Author Topic: Reading Bool Arrays  (Read 3855 times)

cws

  • Newbie
  • *
  • Posts: 16
    • View Profile
Reading Bool Arrays
« on: October 09, 2013, 05:24:11 PM »
Hi,

I'm trying to read values that were defined as Bool Array (320).  It seems like I can do something like this in code:

Dim values(320) As String
values = EthernetIPforCLXCom1.Read("FAULT[0]", 320)
Dim x As String = values(0)

I really want to see just see 8 values, 231 - 238.  I tried using a BasicLabel control but not sure what I put in for the PLCAddress?  If I use "FAULT[0]", the label shows as "False".  If I use something like "FAULT[0].231", I get an error.  How do I reference the values for setting up DataSubcribers in code and also in controls like the BasicLabel?  I understand .NET but not much with PLC's.

Thanks,
Chris

dmroeder

  • Administrator
  • Full Member
  • *****
  • Posts: 212
    • View Profile
Re: Reading Bool Arrays
« Reply #1 on: October 09, 2013, 07:13:56 PM »
If you want to connect a particular BOOL in that array to a BasicLabel then the PLCAddress would be: FAULT[231] (using your example)

If you would prefer to read them in code and not display them on a user form then you are on the right track, you don't have to read all of them though:

Code: [Select]
        Dim values(0 To 8) As String
        values = EthernetIPforCLXCom1.Read("FAULT[231]", 8)

The above should read FAULT[231] - [238] and store them in values(0) - (7).

edit:  actually it seems there might be a problem reading boolean values in arrays (as you have obviously noticed!)...
« Last Edit: October 09, 2013, 07:38:20 PM by dmroeder »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Reading Bool Arrays
« Reply #2 on: October 10, 2013, 08:37:52 AM »
I don't have my PLC setup to try this right now, but give this a try:
Code: [Select]
dim values(7) as string
for i=0 to 7
  values(i)=EthernetnetIPforCLXCom1.Read("FAULT[" & i+231 & "]",1)
next

There was an issue when reading Boolean arrays across a 32 bit boundary, but this doesn't seem to be the case here.

cws

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Reading Bool Arrays
« Reply #3 on: October 10, 2013, 10:32:42 AM »
Hi Archie,

Thanks for the quick response.

If I try to put "FAULT[231]" into a BasicLabel, it displays an error:

Read Failed.  The particular item referenced (usually instance) could not be found, Status Code=5

If I put "FAULT[0]", the label shows "False".  If I try any other values like 100 and 200, I'll get the same error as above.  If I try doing "FAULT[1]", it gets an error on this line in the EthernetIPforCLXCom.vb file saying "Arithmetic operation resulted in an overflow".

BitResult(0) = CStr((CInt(2 ^ SubscriptionList(i).PLCAddress.BitNumber) And CInt(BitResult(0))) > 0)

If I try to read doing this, it seems to work.  I can stop the program and see that values has 320 items in it with True/False:

Dim values(320) As String
values = EthernetIPforCLXCom1.Read("FAULT[0]", 320)
Dim x As String = values(0)

If I do this, it gets an error in the Read Function in EthernetIPforCLXCom.vb .

Read Failed.  The particular item referenced (usually instance) could not be found, Status Code=5

Dim valuesy(7) As String
values = EthernetIPforCLXCom1.Read("FAULT[231]", 8)
Dim y As String = values(0)

If I'm trying to do DataSubscribers in code, using something like this:

For i = 231 To 238
    objDataSubscribers(DataSubscriberCount) = New MfgControl.AdvancedHMI.DataSubscriber
    objDataSubscribers(DataSubscriberCount).CommComponent = EthernetIPforCLXCom1
    objDataSubscribers(DataSubscriberCount).SynchronizingObject = Me
    objDataSubscribers(DataSubscriberCount).PLCAddressValue = "FAULT[" & i.ToString & "]"
    AddHandler objDataSubscribers(DataSubscriberCount).DataChanged, AddressOf DataSubscriber_DataChanged
    DataSubscriberCount += 1
Next

How should I reference the PLCAddressValue?
 
Thanks,
Chris


cws

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Reading Bool Arrays
« Reply #4 on: October 10, 2013, 11:28:44 AM »
Forgot to mention that I'm using version 359.

I tried doing the DataSubcribers in code using:

For i = 231 To 238
    objDataSubscribers(DataSubscriberCount) = New MfgControl.AdvancedHMI.DataSubscriber
    objDataSubscribers(DataSubscriberCount).CommComponent = EthernetIPforCLXCom1
    objDataSubscribers(DataSubscriberCount).SynchronizingObject = Me
    objDataSubscribers(DataSubscriberCount).PLCAddressValue = "FAULT[" & i.ToString & "]"
    AddHandler objDataSubscribers(DataSubscriberCount).DataChanged, AddressOf DataSubscriber_DataChanged
    DataSubscriberCount += 1
Next

But in the DataSubscriber_DataChanged event I get the error:

Read Failed.  The particular item referenced (usually instance) could not be found, Status Code=5

Thanks,
Chris

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Reading Bool Arrays
« Reply #5 on: October 10, 2013, 12:01:41 PM »
I did find the issue and just about have it resolved. I will try to get a patch posted within the next hour. I will be travelling for the next 4 days, so my access will be limited.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Reading Bool Arrays
« Reply #6 on: October 10, 2013, 12:04:53 PM »
This patch has barely been tested, but I wanted to get it posted before I leave. There are 2 files, replace the file in AdvancedHMIDrivers and AdvancedHMIDrivers/support

cws

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Reading Bool Arrays
« Reply #7 on: October 10, 2013, 01:25:09 PM »
I can put "FAULT[231]" into a BasicLabel now and it seems to work.  I'll try and do some other testing with DataSubscribers and let you know.

Thanks for all of your help,
Chris