I am trying to test the OPC scripting function to read a tag. I enabled “Anonymous Access” in the OPC UA server settings, all my project tags are visible in the OPC UA tag browser. I copied the tag path of one of the tags and tried to read its value with the following code copied from the scripting examples, which is called in gateway startup script.
I got the problem! Its is the server name “Ignition OPC-UA Server” given in the code snippet of the script function, should not have a hyphen, it should be “Ignition OPC UA Server”! That’s something in the documentation of scripting function to be changed by you guys at IA! The code snippet contains a hyphen in the server name where as the actual OPC UA server name (atleast in version 8) doesn’t have a hyphen! its working fine with that change.
INFO | jvm 1 | 2020/05/20 23:07:08 | Value: 50.0
INFO | jvm 1 | 2020/05/20 23:07:08 | Quality: Good
INFO | jvm 1 | 2020/05/20 23:07:08 | Timestamp: Wed May 20 23:07:08 IST 2020
Another strange thing I found , I just tried to increment the value by one and write back to tag and print it. I find the value is not incremented, though , it changes in Tag DB eventually ! So there is a delay . Is it due to write being async!
Does the Ignition OPC UA server provide the subscription function ? Why is it not supported in the scripting library?
Yes, but there’s not really a compelling reason to make it available via scripting. Most scripts don’t have an appropriate lifecycle to create a monitored item and delete it when they are done, and if you want a continually updated value you can already just access an OPC tag from scripting.
Are all the client methods defined in the spec for client classes implemented in the server?
The spec defines services. The server implements the required ones for the “Standard UA Server” profile.
Is there any sample client code available in java or any other language like python for reference?
Not really sure what you’re asking for here. Sample client code to talk an OPC UA server outside of Ignition?
Ok, that’s what I was also thinking about. I did see the prosys sdk some time back for examples. However you had mentioned on the forum or LinkedIn some python based library. I think it would also be a good reference.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python38\lib\site-packages\opcua\client\client.py", line 272, in connect
File "C:\Python38\lib\site-packages\opcua\client\client.py", line 297, in connect_socket
File "C:\Python38\lib\site-packages\opcua\client\ua_client.py", line 256, in connect_socket
return self._uasocket.connect_socket(host, port)
File "C:\Python38\lib\site-packages\opcua\client\ua_client.py", line 155, in connect_socket
sock = socket.create_connection((host, port), timeout=self.timeout)
File "C:\Python38\lib\socket.py", line 808, in create_connection
File "C:\Python38\lib\socket.py", line 796, in create_connection
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it