OPC Device Connection Status - Via Scripting

Good Morning -

I am running Perspective, 8.1.19. Looking to get the status of my OPC UA devices via a scripting so I can put it in a customer dashboard. I can get a listing of the device names easily enough using a script like this -

devices = system.opc.browseServer(opcServer, nodeId)
for device in devices:
	print device.getDisplayName()

but can't find a way to get the status of each of these devices (connected, connecting, etc.). Has anyone done this before?

Thanks!
Matt

Usually there is a 'Connected' OPC tag created with each OPC device.

Just monitor that tag and you should be good to go.

1 Like

Thanks @kyler.kamyszek, that's what I was looking for! Each connection is listed under the tag folder Gateway/Devices for anyone wondering.

1 Like

To answer in the context of the original quesion, system.device.listDevices() will return a dataset with the same information.

2 Likes

When I look in the tag browser, I do see System - > Gateway -> OPC ->Connections but I don't see devices listed here in the tags. I am looking to display the same information.

You have to create the tag and point it to the connection property.

Is there anyway to also get an enabled bit for if it's enabled in the gateway.

Just from the output of .listDevices(). The device itself can't give that information because its code isn't running at all when disabled, and therefore cannot respond to such a request.

Can I see these connection statuses of the OPC devices if they are on a remote Ignition server?

I have a FrontEnd-Ignition-server that has connections to more IO-Ignition-servers, using for example RemoteTagProvider.

In my case, All OPC connections are on the IO-servers, and all Perspective projects are on the FrontEndServer

Is there any way to see the OPC Status this way?
without building a derived tag list for them?(that's in my mind as a first glance workaround)

Simple way would be to use the gateway network to send messages back and forth between the gateways.
system.util.sendRequest using the remoteServer option.

Thanks for the idea!
I already use some send message and message handlers inside projects, but for this particular case, I can not imagine yet if it would be a bit too sophisticated and no idea what resource hungry would be to ask this way OPC states for around 70-100-150 OPC connections at a time among the many hundreds of them.
Besides other uses, I have a well working complex Map project with a lot of polygons and polygon groups, and when click on a polygon, marker like mini views appear at each place of interest, showing name, shape, and color coding states and alarms. Here I need to add the OPC-NotConnected state as a color.
This OPC-NotConnected I will be also simultaneously used in other views of perspective projects. So there will always be multiple request for the same OPCconnected state.
No idea what approach would work better and return faster results even if a bit complex.
I already tried with working results the derived tag approach trough RemoteTagProvider (since I have a well designed tag structure) but only for a few connections yet. My concern is if too many derived tags for <[System]Gateway/OPC/Connections/.../Connected> may have consequences. Or would this approach work even better than the massage handler approach? or worse?