AdvancedHMI Software
General Category => Support Questions => Topic started by: sramirez on December 07, 2022, 03:56:56 PM
-
I have a test UDT that I am trying to read a tag with the Data Type of BOOL[3]
I get an error "Index out of range" when I try to use ReadUDT().
I can't figure out what I am doing wrong since I am setting the size of the List(of boolean) in the constructor.
Dim plc As New AdvancedHMIDrivers.EthernetIPforCLXCom
plc.ipaddress = "192.168.1.9"
Dim obj As Test1 = plc.ReadUDT(Of Test)("Test1")
UDT
Test1.TestString STRING
Test1.TestBool BOOL[3]
My vb class is defined as
Public Class Test
Public Property TestString as string
Public Property TestBool as new List(of boolean)
Public Sub New()
for i = 0 to 2
TestBool.add(0)
next
End Sub
End Class
Thanks for any assistance.
Shawn
-
If you are not using version 3.99y Beta, which is downloadable from this forum, try that version.
-
I gave AdvancedHMIv399yBeta38 a try, and did not have any success.
I included the test program.
If I comment out the BoolTest list and the for loop that initializes the list the ReadUDT returns as expected.
I am grateful for any help.
Module Module1
Sub Main()
Dim plc As New AdvancedHMIDrivers.EthernetIPforCLXCom
With plc
.IPAddress = "192.168.1.9"
.PollRateOverride = 1000
.ProcessorSlot = 0
End With
Dim obj As SRTest1 = plc.ReadUDT(Of SRTest1)("SRTest1") <--- Error happens on ReadUDT <Index was out of range. Must be non-negative and less than the size of the collection.>
End Sub
Public Class SRTest1
Public Property TestS1 As String
Public Property TestS2 As New UDT_Pan_Stile
Public Property SRTestS3 As Int32
Public Property BoolTest As New List(Of Boolean)
Public Sub New()
For i = 0 To 31
BoolTest.Add(False)
Next
End Sub
End Class
Public Class UDT_Pan_Stile
Public Property Location As Single
Public Property Type As Int32
Public Property Gauge As Single
End Class
End Module
-
"Index out of range"
Test1.TestBool BOOL[3]
for i = 0 to 2
can you figure out now?
-
Thank you for your assistance.
I have tried for i=0 to 31 in my class's NEW() constuctor but I still get the error "ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection."
I have included images my code and the UDT. I am doing something wrong but I can't figure out what.
If you have time to take another look I would be grateful.
Thanks,
Shawn R
-
I believe I got it to work.
Public Property BoolTest As New List(Of Boolean) and the Sub New() did not work
Removing the Sub New() and changing BoolTest to
Public BoolTest(31) as boolean solved the issue.
Note, you can't define a Public Property BoolTest(31) as boolean