Grab the UDT instance name and parent folder name

Hi everyone

I have a OPC server that use following hierarchy for tags:
Area.Device.EquipmentID_Signal
Device = PLC name like HIMA,FCN,S71200,…
EquipmentID = FIC212
Signal = PV, XA, HOA,…

Example: DPG.HIMA.FIC212_PV

In ignition I mimic same hierarchy folder in tag list and UDT:

  • The Area and Device is folder name.
  • The UDT instance is EquipmentID.
  • Singals is UDT element tag.

In UDT for OPC Item Path string I want to use the UDT instance name and parent folders name reference.
Now it is something like this and is not dynamic:
ns=2;s=DPG.HIMA.FIC212_PV
I do NOT want to use custom parameters to fill this data for each instance manually.
If I can make reference to folder and instance UDT name this string is fill automatically for each items. For example in wonderware I can use me. to reference to UDT isntance name and Parent to reference to parent folder.

I search document but didn’t find any trick to reference parent folder and UDT itself instance name. Can someone help me in this.
Thanks.

Nader

I find some solution by using {InstanceName} and {TagName} pre-define parameters.
{PathToParentFolder} is return folder path with \ as seperator which i need dot . instead

Does anyone know a solution to replace \ with . for {PathToParentFolder}?

Thanks.

Try:

replace('{PathToParentFolder}', '/' , '.')

it doesn’t not work in opc item path:
ns=2;s=replace(’{PathToParentFolder}’, ‘/’ , ‘.’).{InstanceName}_{TagName}
I also test it in memory string tag.
the replace function doesn’t work in UDT.

You need to put quotes around each spot a parameter goes.

Forgive me Nader, I was not thinking correctly. Time for that second cup of coffee… :slight_smile:

The only way you can make a OPC tag more dynamic, as near as I can tell, is by using a parameter. You would need to use system.tag.editTag() to modify the parameter.

I use parameters but I want them automatically fill when I instance UDT. There are some parameter like {InstanceName} which is very helpful.
I want a method to write my parameter when each time i instance a UDT but dont know where to write code!!!

with system.tag.editTag() how can I access parameter of UDT?
example:
UDT = motor
paramter = area
and where should I run it? I want when I instance UDT the parameter value set to XX.YY instead of XX\YY
thanks

Hi Nader,

Did you find a solution to this problem? I too would like to use something like the replace command that Jordan mentioned. something like:

replace('{InstanceName}', 'fbLubricationUnit', '')

as a way to delete part of the instance name.

Cheers,
David

Hi David,
Not possible yet, for this cases I put all my tag data in an excel sheet and import it into ignition and parse it by python script and create tags. Much easier. specially for very complex OPC UA item path.

Thanks for the quick reply. I have heard that in 8.1 it is possible, but I am still using 7.9 so I will need to find an alternative. Something interesting that I found is

system.tag.editTag(tagPath="tagpath", "OPCItemPath":"newOpcItemPath")

However, I have not been able to make it work.

Cheers,
David

This is a pretty old thread, but I am trying to do the same thing. I am grabbing tags from KEPserverEX that are of the format: Driver.PLC.TagName.PropertyName

When I create the UDT tags in Ignition, I want the name of the folder they reside in to be used as "PLC" in my OPC tag string.

The closest thing to getting that is the UDT parameter "PathToParentFolder" but this includes the ENTIRE path to the instance and instance name. I've used the following expression to determine the parent folder name from PathToParentFolder parameter:

// This expression finds the parent folder name of the UTD instance from the path name
substring(replace({PathToParentFolder},"/"+{InstanceName},""),lastIndexOf(replace({PathToParentFolder},"/"+{InstanceName},""),"/")+1)

But... if I had kept reading, I would have realized that Ignition does not allow you to insert a Tag into the OPC Item Path string; you MUST use a parameter. So close!

I think I will still substitute the Instance Name, and the make parameters for "Driver" and "PLC" with defaults values that will make my life easier.

I raised the same question a while ago, my UDT contains enough parameters to build the opc string.

In my folder structure I have used memory tags for the various information needed to build the correct tag path .

I then use a script to fill out the parameters in the UDT tags. So all I need to do I just name the tag, and the script takes care of the rest

1 Like