# HG changeset patch # User 'Laurent Bessard ' # Date 1255683016 -7200 # Node ID c093ec48f2fd17f5b6dabda3b10f0ea2c3d66fbf # Parent 1cdae505be9efa4e9e1f1c079a84dffede42d117# Parent 01f6bfc01251e81dcae4d0527728e5b90dc5430c Greg changes merged diff -r 01f6bfc01251 -r c093ec48f2fd Beremiz.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)) diff -r 01f6bfc01251 -r c093ec48f2fd plugger.py --- 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')) diff -r 01f6bfc01251 -r c093ec48f2fd plugins/c_ext/c_ext.py --- 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"