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