Bladeren bron

fix: Nodeset compiler correctly parse default field datatype

Stefan Profanter 4 jaren geleden
bovenliggende
commit
9bdd6c3f74
2 gewijzigde bestanden met toevoegingen van 4 en 13 verwijderingen
  1. 4 11
      tools/nodeset_compiler/nodes.py
  2. 0 2
      tools/nodeset_compiler/nodeset.py

+ 4 - 11
tools/nodeset_compiler/nodes.py

@@ -522,8 +522,7 @@ class DataTypeNode(Node):
 
             return self.__baseTypeEncoding__
 
-        isEnum = True
-        isSubType = True
+        isEnum = False
         # An option set is at the same time also an enum, at least for the encoding below
         isOptionSet = parentType is not None and parentType.id.ns == 0 and parentType.id.i==12755
 
@@ -545,26 +544,20 @@ class DataTypeNode(Node):
                         fdtype = str(av)
                         if fdtype in nodeset.aliases:
                             fdtype = nodeset.aliases[fdtype]
-                        isEnum = False
                     elif at == "Name":
                         fname = str(av)
                     #elif at == "SymbolicName":
                     #    symbolicName = str(av)
                     elif at == "Value":
                         enumVal = int(av)
-                        isSubType = False
+                        isEnum = True
                     elif at == "ValueRank":
                         valueRank = int(av)
                     else:
                         logger.warn("Unknown Field Attribute " + str(at))
                 # This can either be an enumeration OR a structure, not both.
                 # Figure out which of the dictionaries gets the newly read value pair
-                if isEnum == isSubType:
-                    # This is an error
-                    logger.warn("DataType contains both enumeration and subtype (or neither)")
-                    self.__encodable__ = False
-                    break
-                elif isEnum:
+                if isEnum:
                     # This is an enumeration
                     enumDict.append((fname, enumVal))
                     continue
@@ -588,7 +581,7 @@ class DataTypeNode(Node):
                     subenc = dtnode.buildEncoding(nodeset=nodeset, indent=indent+1)
                     self.__baseTypeEncoding__ = self.__baseTypeEncoding__ + [[fname, subenc, valueRank]]
                     if not dtnode.isEncodable():
-                        # If we inherit an encoding from an unencodable not, this node is
+                        # If we inherit an encoding from an unencodable node, this node is
                         # also not encodable
                         self.__encodable__ = False
                         break

+ 0 - 2
tools/nodeset_compiler/nodeset.py

@@ -337,8 +337,6 @@ class NodeSet(object):
             if not isinstance(dataTypeNode, DataTypeNode):
                 logger.error("Node id " + str(dataType) + " is not reference a valid dataType.")
                 return None
-            if not dataTypeNode.isEncodable():
-                logger.warn("DataType " + str(dataTypeNode.browseName) + " is not encodable.")
             return dataTypeNode
         return None