AdvancedHMI Software
General Category => Support Questions => Topic started 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.
-
Which version are you using?
-
V3.99p
I can read a whole array and pull the Boolean I need out of it but that is a lot of overhead.
-
- 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
-
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
-
Try it with version 3.99r
-
I just tried 399r and same thing.
-
Try Patch 2 for V399r :
https://sourceforge.net/projects/advancedhmi/files/advancedhmi/3.5/Patches
-
It works Thank You!
-
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])
-
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?
-
I just a quick test with this tag and it worked ok with a read and write.
-
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