-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
55 lines (46 loc) · 1.58 KB
/
main.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from opcua import Client
import time
import opcua_app
# create client
# client = Client("opc.tcp://192.168.0.2:4840/freeopcua/server/")
# client.connect()
# get objects handle from client
# print(f"{client.get_namespace_array() = }")
# objects = client.get_objects_node()
# print(f"{objects = }")
# node_1 = objects.get_children()
# server_interfaces = node_1[2]
# server_interfaces = client.get_node('ns=3;s="ServerInterfaces"')
# server_interface_1 = server_interfaces.get_children()
# data_block = server_interface_1.get_children()[0]
# print(data_block.get_value())
# print(server_interfaces.get_children())
# while True:
# values = client.get_node('ns=4;i=2')
# for child in values.get_children():
# print(child.get_value()) # print(values.get_children())
# word_1 = client.get_node('ns=4;i=3')
# print(word_1.get_value())
# time.sleep(1)
# # get objects and their children from objects handle
# tempsens = objects.get_children()[1]
# bulb = objects.get_children()[2]
# print(f"{bulb.get_children() = }")
# print(f"{bulb.get_children()[0].get_browse_name() = }")
#
# state = bulb.get_children()[0]
# print(f"{state.get_value() = }")
#
# state.set_value(True)
# print(f"{state.get_value() = }")
#
# print(f"{tempsens.get_children() = }")
# for child in tempsens.get_children():
# print(f"{child.get_value() = }")
#
# # another way to get node's children
# temp = client.get_node('ns=2;s="TS1_Temperature"')
# print(f"{temp.get_value() = }")
# client.close_session()
if __name__ == '__main__':
opcua_app.run_app()