目标:通过Python实现OPCUA数据的读取
关键字:Python kepware
环境:Python 3.6
1.准备
1.1 kepware连接PLC,导出OPCUA变量清单
1.2 kepware开通OPCUA Server,IP:10.174.212.190:56766
1.3 Python 3.6,opcua包0.98.13
2. 测试
2.1 python 代码
from opcua import Client, ua
client = Client('opc.tcp://10.174.212.190:56766/', timeout=10)
client.connect()
try:
node = client.get_node('ns=2;s=ST10.PLC.TypeNoCur')
print(node.get_value())
except Exception as e:
print(e)
finally:
client.disconnect()
3.运行结果
F01R00Y164