Author Topic: BeginReadMultiple  (Read 2045 times)

qmd

  • Newbie
  • *
  • Posts: 4
    • View Profile
BeginReadMultiple
« on: April 26, 2016, 01:59:57 AM »
Hi,

Just hoping to see a sample of how to use BeginReadMultiple()
Trying to work out how I can build my list of tags to read.

Thanks!

qmd

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: BeginReadMultiple
« Reply #1 on: April 26, 2016, 02:58:45 AM »
I managed to write the code for this to compile, but don't think it's correct as I am not ever getting a DataReceived event. Any idea why?
Code I used to read is:

        Dim result As New Integer

        Dim DintTags As New List(Of Drivers.CLXAddressRead)
        DintTags.Add(New Drivers.CLXAddressRead("DINT1"))
        DintTags.Add(New Drivers.CLXAddressRead("DINT2"))
        DintTags.Add(New Drivers.CLXAddressRead("DINT3"))
        DintTags.Add(New Drivers.CLXAddressRead("DINT4"))
        DintTags.Add(New Drivers.CLXAddressRead("DINT5"))
        result = EthernetIPforMicro800Com1.BeginReadMultiple(DintTags)
        Console.WriteLine("result: " & result)
« Last Edit: April 26, 2016, 03:06:09 AM by qmd »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: BeginReadMultiple
« Reply #2 on: April 26, 2016, 03:50:26 AM »
The BeginReadMultiple will fire the event, but the values are not extracted to e.Values

You will have to manually extract it like this:
Code: [Select]
    Private Sub EthernetIPforCLXCom1_DataReceived_1(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles EthernetIPforCLXCom1.DataReceived
        Dim x As Int16 = BitConverter.ToInt32(e.RawData, 0)
        MsgBox(x)
    End Sub

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: BeginReadMultiple
« Reply #3 on: April 26, 2016, 08:21:43 AM »
My solution above is not correct. I'm investigating further into this

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: BeginReadMultiple
« Reply #4 on: April 26, 2016, 02:24:06 PM »
You will need to specify the NumberOfElements:
Code: [Select]
        Dim addresses As New List(Of MfgControl.AdvancedHMI.Drivers.CLXAddressRead)
        Dim adr As New MfgControl.AdvancedHMI.Drivers.CLXAddressRead("DINTTag")
        adr.NumberOfElements = 1
        addresses.Add(adr)
        EthernetIPforCLXCom1.BeginReadMultiple(addresses)

qmd

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: BeginReadMultiple
« Reply #5 on: April 26, 2016, 11:02:33 PM »
Does this work on MicroLogix?

I have used your code:
Code: [Select]
        Dim addresses As New List(Of MfgControl.AdvancedHMI.Drivers.CLXAddressRead)
        Dim adr As New MfgControl.AdvancedHMI.Drivers.CLXAddressRead("DINT1")
        adr.NumberOfElements = 1

        addresses.Add(adr)
        EthernetIPforMicro800Com1.BeginReadMultiple(addresses)

And get this exception: A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll

I can connect to tags with a subscription via the visual toolbox items though.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: BeginReadMultiple
« Reply #6 on: April 26, 2016, 11:05:05 PM »
The Mirco800 series does not support Multi Service Requests.

qmd

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: BeginReadMultiple
« Reply #7 on: April 27, 2016, 12:19:42 AM »
OK thanks for your very prompt responses.