def __init__(self): self.logger = logging.getLogger(__name__) self.endpoints = [] self._channel_id_counter = 5 self.allow_remote_admin = True self.disabled_clock = False # for debugging we may want to disable clock that writes too much in log self._known_servers = {} # used if we are a discovery server self.aspace = AddressSpace() self.attribute_service = AttributeService(self.aspace) self.view_service = ViewService(self.aspace) self.method_service = MethodService(self.aspace) self.node_mgt_service = NodeManagementService(self.aspace) # import address space from code generated from xml standard_address_space.fill_address_space(self.node_mgt_service) # import address space from save db to disc #standard_address_space.fill_address_space_from_disk(self.aspace) # import address space directly from xml, this has preformance impact so disabled #importer = xmlimporter.XmlImporter(self.node_mgt_service) #importer.import_xml("/home/olivier/python-opcua/schemas/Opc.Ua.NodeSet2.xml") self.loop = utils.ThreadLoop() self.subscription_service = SubscriptionService(self.loop, self.aspace) # create a session to use on server side self.isession = InternalSession(self, self.aspace, self.subscription_service, "Internal", user=User.Admin) self.current_time_node = Node(self.isession, ua.NodeId(ua.ObjectIds.Server_ServerStatus_CurrentTime)) uries = ["http://opcfoundation.org/UA/"] ns_node = Node(self.isession, ua.NodeId(ua.ObjectIds.Server_NamespaceArray)) ns_node.set_value(uries)
def __init__(self, shelffile=None): self.logger = logging.getLogger(__name__) self.server_callback_dispatcher = CallbackDispatcher() self.endpoints = [] self._channel_id_counter = 5 self.allow_remote_admin = True self.disabled_clock = False # for debugging we may want to disable clock that writes too much in log self._known_servers = {} # used if we are a discovery server self.aspace = AddressSpace() self.attribute_service = AttributeService(self.aspace) self.view_service = ViewService(self.aspace) self.method_service = MethodService(self.aspace) self.node_mgt_service = NodeManagementService(self.aspace) self.load_standard_address_space(shelffile) self.loop = utils.ThreadLoop() self.asyncio_transports = [] self.subscription_service = SubscriptionService(self.loop, self.aspace) self.history_manager = HistoryManager(self) # create a session to use on server side self.isession = InternalSession(self, self.aspace, self.subscription_service, "Internal", user=User.Admin) self.current_time_node = Node(self.isession, ua.NodeId(ua.ObjectIds.Server_ServerStatus_CurrentTime)) self._address_space_fixes() self.setup_nodes()
def start(self): self.logger.info("starting internal server") self.loop = utils.ThreadLoop() self.loop.start() self.subscription_service.set_loop(self.loop) serverState = Node(self.isession, ua.NodeId(ua.ObjectIds.Server_ServerStatus_State)) serverState.set_value(ua.uaprotocol_auto.ServerState.Running, ua.VariantType.Int32) Node(self.isession, ua.NodeId(ua.ObjectIds.Server_ServerStatus_StartTime)).set_value(datetime.utcnow()) if not self.disabled_clock: self._set_current_time()
def start(self): self.logger.info("starting internal server") for edp in self.endpoints: self._known_servers[edp.Server.ApplicationUri] = ServerDesc(edp.Server) self.loop = utils.ThreadLoop() self.loop.start() self.subscription_service.set_loop(self.loop) Node(self.isession, ua.NodeId(ua.ObjectIds.Server_ServerStatus_State)).set_value(0, ua.VariantType.Int32) Node(self.isession, ua.NodeId(ua.ObjectIds.Server_ServerStatus_StartTime)).set_value(datetime.utcnow()) if not self.disabled_clock: self._set_current_time()