Author Topic: non-contiguous registers in DS2  (Read 873 times)

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
non-contiguous registers in DS2
« on: June 08, 2018, 11:50:09 PM »
Archie, is there a way to read a multiple indices of a DS2 with non-contiguous registers.  Such as 40119 with 6 elements is e.values(0)-e.values(5)  Can I add 40154 with 6 elements to the same DS2 and read them in the same fashion?  What would their index be?  I know I can add each one with an element of 1.  Just looking for new ways, thanks.   

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: non-contiguous registers in DS2
« Reply #1 on: June 09, 2018, 12:07:13 AM »
The DataSubscriber2 lets you add multiple items to the PCLAddressValueItems list. Then for each item in the list the DataReturned will fire separately. You then have to check the e.PLCAddress to determine which item the event was fired for. For example

    Private Sub DataSubscriber21_DataReturned(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber21.DataReturned
        If e.PlcAddress = "40119" Then
            '* e.Values contains the data starting with 40119
        ElseIf e.PlcAddress = "40154" Then
            '* e.Values will not contain the values for 40154
        End If
    End Sub