2 sys.path.insert(0,
"..")
4 from datetime
import datetime
7 from IPython
import embed
14 shell = code.InteractiveConsole(vars)
18 from opcua
import ua, uamethod, Server
24 print(
"Monitored Item")
26 for idx
in range(len(event.response_params)) :
27 if (event.response_params[idx].StatusCode.is_good()) :
28 nodeId = event.request_params.ItemsToCreate[idx].ItemToMonitor.NodeId
29 print(
"Node {0} was created".format(nodeId))
33 print(
'modify_monitored_items')
37 print(
'delete_monitored_items')
40 if __name__ ==
"__main__":
42 logging.basicConfig(level=logging.WARN)
51 logger = logging.getLogger(
"opcua.subscription_service")
52 logger.setLevel(logging.DEBUG)
58 server.set_endpoint(
"opc.tcp://0.0.0.0:4840/freeopcua/server/")
59 server.set_server_name(
"FreeOpcUa Example Server")
62 uri =
"http://examples.freeopcua.github.io" 63 idx = server.register_namespace(uri)
66 objects = server.get_objects_node()
69 myfolder = objects.add_folder(idx,
"myEmptyFolder")
70 myobj = objects.add_object(idx,
"MyObject")
71 myvar = myobj.add_variable(idx,
"MyVariable", 6.7)
79 server.subscribe_server_callback(CallbackType.ItemSubscriptionCreated, create_monitored_items)
80 server.subscribe_server_callback(CallbackType.ItemSubscriptionModified, modify_monitored_items)
81 server.subscribe_server_callback(CallbackType.ItemSubscriptionDeleted, delete_monitored_items)
84 print(
"Available loggers are: ", logging.Logger.manager.loggerDict.keys())
def delete_monitored_items(event, dispatcher)
def modify_monitored_items(event, dispatcher)
def create_monitored_items(event, dispatcher)