forked from bacElmore/PythonProjects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestOPCUA.py
37 lines (29 loc) · 858 Bytes
/
testOPCUA.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from opcua import Client
import schedule
import time
client = Client('opc.tcp://10.1.10.200:4840')
client.connect()
i1 = 0
def grabData():
global i1
obj0 = client.get_node('ns=2;s=SR_Main.faux_Output1')
obj1 = client.get_node('ns=2;s=SR_Main.faux_Output2')
obj2 = client.get_node('ns=2;s=SR_Main.testStr')
# print("Objects node value is: ", obj0.get_value())
print("Current Temperature is: ", obj1.get_value())
print('Count: ', i1)
i1 = i1 + 1
# print("Objects node value is: ", obj2.get_value())
schedule.every(2).seconds.do(grabData)
try:
while 1:
schedule.run_pending()
time.sleep(1)
except KeyboardInterrupt:
client.disconnect()
client.close_session()
print('----------')
print('Keyboard Interrupted!')
print('----------')
# client.disconnect()
# client.close_session()