Use a tag's Value as a part of another OPC Tag's path

Hello Everybody.

I was wondering if it would be possible to construct a Tag’s source path (e.g. an OPC Tag’s path) by using a combination of strings and dynamic Values from other tags.

For instance, I have two UDT instances called Plc, stored in the Device1 and Device2 folder respectively, like so:


The Plc UDT contains a tag called PlcDeviceName.

Now, each PLC contains a software module called ModuleA, which I model like so:


In both cases, Cooker are instances of a UDT called Cooker, which contains an OPC Tag called Pressure.

What I’m trying to do is to define a dynamic OPC path for Pressure, like so:


which references integer 8 within data block 100 of the underlying SIEMENS PLC (Device1 or Device2 respectively).

I understand the above syntax doesn’t work; I just used it to illustrate my question with an example.
My questions in short:

  • Is it possible to define dynamic OPC paths?
  • If so, how?
  • If not directly possible, can we use some advanced scripting technique to achieve the same results?


Here’s an update of what I’ve been able to accomplish so far.

Based on the following example, this is the result:

I’ve been able to construct a script string by referencing other tags, using the relative tag path, like so:

OpcItemPath Expression Tag’s expression:

"[" + tag('[.]../../Plc/DeviceName') + "]" + "DB733,I8"

Script Expression Tag’s expression:

"shared.pcsmis.opc.readValue('" + tag('[.]OpcItemPath') + "')"

The returned string stored in the “Script” tag is:

This is the global script that returns the OPC value, and it works great as I tested it on its own:

def getOpcServerName():
	return 'Ignition OPC-UA Server' 
def readValue(item_path):
	return system.opc.readValue(getOpcServerName(), item_path)

The only problem I still have is, how to run the script successfully from the Pressure Expression Tag.

Pressure Expression Tag’s expression:

runScript( toString( tag('[.]Script') )  )

This is the error displayed under Tag Diagnostics:

Anyone knows what this error means?