Commit f2ed26c6 authored by olivier R-D's avatar olivier R-D

support deleting all nodes on server side. Needed by opcua-modeler

parent 7e9f42f2
......@@ -473,6 +473,13 @@ class AddressSpace(object):
with self._lock:
return self._nodes.keys()
def empty(self):
"""
Delete all nodes in address space
"""
with self._lock:
self._nodes = {}
def dump(self, path):
"""
dump address space as binary to file
......
......@@ -64,18 +64,7 @@ class InternalServer(object):
self.method_service = MethodService(self.aspace)
self.node_mgt_service = NodeManagementService(self.aspace)
if cacheFile and path.isfile(cacheFile):
# import address space from shelve
self.aspace.load(cacheFile)
else:
# import address space from code generated from xml
standard_address_space.fill_address_space(self.node_mgt_service)
# import address space directly from xml, this has preformance impact so disabled
# importer = xmlimporter.XmlImporter(self.node_mgt_service)
# importer.import_xml("/path/to/python-opcua/schemas/Opc.Ua.NodeSet2.xml", self)
if cacheFile:
self.aspace.dump(cacheFile)
self.load_standard_address_space(cacheFile)
self.loop = utils.ThreadLoop()
self.asyncio_transports = []
......@@ -85,15 +74,39 @@ class InternalServer(object):
# 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.setup_nodes()
def setup_nodes(self):
"""
Set up some nodes as defined by spec
"""
uries = ["http://opcfoundation.org/UA/"]
ns_node = Node(self.isession, ua.NodeId(ua.ObjectIds.Server_NamespaceArray))
ns_node.set_value(uries)
def load_standard_address_space(self, cacheFile=None):
if cacheFile and path.isfile(cacheFile):
# import address space from shelve
self.aspace.load(cacheFile)
else:
# import address space from code generated from xml
standard_address_space.fill_address_space(self.node_mgt_service)
# import address space directly from xml, this has preformance impact so disabled
# importer = xmlimporter.XmlImporter(self.node_mgt_service)
# importer.import_xml("/path/to/python-opcua/schemas/Opc.Ua.NodeSet2.xml", self)
def load_address_space(self, path):
"""
Load address space frfrom path
"""
self.aspace.load(path)
def dump_address_space(self, path):
"""
Dump current address space to path
"""
self.aspace.dump(path)
def start(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment