目標:通過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