Bug on map variable type changing and on comments with special characters corrected
authorlbessard
Wed, 03 Jan 2007 10:33:55 +0100
changeset 63 2be18e405e40
parent 62 93d4db3677e6
child 64 c72dd78e547f
Bug on map variable type changing and on comments with special characters corrected
objdictgen/gen_cfile.py
objdictgen/node.py
objdictgen/nodemanager.py
objdictgen/objdictedit.py
--- a/objdictgen/gen_cfile.py	Tue Jan 02 15:10:38 2007 +0100
+++ b/objdictgen/gen_cfile.py	Wed Jan 03 10:33:55 2007 +0100
@@ -466,6 +466,10 @@
     HeaderFileContent = copyright_notice + generated_tag + """
 #include "data.h"
 
+// prototypes of function provided by object dictionnary
+UNS32 %(NodeName)s_valueRangeTest (UNS8 typeValue, void * value);
+const indextable * %(NodeName)s_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks);
+
 // prototypes of function to be filled by app
 void %(NodeName)s_SDOtimeoutError(UNS8 line);
 void %(NodeName)s_heartbeatError(UNS8);
--- a/objdictgen/node.py	Tue Jan 02 15:10:38 2007 +0100
+++ b/objdictgen/node.py	Wed Jan 03 10:33:55 2007 +0100
@@ -582,6 +582,18 @@
                     if (value & mask) == model:
                         self.Dictionary[i][j] = 0
     
+    def UpdateMapVariable(self, index, subIndex, size):
+        model = index << 16
+        mask = 0xFFFF << 16
+        if subIndex:
+            model += subIndex << 8
+            mask = 0xFF << 8
+        for i in self.Dictionary.iterkeys():
+            if 0x1600 <= i <= 0x17FF or 0x1A00 <= i <= 0x1BFF:
+                for j,value in enumerate(self.Dictionary[i]):
+                    if (value & mask) == model:
+                        self.Dictionary[i][j] = model + size
+    
     def RemoveLine(self, index, max, incr = 1):
         i = index
         while i < max and self.IsEntry(i + incr):
--- a/objdictgen/nodemanager.py	Tue Jan 02 15:10:38 2007 +0100
+++ b/objdictgen/nodemanager.py	Wed Jan 03 10:33:55 2007 +0100
@@ -804,13 +804,15 @@
             else:
                 if editor == "type":
                     value = self.TypeTranslation[value]
+                    size = self.GetEntryInfos(value)["size"]
+                    self.CurrentNode.UpdateMapVariable(index, subIndex, size)
                 elif editor == "access":
                     dic = {}
                     for abbrev,access in AccessType.iteritems():
                         dic[access] = abbrev
                     value = dic[value]
                 self.CurrentNode.SetMappingEntry(index, subIndex, values = {name : value})
-                if name == "name":
+                if name == "name" or editor == "type":
                     self.GenerateMapList()
             self.BufferCurrentNode()
 
--- a/objdictgen/objdictedit.py	Tue Jan 02 15:10:38 2007 +0100
+++ b/objdictgen/objdictedit.py	Wed Jan 03 10:33:55 2007 +0100
@@ -131,8 +131,11 @@
 
     def GetValue(self, row, col):
         if row < self.GetNumberRows():
-            name = str(self.data[row].get(self.GetColLabelValue(col), ""))
-            return name
+            value = self.data[row].get(self.GetColLabelValue(col), "")
+            if (type(value) == UnicodeType):
+                return value
+            else: 
+                return str(value)
     
     def GetEditor(self, row, col):
         if row < self.GetNumberRows():