Fixing networkedit to deal with non-null master nodeid
authorLaurent Bessard
Mon, 01 Oct 2012 19:18:35 +0200
changeset 748 18ed0f3b030a
parent 747 4725d8f909ff
child 754 4715f4ed8e0c
Fixing networkedit to deal with non-null master nodeid
objdictgen/commondialogs.py
objdictgen/networkedit.py
objdictgen/nodelist.py
objdictgen/subindextable.py
--- a/objdictgen/commondialogs.py	Thu Sep 06 16:49:11 2012 +0200
+++ b/objdictgen/commondialogs.py	Mon Oct 01 19:18:35 2012 +0200
@@ -1228,7 +1228,7 @@
                 message = wx.MessageDialog(self, _("Slave Node ID must be between 0 and 127!"), _("Error"), wx.OK|wx.ICON_ERROR)
                 message.ShowModal()
                 message.Destroy()
-            elif nodeid == 0 or nodeid in self.NodeList.SlaveNodes.keys():
+            elif nodeid == self.NodeList.GetMasterNodeID() or nodeid in self.NodeList.GetSlaveIDs():
                 message = wx.MessageDialog(self, _("A Node with this ID already exist in the network!"), _("Error"), wx.OK|wx.ICON_ERROR)
                 message.ShowModal()
                 message.Destroy()
--- a/objdictgen/networkedit.py	Thu Sep 06 16:49:11 2012 +0200
+++ b/objdictgen/networkedit.py	Mon Oct 01 19:18:35 2012 +0200
@@ -198,15 +198,13 @@
             self.NetworkNodes.DeleteAllPages()
         if self.NodeList:
             new_editingpanel = EditingPanel(self.NetworkNodes, self, self.Manager)
-            new_editingpanel.SetIndex(0)
+            new_editingpanel.SetIndex(self.Manager.GetCurrentNodeID())
             self.NetworkNodes.AddPage(new_editingpanel, "")
             for idx in self.NodeList.GetSlaveIDs():
                 new_editingpanel = EditingPanel(self.NetworkNodes, self, self.NodeList, False)
                 new_editingpanel.SetIndex(idx)
                 self.NetworkNodes.AddPage(new_editingpanel, "")
     
-    
-    
     def OnNodeSelectedChanged(self, event):
         if not self.Closing:
             selected = event.GetSelection()
--- a/objdictgen/nodelist.py	Thu Sep 06 16:49:11 2012 +0200
+++ b/objdictgen/nodelist.py	Mon Oct 01 19:18:35 2012 +0200
@@ -71,6 +71,9 @@
         self.Root = newrootpath
         self.Manager.SetCurrentFilePath(os.path.join(self.Root, "master.od"))
     
+    def GetMasterNodeID(self):
+        return self.Manager.GetCurrentNodeID()
+    
     def GetSlaveNumber(self):
         return len(self.SlaveNodes)
     
--- a/objdictgen/subindextable.py	Thu Sep 06 16:49:11 2012 +0200
+++ b/objdictgen/subindextable.py	Mon Oct 01 19:18:35 2012 +0200
@@ -550,7 +550,7 @@
                         typeinfos = self.Manager.GetEntryInfos(subentry_infos["type"])
                         if typeinfos:
                             bus_id = '.'.join(map(str, self.ParentWindow.GetBusId()))
-                            var_name = "master_%04x_%02x" % (index, subindex)
+                            var_name = "%s_%04x_%02x" % (self.Manager.GetCurrentNodeName(), index, subindex)
                             size = typeinfos["size"]
                             data = wx.TextDataObject(str(
                                 ("%s%s.%d.%d"%(SizeConversion[size], bus_id, index, subindex),