OPCUS client: fix handling of string type Node Identifier wxPython4
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Mon, 18 Oct 2021 20:41:31 +0200
branchwxPython4
changeset 3338 fe0da9a8a225
parent 3337 6097bca230e8
child 3339 057b4ba30c35
OPCUS client: fix handling of string type Node Identifier
opc_ua/opcua_client_maker.py
--- a/opc_ua/opcua_client_maker.py	Mon Oct 18 12:40:53 2021 +0200
+++ b/opc_ua/opcua_client_maker.py	Mon Oct 18 20:41:31 2021 +0200
@@ -27,9 +27,9 @@
 )
 
 UA_NODE_ID_types = {
-    "int"   : "UA_NODEID_NUMERIC",
-    "string": "UA_NODEID_STRING",
-    "UUIS"  : "UA_NODEID_UUID",
+    "int"   : ("UA_NODEID_NUMERIC", "{}"  ),
+    "str"   : ("UA_NODEID_STRING" , '"{}"'),
+    "UUIS"  : ("UA_NODEID_UUID"   , '"{}"'),
 }
 
 lstcolnames  = [  "Name", "NSIdx", "IdType", "Id", "Type", "IEC"]
@@ -550,10 +550,11 @@
         for direction, data in self.iteritems():
             iec_direction_prefix = {"input": "__I", "output": "__Q"}[direction]
             for row in data:
-                name, ua_nsidx, ua_nodeid_type, ua_node_id, ua_type, iec_number = row
+                name, ua_nsidx, ua_nodeid_type, _ua_node_id, ua_type, iec_number = row
                 iec_type, C_type, iec_size_prefix, ua_type_enum, ua_type = UA_IEC_types[ua_type]
                 c_loc_name = iec_direction_prefix + iec_size_prefix + locstr + "_" + str(iec_number)
-                ua_nodeid_type = UA_NODE_ID_types[ua_nodeid_type]
+                ua_nodeid_type, id_formating = UA_NODE_ID_types[ua_nodeid_type]
+                ua_node_id = id_formating.format(_ua_node_id)
 
                 formatdict["decl"] += """
 DECL_VAR({ua_type}, {C_type}, {c_loc_name})""".format(**locals())