Forráskód Böngészése

NodesetCompiler: Ignore already loaded nodeset

Stefan Profanter 5 éve
szülő
commit
ebedd4d751

+ 2 - 4
tools/nodeset_compiler/nodeset.py

@@ -227,7 +227,6 @@ class NodeSet(object):
 
 
         # Extract the modelUri
-        modelUri = None
         try:
             modelTag = nodeset.getElementsByTagName("Models")[0].getElementsByTagName("Model")[0]
             modelUri = modelTag.attributes["ModelUri"].nodeValue
@@ -238,13 +237,12 @@ class NodeSet(object):
 
         # Create the namespace mapping
         orig_namespaces = extractNamespaces(xmlfile)  # List of namespaces used in the xml file
-        if modelUri is None and len(orig_namespaces) > 0:
-            modelUri = orig_namespaces[0]
+        if modelUri is None and len(orig_namespaces) > 1:
+            modelUri = orig_namespaces[1]
 
         if modelUri is None:
             raise Exception(self, self.originXML + " does not define the nodeset URI in Models/Model/ModelUri or NamespaceUris array.")
 
-
         for ns in orig_namespaces:
             self.addNamespace(ns)
         self.namespaceMapping[modelUri] = self.createNamespaceMapping(orig_namespaces)

+ 10 - 0
tools/nodeset_compiler/nodeset_compiler.py

@@ -122,6 +122,8 @@ else:
 # Parse the XML files
 ns = NodeSet()
 nsCount = 0
+loadedFiles = list()
+
 
 def getTypesArray(nsIdx):
     if nsIdx < len(args.typesArray):
@@ -130,10 +132,18 @@ def getTypesArray(nsIdx):
         return "UA_TYPES"
 
 for xmlfile in args.existing:
+    if xmlfile.name in loadedFiles:
+        logger.info("Skipping Nodeset since it is already loaded: {} ".format(xmlfile.name))
+        continue
+    loadedFiles.append(xmlfile.name)
     logger.info("Preprocessing (existing) " + str(xmlfile.name))
     ns.addNodeSet(xmlfile, True, typesArray=getTypesArray(nsCount))
     nsCount +=1
 for xmlfile in args.infiles:
+    if xmlfile.name in loadedFiles:
+        logger.info("Skipping Nodeset since it is already loaded: {} ".format(xmlfile.name))
+        continue
+    loadedFiles.append(xmlfile.name)
     logger.info("Preprocessing " + str(xmlfile.name))
     ns.addNodeSet(xmlfile, typesArray=getTypesArray(nsCount))
     nsCount +=1

+ 3 - 0
tools/schema/Opc.Ua.NodeSet2.PubSubMinimal.xml

@@ -1,5 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <UANodeSet xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" LastModified="2016-12-31T00:00:00Z" xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd">
+  <Models>
+    <Model ModelUri="http://opcfoundation.org/UA/" Version="1.04" PublicationDate="2016-12-31T00:00:00Z" />
+  </Models>
   <UAObjectType NodeId="i=15906" BrowseName="PubSubKeyServiceType">
     <DisplayName>PubSubKeyServiceType</DisplayName>
     <References>