]> rtime.felk.cvut.cz Git - CanFestival-3.git/commitdiff
Some bugs fixed
authorlbessard <lbessard>
Wed, 12 Sep 2007 15:18:43 +0000 (15:18 +0000)
committerlbessard <lbessard>
Wed, 12 Sep 2007 15:18:43 +0000 (15:18 +0000)
Improved node print method

objdictgen/networkedit.py
objdictgen/node.py
objdictgen/nodelist.py
objdictgen/objdictedit.py
objdictgen/subindextable.py

index 09e16d391ce6c264a2fe4714d0a5d364bdbb4bb3..9ca47cd57a43cd0d386a844427ab26e283b3fc18 100644 (file)
@@ -27,7 +27,7 @@ import wx.grid
 from types import *
 import os, re, platform, sys, time, traceback, getopt
 
-__version__ = "$Revision: 1.9 $"
+__version__ = "$Revision: 1.10 $"
 
 from nodelist import *
 from nodemanager import *
@@ -100,7 +100,7 @@ try:
             wx.Frame.__init__(self, id=ID_HTMLFRAME, name='HtmlFrame',
                   parent=prnt, pos=wx.Point(320, 231), size=wx.Size(853, 616),
                   style=wx.DEFAULT_FRAME_STYLE, title='')
-            self.Bind(wx.EVT_CLOSE, self.OnCloseFrame, id=ID_HTMLFRAME)
+            self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
             
             self.HtmlContent = UrlClickHtmlWindow(id=ID_HTMLFRAMEHTMLCONTENT,
                   name='HtmlContent', parent=self, pos=wx.Point(0, 0),
@@ -319,7 +319,7 @@ class networkedit(wx.Frame):
         self._init_utils()
         self.SetClientSize(wx.Size(1000, 700))
         self.SetMenuBar(self.menuBar1)
-        self.Bind(wx.EVT_CLOSE, self.OnCloseFrame, id=ID_NETWORKEDIT)
+        self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
         if not self.ModeSolo:
             self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=ID_NETWORKEDITFILEMENUITEMS1)
             accel = wx.AcceleratorTable([wx.AcceleratorEntry(wx.ACCEL_CTRL, 83, ID_NETWORKEDITFILEMENUITEMS1)])
@@ -701,6 +701,14 @@ class networkedit(wx.Frame):
                     edititem.SetText("Other Profile")
                     edititem.Enable(False)
 
+    def GetProfileCallBack(self, text):
+        def ProfileCallBack(event):
+            self.Manager.AddSpecificEntryToCurrent(text)
+            self.RefreshBufferState()
+            self.RefreshCurrentIndexList()
+            event.Skip()
+        return ProfileCallBack
+
 #-------------------------------------------------------------------------------
 #                              Buffer Functions
 #-------------------------------------------------------------------------------
@@ -810,7 +818,6 @@ class networkedit(wx.Frame):
                 if index not in new_profile:
                     removinglist.append(index)
             self.Manager.ManageEntriesOfCurrent(addinglist, removinglist)
-            self.Manager.GenerateMapList()
             self.Manager.BufferCurrentNode()
             self.RefreshBufferState()
             self.RefreshCurrentIndexList()
index 777fb91e43fb0de43ca8abf73a6af2c8b6279284..c674acbc825649e83cdd41ac659320594275ef4a 100755 (executable)
@@ -202,7 +202,7 @@ MappingDictionary = {
                 [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
                  {"name" : "COB ID Client to Server (Transmit SDO)", "type" : 0x07, "access" : 'rw', "pdo" : False},
                  {"name" : "COB ID Server to Client (Receive SDO)", "type" : 0x07, "access" : 'rw', "pdo" : False},
-                 {"name" : "Node ID of the SDO Server", "type" : 0x04, "access" : 'rw', "pdo" : False}]},
+                 {"name" : "Node ID of the SDO Server", "type" : 0x05, "access" : 'rw', "pdo" : False}]},
     0x1400 : {"name" : "Receive PDO %d Parameter[(idx)]", "struct" : pluriarray, "incr" : 1, "nbmax" : 0x200, "need" : False, "values" :
                 [{"name" : "Highest SubIndex Supported", "type" : 0x05, "access" : 'ro', "pdo" : False},
                  {"name" : "COB ID used by PDO", "type" : 0x07, "access" : 'rw', "pdo" : False, "default" : "{True:self.ID+(base+2)*0x100,False:0}[base<4]"},
@@ -815,18 +815,39 @@ class Node:
     Print the Dictionary values
     """
     def Print(self):
+        print self.PrintString()
+    
+    def PrintString(self):
+        result = ""
         listindex = self.Dictionary.keys()
         listindex.sort()
         for index in listindex:
+            name = self.GetEntryName(index)
             values = self.Dictionary[index]
-            if index != 0x1F22 and type(values) != IntType:
-                values = [i for i in values]
-                for i, value in enumerate(values):
-                    if type(value) == IntType:
-                        values[i] = "%X"%value
-                values = "[" + ",".join(values) + "]"
-            print "%04X : %s"%(index, values)
-
+            if isinstance(values, ListType):
+                result += "%04X (%s):\n"%(index, name)
+                for subidx, value in enumerate(values):
+                    subentry_infos = self.GetSubentryInfos(index, subidx + 1)
+                    if index == 0x1F22 and value:
+                        nb_params = BE_to_LE(value[:4])
+                        data = value[4:]
+                        value = str(nb_params)
+                        i = 0
+                        while i < len(data):
+                            value += "\n\t"
+                            value += "%4.4X"%BE_to_LE(data[i:i+2])
+                            value += " %2.2X"%BE_to_LE(data[i+2:i+3])
+                            size = BE_to_LE(data[i+3:i+7])
+                            value += " %8.8X"%size
+                            value += (" %"+"%d"%(size * 2)+"."+"%d"%(size * 2)+"X")%BE_to_LE(data[i+7:i+7+size])
+                            i += 7 + size
+                    elif isinstance(value, IntType):
+                        value = "%X"%value
+                    result += "  %3.3d (%s): %s\n"%(subidx+1, subentry_infos["name"], value)
+            else:
+                result += "%04X (%s): %s\n"%(index, name, values)
+        return result
+            
     def CompileValue(self, value, index):
         if type(value) == StringType and value.find("self.ID") != -1:
             base = self.GetBaseIndex(index)
@@ -996,3 +1017,16 @@ class Node:
     def GetMapList(self):
         list = ["None"] + [name for index, subIndex, size, name in self.GetMapVariableList()]
         return ",".join(list)
+
+def BE_to_LE(value):
+    """
+    Convert Big Endian to Little Endian 
+    @param value: value expressed in Big Endian
+    @param size: number of bytes generated
+    @return: a string containing the value converted
+    """
+    
+    data = [char for char in value]
+    data.reverse()
+    return int("".join(["%2.2X"%ord(char) for char in data]), 16)
+    
\ No newline at end of file
index 6028e4d7426058c33b6afd53ff95fd37d44d3ac4..e21d38f4f9c8343e6c9e793a4dc1a4d206542fd1 100644 (file)
@@ -250,7 +250,6 @@ class NodeList:
         if order > 0:
             nodeindexes = self.SlaveNodes.keys()
             nodeindexes.sort()
-            print nodeindexes
             if order <= len(nodeindexes):
                 return self.SlaveNodes[nodeindexes[order - 1]]["Node"]
         return None
@@ -262,6 +261,7 @@ class NodeList:
             else:
                 node = self.SlaveNodes[self.CurrentSelected]["Node"]
                 if node:
+                    node.SetNodeID(self.CurrentSelected)
                     return node.IsEntry(index)
         return False
     
@@ -272,6 +272,7 @@ class NodeList:
             else:
                 node = self.SlaveNodes[self.CurrentSelected]["Node"]
                 if node:
+                    node.SetNodeID(self.CurrentSelected)
                     return node.GetEntryInfos(index)
         return None
 
@@ -282,6 +283,7 @@ class NodeList:
             else:
                 node = self.SlaveNodes[self.CurrentSelected]["Node"]
                 if node:
+                    node.SetNodeID(self.CurrentSelected)
                     return node.GetSubentryInfos(index, subindex)
         return None
 
@@ -292,6 +294,7 @@ class NodeList:
             else:
                 node = self.SlaveNodes[self.CurrentSelected]["Node"]
                 if node:
+                    node.SetNodeID(self.CurrentSelected)
                     validindexes = []
                     for index in node.GetIndexes():
                         if min <= index <= max:
@@ -305,6 +308,7 @@ class NodeList:
         if self.CurrentSelected != None:
             node = self.SlaveNodes[self.CurrentSelected]["Node"]
             if node:
+                node.SetNodeID(self.CurrentSelected)
                 return self.Manager.GetNodeEntryValues(node, index)
             else:
                 print "Can't find node"
index 94ebd69a7d42123b67d73e644d71d74df40d54bf..f9e44b3db51afe601ffb819ee0ba649510a9b7e5 100755 (executable)
@@ -26,7 +26,7 @@ import wx
 from types import *
 import os, re, platform, sys, time, traceback, getopt
 
-__version__ = "$Revision: 1.27 $"
+__version__ = "$Revision: 1.28 $"
 
 from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes
 
@@ -71,7 +71,7 @@ try:
             wx.Frame.__init__(self, id=ID_HTMLFRAME, name='HtmlFrame',
                   parent=prnt, pos=wx.Point(320, 231), size=wx.Size(853, 616),
                   style=wx.DEFAULT_FRAME_STYLE, title='')
-            self.Bind(wx.EVT_CLOSE, self.OnCloseFrame, id=ID_HTMLFRAME)
+            self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
             
             self.HtmlContent = UrlClickHtmlWindow(id=ID_HTMLFRAMEHTMLCONTENT,
                   name='HtmlContent', parent=self, pos=wx.Point(0, 0),
@@ -305,7 +305,7 @@ class objdictedit(wx.Frame):
         self._init_utils()
         self.SetClientSize(wx.Size(1000, 700))
         self.SetMenuBar(self.menuBar1)
-        self.Bind(wx.EVT_CLOSE, self.OnCloseFrame, id=ID_OBJDICTEDIT)
+        self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
 
         self.FileOpened = wx.Notebook(id=ID_OBJDICTEDITFILEOPENED,
               name='FileOpened', parent=self, pos=wx.Point(0, 0),
index c664dcd153bbe3bdde44cff68feaee695262cb2f..d70bc4ff827960a9828a143f37516cf3f3dc4f72 100644 (file)
@@ -612,7 +612,7 @@ class EditingPanel(wx.SplitterWindow):
                         self.IndexListMenu.FindItemByPosition(0).Enable(False)
                         self.IndexListMenu.FindItemByPosition(1).Enable(True)
                         self.PopupMenu(self.IndexListMenu)
-                    elif 0x1000 <= index <= 0x1BFF:
+                    elif 0x1000 <= index <= 0x1FFF:
                         self.IndexListMenu.FindItemByPosition(0).Enable(False)
                         self.IndexListMenu.FindItemByPosition(1).Enable(False)
                         self.PopupMenu(self.IndexListMenu)