Using system.opc.readValue() on a remote gateway

I have a runtime/tag architecture, where the vision windows are hosted on Server1, and the tags are hosted on Server2.

Server1 is connected to Server2 through the Gateway network.

I would like to have a script execute from a button press that fetches tag values using system.opc.readValue(Server, Path).

I know that this is possible using tag event scripts, but is there any way to do it directly from a component with this architecture?

I don’t see why not…

This link is useful for future needs, I use it all the time.
scripting functions

Thanks for the link. I suppose i should clarify that my script does work when both the vision client, and the tags are on the same gateway.

My issues started when i switched over to the architecture described in the original question.

From further research/testing, i believe that I would need to change my “Server” input to the scripting argument to point to the other server e.g.

returnValue = system.opc.readValue(“”, “My tag path”)

I have not yet found any ignition documentation that details what to use for the “Server” input.

My current best guess would be to configure a new server under: “Gateway/Configure/OPC CONNECTIONS/Servers”. I am currently gathering the hardware required to test this method, but if anyone has some insight on this issue, I would appreciate it.

You would need to add an OPC connection from Server 1 to Server 2 if you wanted to use system.opc calls against Server 2 from Server 1.

If the OPC values you’re trying to read already exist as Ignition tags in Server 2, though, you should just be using system.tag calls instead because you already have access to them as remote tags.

1 Like

Kevin, a quick follow up question on this topic…

Do you know of a way to retrieve the path to a server from a tag provider?

Essentially, I would like to be able to do something like: server = system.getServer(“A Tag Provider”). Where server would then equal: “

Are you aware of anything that can do this?

I don’t think anything like that exists.

You could manually maintain a dataset tag that maps that information in 2 columns. Maybe someone else has a better idea.