General Category > Tips & Tricks

ControlLogix ReadUDT and WriteUDT

(1/2) > >>

Archie:
As of version 3.99y Beta 11, it is now possible to read and write complete UDTs into an equivalent class. To use this, you must create classes and map the data types from CLX to .NET equivalents. The following link has a chart that shows the data type equivalents:

https://advancedhmi.com/documentation/index.php?title=WriteUDT

An example would be the UDT shown in the attached picture. An equivalent class for this UDT would be:

--- Code: ---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 Microseconds As Integer
End Class

--- End code ---

Then to read the value of the UDT:


--- Code: ---Dim MyUDT as DateTimeUDT = EthernetIpForCLXCom1.ReadUDT("MyUDT",GetType(DateTimeUDT))

--- End code ---


NOTE : Creating a class with public fields is considered bad OOP practice. But in order to map arrays, it was necessary to bend that rule a little to make the ReadUDT possible.

bachphi:
Definitely good news, thank you Archie.

Archie:
As of 3.99y Beta 30, there has been a change in ReadUDT to use generics. The new format is like this:

--- Code: ---        Dim MyUDT As DateTimeUDT = EthernetIPforCLXCom1.ReadUDT(Of DateTimeUDT)("MyUDT")

--- End code ---

marcowy:

--- Quote from: Archie on May 28, 2018, 02:40:56 PM ---As of version 3.99y Beta 11, it is now possible to read and write complete UDTs into an equivalent class. To use this, you must create classes and map the data types from CLX to .NET equivalents. The following link has a chart that shows the data type equivalents:

https://advancedhmi.com/documentation/index.php?title=WriteUDT

--- End quote ---
According to this SINT = SByte. But what about USINT? Can I delcare it as Byte and read/write it with ReadUDT/WriteUDT?

Archie:

--- Quote from: marcowy on January 06, 2021, 05:07:08 PM ---According to this SINT = SByte. But what about USINT? Can I delcare it as Byte and read/write it with ReadUDT/WriteUDT?

--- End quote ---
Unsigned tag types are not yet supported, but I will look into getting this implemented in the next beta version.

Navigation

[0] Message Index

[#] Next page

Go to full version