Comments (3)
I use a compatLogix, and the latest version of libplctag4j
from libplctag4j.
UDTs are read like any other tag type. When you read an entire UDT, you get the whole thing as a blob of bytes. You can also read each field individually.
name="myUDTTag" -> gets the entire tag.
name="myUDTTag.aField" -> gets the field "aField" within the UDT tag.
You can use the tag_rw2 tool from the C project to experiment with this.
If you read an entire UDT at once, it is very fast, but you will need to determine the offsets within the bytes of each field.
For instance, if you have a UDT, myUDTTag, with 3 DINTs, A, B, and C, you can read and extract them like this:
Tag tag = new Tag("...name=myUDTTag"...);
tag.read(1000) // you should check the status here
int fieldAValue = tag.getInt32(0);
int fieldBValue = tag.getInt32(4); // DINTs are 4 bytes
int fieldCValue = tag.getInt32(8);
There are many different packing rules for UDTs that Rockwell imposes. If you have boolean values in a UDT, they are packed into hidden byte values that are stored at the start of the UDT or before the boolean field. Each bit is allocated from one of the bits in the hidden field.
Most fields are padded to their nearest power-of-two size. For instance if you have a UDT with a SINT (one byte) followed by a DINT (4 bytes), the UDT will be a total of 8 bytes. The SINT field will be at the beginning, then there will be 3 bytes of padding and then the DINT field.
Let me know if you still have questions!
from libplctag4j.
Thank you very much, it works, I understand that string data type tags are 88 bytes? I seemed to read.
from libplctag4j.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libplctag4j.