Backported (parts of) 1b6331b6333a49286e273a49286e27 from service_call_implementation: Fix duplicate reference from parent to child being created by namespace generator.

This commit is contained in:
ichrispa 2015-07-07 15:16:43 +02:00
parent 50512f48fe
commit 232bb4ecf7

View File

@ -654,12 +654,21 @@ class opcua_node_t:
if parent[1].referenceType() != None:
code.append("// Referencing node found and declared as parent: " + str(parent[0].id()) + "/" + str(parent[0].__node_browseName__) + " using " + str(parent[1].referenceType().id()) + "/" + str(parent[1].referenceType().__node_browseName__))
code.append("UA_Server_addNode(server, (UA_Node*) " + self.getCodePrintableID() + ", " + codegen.getCreateExpandedNodeIDMacro(parent[0]) + ", " + codegen.getCreateNodeIDMacro(parent[1].referenceType()) + ");")
# Otherwise use the "Bootstrapping" method and we will get registered
# with other nodes later.
else:
code.append("// Parent node does not exist yet. This node will be bootstrapped and linked later.")
code.append("UA_NodeStore_insert(server->nodestore, (UA_Node*) " + self.getCodePrintableID() + ", UA_NULL);")
# Note: getFirstParentNode will return [parentNode, referenceToChild]
(parentNode, parentRef) = self.getFirstParentNode()
if not (parentNode in unPrintedNodes) and (parentNode != None):
if parentRef.referenceType() != None:
code.append("// Referencing node found and declared as parent: " + str(parentNode .id()) + "/" + str(parentNode .__node_browseName__) + " using " + str(parentRef.referenceType().id()) + "/" + str(parentRef.referenceType().__node_browseName__))
code.append("UA_Server_addNode(server, (UA_Node*) " + self.getCodePrintableID() + ", " + codegen.getCreateExpandedNodeIDMacro(parentNode ) + ", " + codegen.getCreateNodeIDMacro(parentRef.referenceType()) + ");")
# Parent to child reference is added by the server, do not reprint that reference
if parentRef in unPrintedReferences:
unPrintedReferences.remove(parentRef)
# Try to print all references to nodes that already exist
# Note: we know the reference types exist, because the namespace class made sure they were
# the first ones being printed