Merging with Edouard's modifications
authorlaurent
Mon, 17 Oct 2011 09:04:13 +0200
changeset 628 2a8476222ba8
parent 627 ff7f76c936b9 (current diff)
parent 625 08d4cc1ceb9b (diff)
child 629 61347cc521d1
child 630 91b2ae63ea3d
Merging with Edouard's modifications
Beremiz.py
--- a/Beremiz.py	Fri Oct 14 23:54:00 2011 +0200
+++ b/Beremiz.py	Mon Oct 17 09:04:13 2011 +0200
@@ -325,11 +325,7 @@
 
 [ID_BEREMIZ, ID_BEREMIZMAINSPLITTER, 
  ID_BEREMIZPLCCONFIG, ID_BEREMIZLOGCONSOLE, 
- ID_BEREMIZINSPECTOR, ID_BUILD] = [wx.NewId() for _init_ctrls in range(6)]
-
-[ID_BEREMIZRUNMENUBUILD, ID_BEREMIZRUNMENUSIMULATE, 
- ID_BEREMIZRUNMENURUN, ID_BEREMIZRUNMENUSAVELOG, 
-] = [wx.NewId() for _init_coll_EditMenu_Items in range(4)]
+ ID_BEREMIZINSPECTOR] = [wx.NewId() for _init_ctrls in range(5)]
 
 class Beremiz(IDEFrame):
 	
@@ -408,10 +404,23 @@
         IDEFrame._init_ctrls(self, prnt)
         
         self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, id=ID_BEREMIZINSPECTOR)
-        self.Bind(wx.EVT_MENU, self.OnBuildProject, id=ID_BUILD)
-        accel = wx.AcceleratorTable([wx.AcceleratorEntry(wx.ACCEL_CTRL|wx.ACCEL_ALT, ord('I'), ID_BEREMIZINSPECTOR),
-                                     wx.AcceleratorEntry(wx.ACCEL_NORMAL, wx.WXK_F11, ID_BUILD)])
-        self.SetAcceleratorTable(accel)
+        accels = [wx.AcceleratorEntry(wx.ACCEL_CTRL|wx.ACCEL_ALT, ord('I'), ID_BEREMIZINSPECTOR)]
+        for method,shortcut in [("Stop",     wx.WXK_F4),
+                                ("Run",      wx.WXK_F5),
+                                ("Transfer", wx.WXK_F6),
+                                ("Connect",  wx.WXK_F7),
+                                ("Build",    wx.WXK_F11)]:
+            def OnMethodGen(obj,meth):
+                def OnMethod(evt):
+                    if obj.PluginRoot is not None:
+                       obj.PluginRoot.CallMethod('_'+meth)
+                    wx.CallAfter(self.RefreshAll)
+                return OnMethod
+            newid = wx.NewId()
+            self.Bind(wx.EVT_MENU, OnMethodGen(self,method), id=newid)
+            accels += [wx.AcceleratorEntry(wx.ACCEL_NORMAL, shortcut,newid)]
+        
+        self.SetAcceleratorTable(wx.AcceleratorTable(accels))
         
         self.PLCConfig = wx.ScrolledWindow(id=ID_BEREMIZPLCCONFIG,
               name='PLCConfig', parent=self.LeftNoteBook, pos=wx.Point(0, 0),
@@ -525,10 +534,6 @@
             wnd = self
         InspectionTool().Show(wnd, True)
 
-    def OnBuildProject(self, evt):
-        if self.PluginRoot is not None:
-            self.PluginRoot._build()
-
     def OnLogConsoleDClick(self, event):
         wx.CallAfter(self.SearchLineForError)
         event.Skip()
--- a/LPCBeremiz.py	Fri Oct 14 23:54:00 2011 +0200
+++ b/LPCBeremiz.py	Mon Oct 17 09:04:13 2011 +0200
@@ -397,7 +397,7 @@
         {"bitmap" : opjimg("Build"),
          "name" : _("Build"),
          "tooltip" : _("Build project into build folder"),
-         "method" : "_build"},
+         "method" : "_Build"},
         {"bitmap" : opjimg("Transfer"),
          "name" : _("Transfer"),
          "shown" : False,
@@ -443,14 +443,14 @@
         else:
             return PluginsRoot._getBuildPath(self)
 
-    def _build(self):
+    def _Build(self):
         save = self.ProjectTestModified()
         if save:
             self.SaveProject()
             self.AppFrame._Refresh(TITLE, FILEMENU)
         if self.BuildPath is not None:
             mycopytree(self.OrigBuildPath, self.BuildPath)
-        PluginsRoot._build(self)
+        PluginsRoot._Build(self)
         if save:
             wx.CallAfter(self.AppFrame.RefreshAll)
     
@@ -610,22 +610,22 @@
                      "Started" :     [("_Simulate", False),
                                       ("_Run", False),
                                       ("_Stop", True),
-                                      ("_build", True),
+                                      ("_Build", True),
                                       ("_Transfer", True)],
                      "Stopped" :     [("_Simulate", False),
                                       ("_Run", True),
                                       ("_Stop", False),
-                                      ("_build", True),
+                                      ("_Build", True),
                                       ("_Transfer", True)],
                      "Connected" :   [("_Simulate", not simulating),
                                       ("_Run", True),
                                       ("_Stop", simulating),
-                                      ("_build", True),
+                                      ("_Build", True),
                                       ("_Transfer", True)],
                      "Disconnected" :[("_Simulate", not simulating),
                                       ("_Run", False),
                                       ("_Stop", simulating),
-                                      ("_build", True),
+                                      ("_Build", True),
                                       ("_Transfer", False)],
                    }.get(status,[]):
                 self.ShowMethod(*args)
@@ -802,7 +802,7 @@
         if self.CurrentMode is None and self.OnlineMode != "OFF":
             self.CurrentMode = TRANSFER_MODE
             
-            PluginsRoot._build(self)
+            PluginsRoot._Build(self)
             
             ID_ABORTTRANSFERTIMER = wx.NewId()
             self.AbortTransferTimer = wx.Timer(self.AppFrame, ID_ABORTTRANSFERTIMER)
@@ -1222,7 +1222,7 @@
                 frame.Hide()
         
         def Compile(self):
-            self.PluginRoot._build()
+            self.PluginRoot._Build()
         
         def SetProjectProperties(self, projectname, productname, productversion, companyname):
             properties = self.PluginRoot.GetProjectProperties()
--- a/plugger.py	Fri Oct 14 23:54:00 2011 +0200
+++ b/plugger.py	Mon Oct 17 09:04:13 2011 +0200
@@ -651,6 +651,11 @@
                 return True
         return False
 
+    def CallMethod(self, method):
+        for d in self.PluginMethods:
+            if d["method"]==method and d.get("enabled", True) and d.get("shown", True):
+                getattr(self, method)()
+
 def _GetClassFunction(name):
     def GetRootClass():
         return getattr(__import__("plugins." + name), name).RootClass
@@ -1385,7 +1390,7 @@
         return plc_main_code
 
         
-    def _build(self):
+    def _Build(self):
         """
         Method called by user to (re)build SoftPLC and plugin tree
         """
@@ -1480,6 +1485,7 @@
             self.logger.write_error(traceback.format_exc())
             return False
 
+        self.logger.write(_("Successfully built.\n"))
         # Update GUI status about need for transfer
         self.CompareLocalAndRemotePLC()
         return True
@@ -1751,12 +1757,12 @@
     def KillDebugThread(self):
         self.debug_break = True
         if self.DebugThread is not None:
-            self.logger.writeyield(_("Stopping debug ... "))
+            self.logger.writeyield(_("Stopping debugger...\n"))
             self.DebugThread.join(timeout=5)
             if self.DebugThread.isAlive() and self.logger:
-                self.logger.write_warning(_("Debug Thread couldn't be killed"))
+                self.logger.write_warning(_("Couldn't stop debugger.\n"))
             else:
-                self.logger.write(_("success\n"))
+                self.logger.write(_("Debugger stopped.\n"))
         self.DebugThread = None
 
     def _connect_debug(self): 
@@ -1946,7 +1952,7 @@
         {"bitmap" : opjimg("Build"),
          "name" : _("Build"),
          "tooltip" : _("Build project into build folder"),
-         "method" : "_build"},
+         "method" : "_Build"},
         {"bitmap" : opjimg("Clean"),
          "name" : _("Clean"),
          "enabled" : False,