Merge with Edouard's Modifications
authorlaurent
Wed, 15 Feb 2012 00:44:24 +0100
changeset 684 d376a8b0b602
parent 681 383864958dac (current diff)
parent 683 57aa9da845d5 (diff)
child 685 2db8b87016a0
Merge with Edouard's Modifications
LPCBeremiz.py
plugins/canfestival/canfestival.py
--- a/Beremiz.py	Tue Feb 14 12:20:19 2012 +0100
+++ b/Beremiz.py	Wed Feb 15 00:44:24 2012 +0100
@@ -880,7 +880,7 @@
                 msizer.AddWindow(button, 0, border=0, flag=wx.ALIGN_CENTER)
         return msizer
 
-    def GenerateParamsPanel(self, plugin, bkgdclr):
+    def GenerateParamsPanel(self, plugin, bkgdclr, top_offset=0):
         rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
         rightwindow.SetBackgroundColour(bkgdclr)
         
@@ -893,7 +893,7 @@
         rightwindowmainsizer.AddSizer(rightwindowsizer, 0, border=0, flag=wx.GROW)
         
         msizer = self.GenerateMethodButtonSizer(plugin, rightwindow, not self.PluginInfos[plugin]["right_visible"])
-        rightwindowsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW)
+        rightwindowsizer.AddSizer(msizer, 0, border=top_offset, flag=wx.TOP|wx.GROW)
         
         rightparamssizer = wx.BoxSizer(wx.HORIZONTAL)
         rightwindowsizer.AddSizer(rightparamssizer, 0, border=0, flag=wx.ALIGN_RIGHT)
@@ -1168,8 +1168,8 @@
         tc.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(tc, plugin, "BaseParams.Name"), id=tc_id)
         iecsizer.AddWindow(tc, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
         
-        rightwindow = self.GenerateParamsPanel(plugin, bkgdclr)
-        self.PluginTreeSizer.AddWindow(rightwindow, 0, border=8, flag=wx.TOP|wx.GROW)
+        rightwindow = self.GenerateParamsPanel(plugin, bkgdclr, 8)
+        self.PluginTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW)
         
         self.PluginInfos[plugin]["left"] = leftwindow
         self.PluginInfos[plugin]["right"] = rightwindow
--- a/plugger.py	Tue Feb 14 12:20:19 2012 +0100
+++ b/plugger.py	Wed Feb 15 00:44:24 2012 +0100
@@ -466,6 +466,14 @@
             self.GetPlugRoot().logger.write_warning(_("A child names \"%s\" already exist -> \"%s\"\n")%(DesiredName,res))
         return res
 
+    def GetAllChannels(self):
+        AllChannels=[]
+        for PlugInstance in self.PlugParent.IterChilds():
+            if PlugInstance != self:
+                AllChannels.append(PlugInstance.BaseParams.getIEC_Channel())
+        AllChannels.sort()
+        return AllChannels
+
     def FindNewIEC_Channel(self, DesiredChannel):
         """
         Changes IEC Channel number to DesiredChannel if available, nearest available if not.
@@ -476,12 +484,8 @@
         # Do nothing if no change
         #if CurrentChannel == DesiredChannel: return CurrentChannel
         # Build a list of used Channels out of parent's PluggedChilds
-        AllChannels=[]
-        for PlugInstance in self.PlugParent.IterChilds():
-            if PlugInstance != self:
-                AllChannels.append(PlugInstance.BaseParams.getIEC_Channel())
-        AllChannels.sort()
-
+        AllChannels = self.GetAllChannels()
+        
         # Now, try to guess the nearest available channel
         res = DesiredChannel
         while res in AllChannels: # While channel not free
--- a/plugins/canfestival/canfestival.py	Tue Feb 14 12:20:19 2012 +0100
+++ b/plugins/canfestival/canfestival.py	Wed Feb 15 00:44:24 2012 +0100
@@ -365,7 +365,13 @@
         return infos
     
     def GetCanDriver(self):
-        return self.CanFestivalInstance.getCAN_Driver()
+        can_driver = self.CanFestivalInstance.getCAN_Driver()
+        if sys.platform == 'win32':
+            if self.CanFestivalInstance.getDebug_mode() and os.path.isfile(os.path.join("%s"%(can_driver + '_DEBUG.dll'))):
+                can_driver += '_DEBUG.dll'
+            else:
+                can_driver += '.dll'
+        return can_driver
     
     def PlugGenerate_C(self, buildpath, locations):
         
@@ -403,29 +409,34 @@
 
                 # initialize and declare node boot status variables for post_SlaveBootup lookup
                 SlaveIDs = child.GetSlaveIDs()
-                for id in SlaveIDs:
+                if len(SlaveIDs) == 0:
+                    # define post_SlaveBootup lookup functions
                     format_dict["slavebootups"] += (
-                    "int %s_slave_%d_booted = 0;\n"%(nodename, id))
-                # define post_SlaveBootup lookup functions
-                format_dict["slavebootups"] += (
-                    "static void %s_post_SlaveBootup(CO_Data* d, UNS8 nodeId){\n"%(nodename)+
-                    "    switch(nodeId){\n")
-                # one case per declared node, mark node as booted
-                for id in SlaveIDs:
+                        "static void %s_post_SlaveBootup(CO_Data* d, UNS8 nodeId){}\n"%(nodename))
+                else:
+                    for id in SlaveIDs:
+                        format_dict["slavebootups"] += (
+                        "int %s_slave_%d_booted = 0;\n"%(nodename, id))
+                    # define post_SlaveBootup lookup functions
                     format_dict["slavebootups"] += (
-                    "        case %d:\n"%(id)+
-                    "            %s_slave_%d_booted = 1;\n"%(nodename, id)+
-                    "            break;\n")
-                format_dict["slavebootups"] += (
-                    "        default:\n"+
-                    "            break;\n"+
-                    "    }\n"+
-                    "    if( ")
-                # expression to test if all declared nodes booted
-                format_dict["slavebootups"] += " && ".join(["%s_slave_%d_booted"%(nodename, id) for id in SlaveIDs])
-                format_dict["slavebootups"] += " )\n" + (
-                    "        Master_post_SlaveBootup(d,nodeId);\n"+
-                    "}\n")
+                        "static void %s_post_SlaveBootup(CO_Data* d, UNS8 nodeId){\n"%(nodename)+
+                        "    switch(nodeId){\n")
+                    # one case per declared node, mark node as booted
+                    for id in SlaveIDs:
+                        format_dict["slavebootups"] += (
+                        "        case %d:\n"%(id)+
+                        "            %s_slave_%d_booted = 1;\n"%(nodename, id)+
+                        "            break;\n")
+                    format_dict["slavebootups"] += (
+                        "        default:\n"+
+                        "            break;\n"+
+                        "    }\n"+
+                        "    if( ")
+                    # expression to test if all declared nodes booted
+                    format_dict["slavebootups"] += " && ".join(["%s_slave_%d_booted"%(nodename, id) for id in SlaveIDs])
+                    format_dict["slavebootups"] += " )\n" + (
+                        "        Master_post_SlaveBootup(d,nodeId);\n"+
+                        "}\n")
                 # register previously declared func as post_SlaveBootup callback for that node
                 format_dict["slavebootup_register"] += (
                     "%s_Data.post_SlaveBootup = %s_post_SlaveBootup;\n"%(nodename,nodename))
@@ -459,12 +470,7 @@
                    child_data.getCAN_Baudrate())
             format_dict["nodes_open"] += 'NODE_OPEN(%s)\n    '%(nodename)
             format_dict["nodes_close"] += 'NODE_CLOSE(%s)\n    '%(nodename)
-            format_dict["nodes_stop"] += 'NODE_STOP(%s)\n    '%(nodename)        
-        if sys.platform == 'win32':
-            if self.CanFestivalInstance.getDebug_mode() and os.path.isfile(os.path.join("%s"%(format_dict["candriver"] + '_DEBUG.dll'))):
-                    format_dict["candriver"] += '_DEBUG.dll'
-            else:
-                format_dict["candriver"] += '.dll'
+            format_dict["nodes_stop"] += 'NODE_STOP(%s)\n    '%(nodename)
         
         filename = os.path.join(os.path.split(__file__)[0],"cf_runtime.c")
         cf_main = open(filename).read() % format_dict