› PLCGurus.NET Live & Interactive Forum › PLC Questions and Answers › Rockwell, Allen-Bradley, Stratix › Net.LOGIX Anyway to identify a tag data type without declaring it in code?
- This topic has 2 replies, 2 voices, and was last updated 3 years, 2 months ago by Anonymous.
- March 17, 2020 at 2:38 pm #19029AnonymousKarma: 0Rank: Padawan
I have followed Fred’s tutorial using Ingear’s .NETLogix drivers for a CompactLogix L33ER and have been very successful in both reproducing his results and obtaining some added functionality I was hoping to achieve following this solution to our automation project here.
Unfortunately, C# is a relatively new programming language to me and while this is a great learning experience, I do find comprehending the netlogix documentation to be difficult and leaving me with questions hence why I’m asking a question here!
I was wondering if there was a way that someone knows here using the .NET Logix drivers to identify tag data types without having to explicitly instantiate the datatype (or in my case, the Tag.ATOMIC.String parameter) in the constructor of the Tag class. I have checked out the solution code for the Tag Browser that came with our installation and I feel like the answer is in there… somewhere, but I am not entirely sure what could possibly give this information without looping through the entire tag tree as is what I think is going on in that demonstration program.
Simply put: I would like to be able to read a tag’s datatype in my PLC based on its string name as registered on the PLC.
Please let me know if I’m not being in clear in my question. I’d be happy to clarify and provide context if any one is interested.
Thank you!March 19, 2020 at 10:26 am #19117PLCGuruKeymaster
Hi there, and welcome to the forums!
Not sure if this is what you’re after, but there are several overloads for the Tag class. You could try something like this…
Tag tagToBeRead = new Tag(“your full path controller tagname here”);
if (Controller.ReadTag(tagToBeRead) == ResultCode.E_SUCCESS)
string dataType = tagToBeRead.DataType.ToString();
Hope that helps!March 22, 2020 at 9:39 am #19171AnonymousKarma: 0Rank: Padawan
Thanks for your reply! I believe your solution may be exactly what I’m looking for. I just wish I could get to my test rig at work at the moment and actually prove it with the actual controller!
I’ll be sure to update you if this works in case someone else has this problem too. Just wanted to thank you for your response!
- You must be logged in to reply to this topic.