UDT OPC Item Path from Parts of Name

We have 15 identical devices whose data comes to us from a data concentrator, so on the OPC side there is one device definition/connection. We have a UDT for the devices. When creating the tags the structure looks like this:

Site_ID            (folder)
   Device_1        (UDT Instance)
       Tag_x
       Tag_y
   Device_2
   ....
   Device_n

the structure in the concentrator is organized, so it is easy to calculate the address in the OPC space. But the only way I’ve found to do that is using a parameter, which adds an extra step, and room for error. Also having trouble setting the OPC device name for the same reason. What I would like to do is create the OPC Item Path from parts of the Instance:

ns=1,s=[Site_ID]AnalogInput:value(right(InstanceName,1))*baseaddress+y....

The closest I can come using the default parameter bindings is to use {PathtoParentFolder}, but that results in “Site_ID\Device_n”. So I need left something like:

[.]../

or

left({PathtoParentFolder}, len({PathtoParentFolder})-find("/",{PathtoParentFolder})

I can’t seem to find a syntax for the relative path that seems to work in the OPC Item Path definition, and expression functions don’t fly.

And trying to pull the device number off the right side of the instance name (in the OPC Item Path binding) is like pulling teeth. All of the examples show using a parameter to set the device number (Motor Number:1), is there any way I can read that from the InstanceName instead? Having to put the number at the end of the tagname, and then enter in a parameter of the same tag is just an extra step I’d like to avoid.

Suggestions?

Use parameters. Then use a script to set/audit your parameter values.

1 Like

Hi, I know this is an old topic, but could you expand on what you mean by this? I'm currently trying do this, but I am unable to set an item path with parameters that ignition likes.

I would guess it is syntax issue, getting an OPC path from parameters does work, I just couldn't get it to work from something that was not a parameter we defined for the purpose. Here's an OPC path that works:

ns=1;s=[{Site_ID}]AnalogInput{9+DNP_Base+Device_Index*DNP_Size}

In this case Site_ID is a string parameter and DNP_Base, Device_Index, and DNP_Size are integer parameters.

(A newer version of Ignition has decided it does not like the underscore in parameter names, but this one still works).

This then resolves to something like:

ns=1;s=[04981_Spring_St_BESS]AnalogInput509

My original quest was to derive what became Device_Index from the tagname, so that if if this was Device_Name_4 I could just read the "4" from the end of the tagname, but I never got that to fly.

What specific issues are you running into?

I figured it out! Thanks for replying! I wasn't using a parameter and was instead using a custom property because I am new to this and perhaps a little stupid