2 sys.path.insert(0,
"..")
5 from IPython
import embed
12 shell = code.InteractiveConsole(vars)
16 from opcua
import Client
22 Subscription Handler. To receive events from server for a subscription 23 data_change and event methods are called directly from receiving thread. 24 Do not do expensive, slow or network operation there. Create another 25 thread if you need to do such a thing 28 print(
"New event recived: ", event)
31 if __name__ ==
"__main__":
33 client = Client(
"opc.tcp://localhost:4840/freeopcua/server/")
39 root = client.get_root_node()
40 print(
"Objects node is: ", root)
43 obj = root.get_child([
"0:Objects",
"2:MyObject"])
44 print(
"MyObject is: ", obj)
46 myevent = root.get_child([
"0:Types",
"0:EventTypes",
"0:BaseEventType",
"2:MyFirstEvent"])
47 print(
"MyFirstEventType is: ", myevent)
50 sub = client.create_subscription(100, msclt)
51 handle = sub.subscribe_events(obj, myevent)
54 sub.unsubscribe(handle)
def event_notification(self, event)