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?
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.
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.
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?
If going the tag route, I would just create a dataset tag on each gateway in a root folder. That gets filled by a gateway timer event calling system.device.listDevices() every 30 or 60 seconds.
Then you can just reference that dataset tag using the remote tag providers from Perspective.
BUT, calling that script and returning that small of a dataset is a nothing burger for gateway messaging. I use it for the same kind of thing where I need data from databases behind firewalls for perspective reports on the IT side. We read thousands of rows like that with it not even showing up on the gateways CPU or RAM utilization. The gateway network is very efficient.
Thanks a lot! That would be a very good idea, but...
I just tried you idea, with system.device.listDevices() in a script console but it simply returns an empty Dataset of [0R x 4C] with Name, Enabled, State, Driver columns.
Whereas my "[System]Gateway/OPC/Connections/{OPCserver}/Connected" reference tags already implemented and monitored are working properly.