Adding index in PDO mapping names for differenciate mapped variables when they have the same name
authorlbessard
Thu, 12 Mar 2009 16:01:47 +0100
changeset 536 00935990f087
parent 535 69c25c60df5d
child 537 9abbda25a18b
Adding index in PDO mapping names for differenciate mapped variables when they have the same name
objdictgen/node.py
--- a/objdictgen/node.py	Thu Mar 12 15:58:46 2009 +0100
+++ b/objdictgen/node.py	Thu Mar 12 16:01:47 2009 +0100
@@ -1071,6 +1071,9 @@
         list.sort()
         return ",".join(list)
 
+    def GenerateMapName(self, name, index, subindex):
+        return "%s (0x%4.4X)" % (name, index)
+
     """
     Generate the list of variables that can be mapped for the current node
     """
@@ -1082,8 +1085,9 @@
         for index, subIndex, size, name in list:
             self.MapList += ",%s"%name
             map = "%04X%02X%02X"%(index,subIndex,size)
-            self.NameTranslation[name] = map
-            self.MapTranslation[map] = name
+            mapname = self.GenerateMapName(name, index, subIndex)
+            self.NameTranslation[mapname] = map
+            self.MapTranslation[map] = mapname
 
     def GetMapValue(self, mapname):
         if mapname == "None":
@@ -1091,7 +1095,7 @@
         else:
             list = self.GetMapVariableList()
             for index, subIndex, size, name in list:
-                if mapname == name:
+                if mapname == self.GenerateMapName(name, index, subIndex):
                     return (index << 16) + (subIndex << 8) + size
             return None
     
@@ -1101,14 +1105,14 @@
             subindex = (value >> 8) % (1 << 8)
             result = self.GetSubentryInfos(index, subindex)
             if result:
-                return result["name"]
+                return self.GenerateMapName(result["name"], index, subindex)
         return "None"
     
     """
     Return the list of variables that can be mapped for the current node
     """
     def GetMapList(self):
-        list = ["None"] + [name for index, subIndex, size, name in self.GetMapVariableList()]
+        list = ["None"] + [self.GenerateMapName(name, index, subIndex) for index, subIndex, size, name in self.GetMapVariableList()]
         return ",".join(list)
 
 def BE_to_LE(value):