Author Topic: List member names of a data type  (Read 2794 times)

sds5150

  • Newbie
  • *
  • Posts: 14
    • View Profile
List member names of a data type
« on: March 31, 2020, 11:28:03 AM »
I have a user defined data type that has a large number of members.  Is it possible to get a list of the members names?

I would like to be able to export this list to a spreadsheet.

I have found that I can list tags using the following, but that doesn't give me a way to list the members within a UDT tag.

 Dim CLXTag() As MfgControl.AdvancedHMI.Drivers.CLXTag
CLXTag = _EthernetCommsMain.GetTagList()


Thanks!!

bachphi

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: List member names of a data type UDT
« Reply #1 on: December 02, 2020, 10:35:21 AM »
1. Is there a way to get member tag names of a UDT?

2. With the current version, will it do read/write to sub UDTs [I have not tried it yet]
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: List member names of a data type
« Reply #2 on: December 02, 2020, 02:28:03 PM »
It looks like you would need to know the members of UDT, see these topics and also search the forum:

   https://www.advancedhmi.com/forum/index.php?topic=2545.0
   https://www.advancedhmi.com/forum/index.php?topic=2112.msg14373#msg14373

Also see the wiki:

   https://advancedhmi.com/documentation/index.php?title=WriteUDT

« Last Edit: December 02, 2020, 02:30:23 PM by Godra »

bachphi

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: List member names of a data type UDT
« Reply #3 on: December 03, 2020, 08:48:30 AM »
1. Is there a way to get member tag names of a UDT?

2. With the current version, will it do read/write to sub UDTs [I have not tried it yet]

Read/Write to UDT within a UDT does work

Code: [Select]
Public Class DateTimeUDT
    Public Year As Integer
    Public Month As Integer
    Public Day As Integer
    Public Hour As Integer
    Public Minute As Integer
    Public Second As Integer
    Public mSec As Integer
    Public StrArr(1) As String
    Public Limits As New Limits
End Class

Public Class Limits
    Public LowLimit As Single 'Double, Decimal
    Public Hi_Limit As Single
End Class

...
Dim DTCurrent As New DateTimeUDT

DTCurrent.Year = 2021
        DTCurrent.Month = 12
        DTCurrent.Day = 12
        DTCurrent.Hour = 12
        DTCurrent.Minute = 12
        DTCurrent.Second = 12
        DTCurrent.mSec = 12
        DTCurrent.StrArr(0) = "Haha"
        DTCurrent.StrArr(1) = "Haha22"
        DTCurrent.Limits.LowLimit = 2.2
        DTCurrent.Limits.Hi_Limit = 4.4

        PLC.WriteUDT("DTCurrent", DTCurrent)

===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

bachphi

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: List member names of a data type
« Reply #4 on: December 03, 2020, 03:15:36 PM »
Added a string with custom length, it still read good!

Now,  if only Archie can take one step further like Ingear. NET.LOGIX can browse all Controller & Program Scope PLC tags including UDT's, nested UDT's, arrays of UDT's and arrays of nested UDT's.  See our TagBrowse example.

http://ehelp.ingeardrivers.com/netlogix7/WebHelp/Tag_Browse_Project.htm
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

bachphi

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: List member names of a data type
« Reply #5 on: December 03, 2020, 04:05:26 PM »
Another thought, maybe someone can quickly develop this:

read in the xml file from Logix program.L5X.
Next, generate a PLC file contains all classes from the <DataTypes>
Then, enumerate a PLCtag file consists of all tags from <Tags>
All tags are now avail. for use.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: List member names of a data type
« Reply #6 on: December 05, 2020, 12:49:05 AM »
He wants it all in a spreadsheet and RSLogix 5000 does allow all the tags be exported as CSV file:

   https://literature.rockwellautomation.com/idc/groups/literature/documents/rm/1756-rm084_-en-p.pdf

Then he can open either L5X or L5K file in a Notepad and manually type in all UDT members into the spreadsheet.

bachphi

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: List member names of a data type
« Reply #7 on: December 09, 2020, 10:30:10 AM »
not sure if that's any better.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: List member names of a data type
« Reply #8 on: December 09, 2020, 08:04:26 PM »
It's a procedure that anybody can perform.

Other suggestions for listing UDT members are currently wishful thinking.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: List member names of a data type
« Reply #9 on: January 02, 2021, 10:18:01 AM »
Now,  if only Archie can take one step further like Ingear. NET.LOGIX can browse all Controller & Program Scope PLC tags including UDT's, nested UDT's, arrays of UDT's and arrays of nested UDT's.  See our TagBrowse example.

http://ehelp.ingeardrivers.com/netlogix7/WebHelp/Tag_Browse_Project.htm
Coming soon. I posted a demo application showing capabilties:

https://www.advancedhmi.com/forum/index.php?topic=2835.0

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: List member names of a data type
« Reply #10 on: January 02, 2021, 10:23:02 PM »
Archie,

Besides for the IP, how do you specify a path in the browser (does it assume any specific path)?

Can you post the whole solution?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: List member names of a data type
« Reply #11 on: January 03, 2021, 04:02:04 AM »
For the record, this is the code that populates the tree. It uses a recursive subroutine so it can drill into inifinte layers

Code: [Select]
    Private Sub Button1_Click_8(sender As Object, e As EventArgs) Handles Button1.Click
        Dim y() As AdvancedHMI.Drivers.CLXTag = EthernetIPforCLXCom1.GetTagList

        For i = 0 To y.Length - 1
            Dim Node As New TreeNode(y(i).TagName)
            TreeView1.Nodes.Add(Node)
            AddSubNode(Node, y(i).UDTStructure)
        Next
    End Sub

    Private Sub AddSubNode(node As TreeNode, UDTstructure As AdvancedHMI.Drivers.CIP.CLXTemplateObject)
        If UDTstructure IsNot Nothing Then
            For i = 0 To UDTstructure.Members.Count - 1
                Dim SubNode As New TreeNode(UDTstructure.Members(i).Name)
                node.Nodes.Add(SubNode)
                AddSubNode(SubNode, UDTstructure.Members(i).SubTemplate)

                If UDTstructure.Members(i).SubTemplate IsNot Nothing Then
                    SubNode.Text &= " (" & UDTstructure.Members(i).SubTemplate.Name & ")"
                End If
            Next
        End If
    End Sub

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: List member names of a data type
« Reply #12 on: January 03, 2021, 05:38:23 AM »
Neat.

bachphi

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: List member names of a data type
« Reply #13 on: January 09, 2021, 10:38:21 AM »
Now,  if only Archie can take one step further like Ingear. NET.LOGIX can browse all Controller & Program Scope PLC tags including UDT's, nested UDT's, arrays of UDT's and arrays of nested UDT's.  See our TagBrowse example.

http://ehelp.ingeardrivers.com/netlogix7/WebHelp/Tag_Browse_Project.htm
Coming soon. I posted a demo application showing capabilties:

https://www.advancedhmi.com/forum/index.php?topic=2835.0

Thank you for adding the feature. AAHMI could now be #1 contender!
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================