Greg changes merged
author'Laurent Bessard <laurent.bessard@lolitech.fr>'
Fri, 16 Oct 2009 10:50:16 +0200
changeset 420 c093ec48f2fd
parent 419 1cdae505be9e (diff)
parent 418 01f6bfc01251 (current diff)
child 421 c9ec111ad275
Greg changes merged
plugger.py
plugins/c_ext/c_ext.py
--- a/Beremiz.py	Thu Oct 15 17:39:26 2009 +0200
+++ b/Beremiz.py	Fri Oct 16 10:50:16 2009 +0200
@@ -377,7 +377,7 @@
         
         self._init_beremiz_sizers()
 
-    def __init__(self, parent, projectOpen, buildpath, debug=True):
+    def __init__(self, parent, projectOpen=None, buildpath=None, plugin_root=None, debug=True):
         IDEFrame.__init__(self, parent, debug)
         self.Config = wx.ConfigBase.Get()
         
@@ -403,8 +403,11 @@
                 self.ResetView()
                 self.ShowErrorMessage(result)
         else:
-            self.PluginRoot = None
-            self.Controler = None
+            self.PluginRoot = plugin_root
+            self.Controler = plugin_root
+            if plugin_root is not None:
+                self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
+                self.RefreshAll()
         
         # Add beremiz's icon in top left corner of the frame
         self.SetIcon(wx.Icon(Bpath( "images", "brz.ico"), wx.BITMAP_TYPE_ICO))
--- a/plugger.py	Thu Oct 15 17:39:26 2009 +0200
+++ b/plugger.py	Fri Oct 16 10:50:16 2009 +0200
@@ -485,7 +485,7 @@
         # Ask to his parent to remove it
         self.PlugParent._doRemoveChild(self)
 
-    def PlugAddChild(self, PlugName, PlugType):
+    def PlugAddChild(self, PlugName, PlugType, IEC_Channel=0):
         """
         Create the plugins that may be added as child to this node self
         @param PlugType: string desining the plugin class name (get name from PlugChildsTypes)
@@ -554,7 +554,7 @@
                     # If plugin do not have corresponding file/dirs - they will be created on Save
                     _self.PlugMakeDir()
                     # Find an IEC number
-                    _self.FindNewIEC_Channel(0)
+                    _self.FindNewIEC_Channel(IEC_Channel)
                     # Call the plugin real __init__
                     if getattr(PlugClass, "__init__", None):
                         PlugClass.__init__(_self)
@@ -739,8 +739,7 @@
         PLCControler.__init__(self)
 
         self.MandatoryParams = None
-        self.AppFrame = frame
-        self.logger = logger
+        self.SetAppFrame(frame, logger)
         self._builder = None
         self._connector = None
         self.Deleting = False
@@ -755,11 +754,6 @@
         self.DebugTimer=None
         self.ResetIECProgramsAndVariables()
         
-        # Timer to pull PLC status
-        ID_STATUSTIMER = wx.NewId()
-        self.StatusTimer = wx.Timer(self.AppFrame, ID_STATUSTIMER)
-        self.AppFrame.Bind(wx.EVT_TIMER, self.PullPLCStatusProc, self.StatusTimer)
-        
         #This method are not called here... but in NewProject and OpenProject
         #self._AddParamsMembers()
         #self.PluggedChilds = {}
@@ -785,6 +779,25 @@
     def __del__(self):
         self.Deleting = True
 
+    def SetAppFrame(self, frame, logger):
+        self.AppFrame = frame
+        self.logger = logger
+        self.StatusTimer = None
+        
+        if frame is not None:
+            # Timer to pull PLC status
+            ID_STATUSTIMER = wx.NewId()
+            self.StatusTimer = wx.Timer(self.AppFrame, ID_STATUSTIMER)
+            self.AppFrame.Bind(wx.EVT_TIMER, self.PullPLCStatusProc, self.StatusTimer)
+
+    def ResetAppFrame(self, logger):
+        if self.AppFrame is not None:
+            self.AppFrame.Unbind(wx.EVT_TIMER, self.StatusTimer)
+            self.StatusTimer = None
+            self.AppFrame = None
+        
+        self.logger = logger
+
     def PluginLibraryFilePath(self):
         return os.path.join(os.path.split(__file__)[0], "pous.xml")
 
@@ -916,8 +929,8 @@
     
     def CloseProject(self):
         self.ClearPluggedChilds()
-        self.AppFrame.Unbind(wx.EVT_TIMER, self.StatusTimer)
-    
+        self.ResetAppFrame(None)
+        
     def SaveProject(self):
         if not self.SaveXMLFile():
             self.SaveXMLFile(os.path.join(self.ProjectPath, 'plc.xml'))
--- a/plugins/c_ext/c_ext.py	Thu Oct 15 17:39:26 2009 +0200
+++ b/plugins/c_ext/c_ext.py	Fri Oct 16 10:50:16 2009 +0200
@@ -324,15 +324,15 @@
         text += "  return 0;\n"
         text += "\n}\n\n"
         
-        text += "void __cleanup_%s()\n{\n"%location_str
+        text += "void __cleanup_%s(void)\n{\n"%location_str
         text += self.CFile.cleanUpFunction.gettext()
         text += "\n}\n\n"
         
-        text += "void __retrieve_%s()\n{\n"%location_str
+        text += "void __retrieve_%s(void)\n{\n"%location_str
         text += self.CFile.retrieveFunction.gettext()
         text += "\n}\n\n"
         
-        text += "void __publish_%s()\n{\n"%location_str
+        text += "void __publish_%s(void)\n{\n"%location_str
         text += self.CFile.publishFunction.gettext()
         text += "\n}\n\n"