2 sys.path.insert(0,
"..")
5 from opcua
import Client
6 from opcua
import uaprotocol
as ua
12 Client to subscription. It will receive events from server 16 print(
"Python: New data change event", node, val)
19 print(
"Python: New event", event)
22 if __name__ ==
"__main__":
24 logging.basicConfig(level=logging.WARN)
25 client = Client(
"opc.tcp://192.168.56.100:49320/OPCUA/SimulationServer/")
30 root = client.get_root_node()
31 print(
"Root is", root)
32 print(
"childs of root are: ", root.get_children())
33 print(
"name of root is", root.get_browse_name())
34 objects = client.get_objects_node()
35 print(
"childs og objects are: ", objects.get_children())
38 tag1 = client.get_node(
"ns=2;s=Channel1.Device1.Tag1")
39 print(
"tag1 is: {0} with value {1} ".format(tag1, tag1.get_value()))
40 tag2 = client.get_node(
"ns=2;s=Channel1.Device1.Tag2")
41 print(
"tag2 is: {0} with value {1} ".format(tag2, tag2.get_value()))
44 sub = client.create_subscription(500, handler)
45 handle = sub.subscribe_data_change(tag1)
46 handle = sub.subscribe_data_change(tag2)
48 from IPython
import embed
52 sub.unsubscribe(handle)
def datachange_notification(self, node, val, data)
def event_notification(self, event)