Code Monkey home page Code Monkey logo

Comments (10)

ottowayi avatar ottowayi commented on August 17, 2024 1

You can get the dimensions of a tag by reading attribute 8 for the Symbol Object. Here is how I do it.

from pylogix.

dmroeder avatar dmroeder commented on August 17, 2024

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.

jdingus avatar jdingus commented on August 17, 2024

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.

dmroeder avatar dmroeder commented on August 17, 2024

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.

jdingus avatar jdingus commented on August 17, 2024

Thanks for info on parsing the L5X export.

Would work just fine and already some good libraries developed.

from pylogix.

dmroeder avatar dmroeder commented on August 17, 2024

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.

su600 avatar su600 commented on August 17, 2024

Thank you for this library too!
Is there any progress on this issue? Can we indentify the dimensional of Tags now ?

from pylogix.

TheFern2 avatar TheFern2 commented on August 17, 2024

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.

dmroeder avatar dmroeder commented on August 17, 2024

Thanks for the details @ottowayi, I'll check into it.

from pylogix.

th3dj avatar th3dj commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.