Selaa lähdekoodia

fixes #718 by removing automatically generated HasTypeReference references

Stasik0 8 vuotta sitten
vanhempi
commit
b9ff003f00
1 muutettua tiedostoa jossa 9 lisäystä ja 1 poistoa
  1. 9 1
      tools/pyUANamespace/open62541_MacroHelper.py

+ 9 - 1
tools/pyUANamespace/open62541_MacroHelper.py

@@ -210,7 +210,7 @@ class open62541_MacroHelper():
 
     code.append("UA_NodeId nodeId = " + str(self.getCreateNodeIDMacro(node)) + ";")
     if nodetype in ["Object", "Variable"]:
-      code.append("UA_NodeId typeDefinition = UA_NODEID_NULL;") # todo instantiation of object and variable types
+      code.append("UA_NodeId typeDefinition = UA_NODEID_NULL;") #due to the current API we cannot set types here since the API will generate nodes with random IDs
     code.append("UA_NodeId parentNodeId = " + str(self.getCreateNodeIDMacro(parentNode)) + ";")
     code.append("UA_NodeId parentReferenceNodeId = " + str(self.getCreateNodeIDMacro(parentReference.referenceType())) + ";")
     extrNs = node.browseName().split(":")
@@ -229,6 +229,14 @@ class open62541_MacroHelper():
       code.append("       , attr, NULL, NULL);")
     else:
       code.append("       , attr, (UA_MethodCallback) NULL, NULL, " + str(len(inArgVal)) + ", inputArguments,  " + str(len(outArgVal)) + ", outputArguments, NULL);")
+      
+    #Adding a Node with typeDefinition = UA_NODEID_NULL will create a HasTypeDefinition reference to BaseDataType - remove it since 
+    #a real Reference will be add in a later step (a single HasTypeDefinition reference is assumed here)
+    #The current API does not let us specify IDs of Object's subelements.
+    if nodetype is "Object":
+      code.append("UA_Server_deleteReference(server, nodeId, UA_NODEID_NUMERIC(0, 40), true, UA_EXPANDEDNODEID_NUMERIC(0, 58), true); //remove HasTypeDefinition refs generated by addObjectNode");
+    if nodetype is "Variable":
+      code.append("UA_Server_deleteReference(server, nodeId, UA_NODEID_NUMERIC(0, 40), true, UA_EXPANDEDNODEID_NUMERIC(0, 62), true); //remove HasTypeDefinition refs generated by addVariableNode");
     return code
 
   def getCreateNodeBootstrap(self, node):