AdvancedHMI Software

General Category => Support Questions => Topic started by: jscott on August 30, 2016, 12:07:28 PM

Title: CLX subscribing and reading an array
Post by: jscott 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.

Title: Re: CLX subscribing and reading an array
Post by: Archie on August 30, 2016, 01:18:35 PM
Which version are you using?
Title: Re: CLX subscribing and reading an array
Post by: jscott 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.

Title: Re: CLX subscribing and reading an array
Post by: Archie 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
Title: Re: CLX subscribing and reading an array
Post by: jscott 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
Title: Re: CLX subscribing and reading an array
Post by: Archie on September 23, 2016, 04:40:18 PM
Try it with version 3.99r
Title: Re: CLX subscribing and reading an array
Post by: jscott on September 23, 2016, 04:49:41 PM
I just tried 399r and same thing.
Title: Re: CLX subscribing and reading an array
Post by: Archie on September 23, 2016, 08:45:14 PM
Try Patch 2 for V399r :

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

Title: Re: CLX subscribing and reading an array
Post by: jscott on October 03, 2016, 11:43:59 AM
It works Thank You!
Title: Re: CLX subscribing and reading an array
Post by: jscott 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])
Title: Re: CLX subscribing and reading an array
Post by: Archie 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?
Title: Re: CLX subscribing and reading an array
Post by: Archie 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.
Title: Re: CLX subscribing and reading an array
Post by: jscott 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