Author Topic: CLX subscribing and reading an array  (Read 2874 times)

jscott

  • Newbie
  • *
  • Posts: 7
    • View Profile
CLX subscribing and reading an array
« on: August 30, 2016, 12:07:28 PM »
I am subscribing and trying to read a Boolean in the middle of an array but it gives an error when it returns data."An exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll but was not handled in user code Additional information: Index was out of range. Must be non-negative and less than the size of the collection."

Private Sub _Click(sender As Object, e As EventArgs) Handles Button3.Click
      Cntrlgxc22Inch.Subscribe("Array[77]", 1, 100, AddressOf VssInfeedStpBfrData16)
End Sub

Dim Array77 As Boolean
      Private Sub VssInfeedStpBfrData16(ByVal sender As Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
        Array77 = e.Values(0)
End Sub

When I read an array of Boolean say TestArray[77].Test as a Boolean it works correctly.


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: CLX subscribing and reading an array
« Reply #1 on: August 30, 2016, 01:18:35 PM »
Which version are you using?

jscott

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: CLX subscribing and reading an array
« Reply #2 on: August 30, 2016, 01:27:13 PM »
V3.99p

I can read a whole array and pull the Boolean I need out of it but that is a lot of overhead.


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: CLX subscribing and reading an array
« Reply #3 on: August 30, 2016, 10:08:46 PM »
- Download the V399p patch from here:

https://sourceforge.net/projects/advancedhmi/files/advancedhmi/3.5/Patches/

- Extract the file
- Copy the file to \AdvancedHMIDrivers\Support  and replace the existing
- Open your project in Visual Studio and Rebuild Solution

jscott

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: CLX subscribing and reading an array
« Reply #4 on: September 23, 2016, 04:25:38 PM »
Finally got back to this project, and I am having issues with the patch it is not giving me an error message anymore it is just not subscribing to the variable, therefore I get no data.

Jamie

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: CLX subscribing and reading an array
« Reply #5 on: September 23, 2016, 04:40:18 PM »
Try it with version 3.99r

jscott

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: CLX subscribing and reading an array
« Reply #6 on: September 23, 2016, 04:49:41 PM »
I just tried 399r and same thing.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI

jscott

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: CLX subscribing and reading an array
« Reply #8 on: October 03, 2016, 11:43:59 AM »
It works Thank You!

jscott

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: CLX subscribing and reading an array
« Reply #9 on: October 03, 2016, 01:44:27 PM »
Ok so the last issue is fixed, I then came across another. It seems like I can not subscribe to a two dimension array (example: Spare[0].Bool[1])

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: CLX subscribing and reading an array
« Reply #10 on: October 04, 2016, 10:16:25 AM »
Ok so the last issue is fixed, I then came across another. It seems like I can not subscribe to a two dimension array (example: Spare[0].Bool[1])
I assume in your example, "Spare" is a UDT?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: CLX subscribing and reading an array
« Reply #11 on: October 04, 2016, 11:36:35 AM »
I just a quick test with this tag and it worked ok with a read and write.

jscott

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: CLX subscribing and reading an array
« Reply #12 on: October 05, 2016, 12:26:00 PM »
Yes this is a UDT thank you.

I am able to read "Spare[0].Bool[1]" but when I subscribe to this variable I get a exception of "Index was put of range. Must be Non-negative and less than the size of the collection. Parameter Name: index". Below is the read and subscribe I used for testing.

    Private Sub Label6_Click(sender As Object, e As EventArgs) Handles Label6.Click
        Label6.Text = Inch22Com.Read("Spare[0].Bool[1]")
    End Sub

    Private Sub Label11_Click(sender As Object, e As EventArgs) Handles Label11.Click
        Inch22Com.Subscribe("Spare[0].Bool[1]", 1, 100, AddressOf TestSub)
    End Sub

    Private Sub TestSub(sender As Object, e As Drivers.Common.PlcComEventArgs)
        Try
            Label11.Text = e.Values(0)
        Catch ep As Exception
            MsgBox(ep.Message)
        End Try
    End Sub