Comments (10)
You can get the dimensions of a tag by reading attribute 8 for the Symbol Object. Here is how I do it.
from pylogix.
There is not a way. I'm curious though... maybe I can come up with something.
Can you give me a bit of context on what you are planning on doing? Maybe with tag name examples and datatypes?
Are these tag names that you already know, but the same tag is an array in one PLC but not in another?
Or are you using GetTagList to get tag names, then trying to read them?
from pylogix.
Envisioning connecting to a PLC and running and running GetTagList() and then from that maybe opening up a flask dev server which would serve up in a data table the tag lists generated along with their datatypes and the values.
I could refresh the data on the server side maybe every 5 seconds or whatever would be reasonable and thru ajax refresh the browser in real-time.
In order to serve up the data I would need to know if the tag is multidimensional and how large.
I'm not very familiar with PLC tags but I would think only certain datatypes can be multidimensional?
The dev PLC I'm doing some initial prototype work on is a CompactLogix.
All PLC's I"m working with will be completely different implemented by different people at different times making different parts
I do not know what the tag names are coming up to the machine and I'm trying to determine which tags I want to use for data collection.
My use case for this would be to connect to a machine while it is producing parts and use the tag names and the data values to quickly determine which data is relevant for my project.
Attached an example output of tags and data types.
TagList_csv.txt
Thanks again
from pylogix.
Ah I see. This will be much more difficult. It is not impossible, but not currently possible. On my list of things to work on, I have always thought it would be cool to do exactly what you are after, just connect to the PLC, get the tags, and start reading them.
You are correct, the PLC has arrays, and multi-dimensional arrays (up to 3 dimensions). Using more than one dimension is a bit uncommon though, but I suppose that doesn’t matter.
A Logix PLC has a few basic data types: STRING, SINT, INT, DINT, LINT, REAL, BOOL. Then there is the UDT. UDT is a user created data type, or a data type that is made up of the base data types. When requesting the tags, I get the tag name and basic data type. The problem that I need to solve is interrogating the UDT’s to get down to their basic data type.
Let’s say we have a UDT called “Person”, it’s made up of a “Name”(STRING) and an “Age” (SINT). So we create an instance of it and we have Bill.Name and Bill.Age. When you request the tag list, you will get Bill, and it will be identified as a UDT. A tag called MyTimer that is the TIMER data type also appears to be a UDT. What would need to happen is we would need to find out the makeup of “Person”. Then you add the possibility of nested UDT’s and arrays, it gets more complicated. And the process takes a bit longer.
This is something I hope to work out as time allows. One user shared a clever way of working with UDT’s which involved exporting the PLC program to a L5X file (which is essentially XML). You can fairly easily parse a L5X in python to get the tag names and structures, then read the tags that were in the L5X. This may be an option for you for now. I'll think about this some more...
from pylogix.
Thanks for info on parsing the L5X export.
Would work just fine and already some good libraries developed.
from pylogix.
Hopefully I'll sort out getting a more complete picture of the tags soon. I've been experimenting with some ideas. Stay tuned...
from pylogix.
Thank you for this library too!
Is there any progress on this issue? Can we indentify the dimensional of Tags now ?
from pylogix.
Could this be done by brute force?
try a tag[0], if it returns something, then try tag[0][0] , and just keep going until you get None. That's one way to find out the depth of a tag.
Thoughts?
from pylogix.
Thanks for the details @ottowayi, I'll check into it.
from pylogix.
I just used the l5x parsed it and read the Demention tag and then a
ref = comm.Read('tag', dementionvariable)
That way it just pulls the whole array. My first try used a while loop but it wasn't to my liking and lists are easier to work with plus i don't have to assemble all the output form the read.
from pylogix.
Related Issues (20)
- "Forward open failed" when trying to read tags from Berghof PLC HOT 8
- .GetDeviceProperties always returns DeviceType of "None" HOT 5
- Issues connecting to emulate HOT 7
- micro850 connection HOT 5
- Return data gets jumbled up on a multi write when the tags don't exist. HOT 13
- The return value is different when using a multi write compared to a single write for a string. HOT 4
- cannot get a tag list HOT 3
- Is it possible to inhibit a periodic task? HOT 2
- pylogix - returning a tag list as a row of values HOT 7
- PLC REAL values HOT 5
- Pylogix - compare a previously acquired tag list with the current one HOT 5
- Discover does not work while running pylogix in docker HOT 10
- Invalid Continuation Byte HOT 5
- Abnormal code termination. HOT 8
- Do I need to use routing? HOT 20
- PLC connection best practice HOT 8
- Forward Open Failed HOT 22
- Connection Issues HOT 9
- PLC read does not run when called from a function HOT 5
- documentation on the CIP protocol HOT 8
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 pylogix.