Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
authorLaurent Bessard
Thu, 06 Sep 2012 16:49:11 +0200
changeset 747 4725d8f909ff
parent 746 3e16d9a121b8
child 748 18ed0f3b030a
child 749 5cbb8e9ad67c
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
objdictgen/subindextable.py
--- a/objdictgen/subindextable.py	Tue Jun 19 10:29:03 2012 +0200
+++ b/objdictgen/subindextable.py	Thu Sep 06 16:49:11 2012 +0200
@@ -94,6 +94,31 @@
     {"minIndex" : 0x6000, "maxIndex" : 0x9FFF, "name" : "Standardized Device Profile"},
     {"minIndex" : 0xA000, "maxIndex" : 0xBFFF, "name" : "Standardized Interface Profile"}]
 
+IECTypeConversion = {
+    "BOOLEAN": "BOOL",
+    "INTEGER8": "SINT",
+    "INTEGER16": "INT",
+    "INTEGER32": "DINT",
+    "UNSIGNED8": "USINT",
+    "UNSIGNED16": "UINT",
+    "UNSIGNED32": "UDINT",
+    "REAL32": "REAL",
+    "VISIBLE_STRING": "STRING",
+    "OCTET_STRING": "STRING",
+    "UNICODE_STRING": "WSTRING",
+    "DOMAIN": "STRING",
+    "INTEGER24": "DINT",
+    "REAL64": "LREAL",
+    "INTEGER40": "LINT",
+    "INTEGER48": "LINT",
+    "INTEGER56": "LINT",
+    "INTEGER64": "LINT",
+    "UNSIGNED24": "UDINT",
+    "UNSIGNED40": "ULINT",
+    "UNSIGNED48": "ULINT",
+    "UNSIGNED56": "ULINT",
+    "UNSIGNED64": "ULINT",
+}
 SizeConversion = {1 : "X", 8 : "B", 16 : "W", 24 : "D", 32 : "D", 40 : "L", 48 : "L", 56 : "L", 64 : "L"}
 
 class SubindexTable(wx.grid.PyGridTableBase):
@@ -527,7 +552,11 @@
                             bus_id = '.'.join(map(str, self.ParentWindow.GetBusId()))
                             var_name = "master_%04x_%02x" % (index, subindex)
                             size = typeinfos["size"]
-                            data = wx.TextDataObject(str(("%s%s.%d.%d"%(SizeConversion[size], bus_id, index, subindex), "location", None, var_name, "")))
+                            data = wx.TextDataObject(str(
+                                ("%s%s.%d.%d"%(SizeConversion[size], bus_id, index, subindex), 
+                                 "location", 
+                                 IECTypeConversion.get(typeinfos["name"]), 
+                                 var_name, "")))
                             dragSource = wx.DropSource(self.SubindexGrid)
                             dragSource.SetData(data)
                             dragSource.DoDragDrop()
@@ -545,7 +574,11 @@
                             node_id = self.ParentWindow.GetCurrentNodeId()
                             var_name = "%s_%04x_%02x" % (self.Manager.GetSlaveName(node_id), index, subindex)
                             size = typeinfos["size"]
-                            data = wx.TextDataObject(str(("%s%s.%d.%d.%d"%(SizeConversion[size], bus_id, node_id, index, subindex), "location", None, var_name, "")))
+                            data = wx.TextDataObject(str(
+                                ("%s%s.%d.%d.%d"%(SizeConversion[size], bus_id, node_id, index, subindex), 
+                                 "location", 
+                                 IECTypeConversion.get(typeinfos["name"]), 
+                                 var_name, "")))
                             dragSource = wx.DropSource(self.SubindexGrid)
                             dragSource.SetData(data)
                             dragSource.DoDragDrop()