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