Skip to content

Commit

Permalink
NodesetCompiler: Hide valueRank not supported warning
Browse files Browse the repository at this point in the history
The valueRank for data types is currently not used in the nodeset compiler
and thus we can hide the warning. The rest of the code still works.

This valueRank attribute should then later on be used when creating
data type definitions on the fly with fixed array size instead of malloc
arrays.
  • Loading branch information
Pro committed Nov 2, 2018
1 parent 5544ed1 commit 1920661
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
8 changes: 4 additions & 4 deletions tools/nodeset_compiler/backend_open62541_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def generateExtensionObjectSubtypeCode(node, parent, nodeset, recursionDepth=0,
for field in node.encodingRule:
ptrSym = ""
# If this is an Array, this is pointer to its contents with a AliasOfFieldSize entry
if field[2] != 0:
if field[2] != None and field[2] != 0 :
code.append(" UA_Int32 " + str(field[0]) + "Size;")
ptrSym = "*"
if len(field[1]) == 1:
Expand All @@ -211,7 +211,7 @@ def generateExtensionObjectSubtypeCode(node, parent, nodeset, recursionDepth=0,
logger.debug(
"Encoding of field " + subv.alias + " is " + str(subv.encodingRule) + "defined by " + str(encField))
# Check if this is an array
if encField[2] == 0:
if subv.valueRank is None or subv.valueRank == 0:
code.append(instanceName + "_struct." + subv.alias + " = " +
generateNodeValueCode(subv, instanceName, asIndirect=False, max_string_length=max_string_length) + ";")
else:
Expand Down Expand Up @@ -260,7 +260,7 @@ def generateExtensionObjectSubtypeCode(node, parent, nodeset, recursionDepth=0,
for subv in node.value:
encField = node.encodingRule[encFieldIdx]
encFieldIdx = encFieldIdx + 1
if encField[2] == 0:
if subv.valueRank is None or subv.valueRank == 0:
code.append(
"retVal |= UA_encodeBinary(&" + instanceName + "_struct." + subv.alias + ", " +
getTypesArrayForValue(nodeset, subv) + ", &pos" + instanceName + ", &end" + instanceName + ", NULL, NULL);")
Expand Down Expand Up @@ -516,7 +516,7 @@ def generateNodeCode_begin(node, nodeset, max_string_length, generate_ns0, paren
code.append("UA_NODEID_NULL,")
code.append("(const UA_NodeAttributes*)&attr, &UA_TYPES[UA_TYPES_{}ATTRIBUTES],NULL, NULL);".format(node.__class__.__name__.upper().replace("NODE" ,"")))
code.extend(codeCleanup)

return "\n".join(code)

def generateNodeCode_finish(node):
Expand Down
10 changes: 7 additions & 3 deletions tools/nodeset_compiler/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(self, xmlelement=None):
self.dataType = None
self.encodingRule = []
self.isInternal = False
self.valueRank = None
if xmlelement:
self.parseXML(xmlelement)

Expand Down Expand Up @@ -165,7 +166,7 @@ def parseXMLEncoding(self, xmlvalue, parentDataTypeNode, parent):
else:
self.value = [self.__parseXMLSingleValue(xmlvalue, parentDataTypeNode, parent)]

def __parseXMLSingleValue(self, xmlvalue, parentDataTypeNode, parent, alias=None, encodingPart=None):
def __parseXMLSingleValue(self, xmlvalue, parentDataTypeNode, parent, alias=None, encodingPart=None, valueRank=None):
# Parse an encoding list such as enc = [[Int32], ['Duration', ['DateTime']]],
# returning a possibly aliased variable or list of variables.
# Keep track of aliases, as ['Duration', ['Hawaii', ['UtcTime', ['DateTime']]]]
Expand Down Expand Up @@ -195,6 +196,7 @@ def __parseXMLSingleValue(self, xmlvalue, parentDataTypeNode, parent, alias=None
t = self.getTypeByString(enc[0], enc)
t.alias = alias
t.parseXML(xmlvalue)
t.valueRank = valueRank
return t
else:
if not valueIsInternalType(xmlvalue.localName):
Expand All @@ -207,7 +209,8 @@ def __parseXMLSingleValue(self, xmlvalue, parentDataTypeNode, parent, alias=None
else:
# 1: ['Alias', [...], n]
# Let the next elif handle this
return self.__parseXMLSingleValue(xmlvalue, parentDataTypeNode, parent, alias=alias, encodingPart=enc[0])
return self.__parseXMLSingleValue(xmlvalue, parentDataTypeNode, parent,
alias=alias, encodingPart=enc[0], valueRank=enc[2] if len(enc)>2 else None)
elif len(enc) == 3 and isinstance(enc[0], six.string_types):
# [ 'Alias', [...], 0 ] aliased multipart
if alias == None:
Expand All @@ -216,7 +219,8 @@ def __parseXMLSingleValue(self, xmlvalue, parentDataTypeNode, parent, alias=None
elif alias != None and len(enc[1]) > 1:
alias = enc[0]
# otherwise drop the alias
return self.__parseXMLSingleValue(xmlvalue, parentDataTypeNode, parent, alias=alias, encodingPart=enc[1])
return self.__parseXMLSingleValue(xmlvalue, parentDataTypeNode, parent,
alias=alias, encodingPart=enc[1], valueRank=enc[2] if len(enc)>2 else None)
else:
# [ [...], [...], [...]] multifield of unknowns (analyse separately)
# create an extension object to hold multipart type
Expand Down
7 changes: 2 additions & 5 deletions tools/nodeset_compiler/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def buildEncoding(self, nodeset, indent=0, force=False):
self.__encodable__ = False
break
else:
self.__baseTypeEncoding__ = self.__baseTypeEncoding__ + [self.browseName.name, subenc, 0]
self.__baseTypeEncoding__ = self.__baseTypeEncoding__ + [self.browseName.name, subenc, None]
if len(self.__baseTypeEncoding__) == 0:
logger.debug(prefix + "No viable definition for " + str(self.browseName) + " " + str(self.id) + " found.")
self.__encodable__ = False
Expand All @@ -520,7 +520,6 @@ def buildEncoding(self, nodeset, indent=0, force=False):

isEnum = True
isSubType = True
hasValueRank = 0

# We need to store the definition as ordered data, but can't use orderedDict
# for backward compatibility with Python 2.6 and 3.4
Expand All @@ -533,7 +532,7 @@ def buildEncoding(self, nodeset, indent=0, force=False):
fname = ""
fdtype = ""
enumVal = ""
valueRank = 0
valueRank = None
for at,av in x.attributes.items():
if at == "DataType":
fdtype = str(av)
Expand All @@ -547,8 +546,6 @@ def buildEncoding(self, nodeset, indent=0, force=False):
isSubType = False
elif at == "ValueRank":
valueRank = int(av)
if valueRank > 0:
logger.warn("Value ranks >0 not fully supported. Further steps may fail")
else:
logger.warn("Unknown Field Attribute " + str(at))
# This can either be an enumeration OR a structure, not both.
Expand Down

0 comments on commit 1920661

Please sign in to comment.