Net.LOGIX Anyway to identify a tag data type without declaring it in code?

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?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #19029
    Mooreppjmooreppj
    Participant
    • Topics: 1
    • Replies: 1
    • Total Posts: 2
    Karma: 16
    Rank: Padawan

    Hello!

    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!

     

    #19117
    AdminFred Graham
    Keymaster
    • Topics: 16
    • Replies: 167
    • Total Posts: 183

    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!

    #19171
    Mooreppjmooreppj
    Participant
    • Topics: 1
    • Replies: 1
    • Total Posts: 2
    Karma: 16
    Rank: Padawan

    Hello Fred,

    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!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.