AdvancedHMI Software
General Category => Support Questions => Topic started by: sds5150 on February 04, 2020, 12:00:15 PM
-
We are trying to use the ReadUDT function in AdvancedHMIv399yBeta33.
The image shows our test UDT in the PLC called TIme.
We have a class setup in vb.net as follows
Public Class TimeUDT
Public Property Yr As Int32
Public Property Mo As Int32
Public Property Da As Int32
Public Property Hr As Int32
Public Property Min As Int32
Public Property Sec As Int32
Public Property uSec As Int32
Public Property double_str As String
Public Property single_str As String
End Class
When we execute the code
Dim objT As TimeUDT
objT = _EthernetCommsMain.ReadUDT(Of TimeUDT)("time")
We get data filling the properties but run into a problem with double_str. It is an array in the UDT.
How do we setup our class so that it can handle the array?
Thanks for the help!
-
Public Class TimeUDT
Public Yr As Int32
Public Mo As Int32
Public Da As Int32
Public Hr As Int32
Public Min As Int32
Public Sec As Int32
Public uSec As Int32
Public double_str(2) As String
Public single_str As String
End Class
-
If a StrArray declared as STRING[2] on the PLC side, then its class size should be declared as (1) not 2 :
Public Class DateTimeUDT
Public Year As Integer
Public Month As Integer
Public Day As Integer
Public Hour As Integer
Public Minute As Integer
Public Second As Integer
Public mSec As Integer
Public StrArr(1) As String
End Class
....
Dim DTCurrent As DateTimeUDT = PLC.ReadUDT(Of DateTimeUDT)("DTCurrent")
(https://i.postimg.cc/vT4PM2jM/UDT-Date-Time.png)
-
If a StrArray declared as STRING[2] on the PLC side, then its class size should be declared as (1) not 2 :
Good catch. Trying to keep up with which system indicates number of elements versus the maximum element always makes me have to think twice.
-
Some example for C#??
-
There is some C# here: https://www.advancedhmi.com/forum/index.php?topic=2545.0
You can also try using online converters to convert from VB to C#.