system.opc.getServerState Syntax Help

Hi, I am trying to build out a UDT to monitor my OPC Device connection states. Before building the UDT I just put a label on a page and for the text binding did a runscript using system.opc.getServerState.

I don’t get any binding errors, but the status just comes back “UNKNOWN”, but if I look at the connection status from the portal and view my opc devices is shows “CONNECTED”.

Do I have a syntax problem? Not fully qualifying the path perhaps? Code Below:

runScript("system.opc.getServerState('WW Treatment Plant')", 5000)

Thanks for any help-

I tried an identical expression, I only changed the OPC server name, and it evaluated correctly in both a UDT and an expression binding. Is there something more you are doing? Are you seeing the state as unknown in the client or the designer?

Not doing anything other than the runscript in the labels text binding. I am seeing “UNKNOWN” in the designer and in the windows when running as staging.

runScript("system.opc.getServerState('WW Treatment Plant')", 5000)

I checked the name of the opc device. But just to be clear, this is a PLC setup under the Ignition OPC-UA server. So in script above, the WW Treatment Plant is what I am viewing under OPC>Devices from the configuration page of the web portal.

I though perhaps it needed to state the actual OPC Server and then device.

runScript("system.opc.getServerState('Ignition OPC-UA Server.Devices.WW Treatment Plant')", 5000)

This gets me the same “UNKNOWN” status.

system.opc.getServerState returns the state of an OPC-UA connection (client to server), not the state of a device on the server.

Each of the devices on Ignition’s OPC-UA server should have an ‘Is Connected’ tag or something along those lines – try looking at that instead.

hmmm… Wondering if that will accomplish what I am after. The problem I am having is in several cases the plc backplane has had an IO Fault. When the event occurs if you view the state of the connection from the portal it shows “CONNECTED:FAULT” . My understanding and probably wrong :slight_smile: is that the system.opc.getServerState would return the “FAULT” part of this. The PLC is technically connected and communications are fine, but the PLC itself is faulted and therefore my tags are bad.

I was initially just alarming off the Is Connected tag, but the issue is, this LAN connection is over a wifi bridge and we get periodic packet loss (which is normal when not in excess for wifi). due to the tag scan rate, it picks up the packet loss and triggers the alert. Thats why I was hoping to get the actual PLC status.

It looks like the Connection State tag may be the same thing returned from the system.opc.getServerState… If thats the case perhaps thats the approach… Still does not explain why I am getting the “UNKNOWN”. I am obviously doing something wrong. :scratch: