# HG changeset patch # User greg # Date 1224168579 -7200 # Node ID 1da137b99948039fe7f12408ceb7744c88877ca7 # Parent 1f660bed2ab1ebc8e0d0e60e03525e6ec7839d28 add buildpath parameter for beremiz fix problems with test_svgui remove -mno-cygwin from plugins/svgui diff -r 1f660bed2ab1 -r 1da137b99948 Beremiz.py --- a/Beremiz.py Tue Oct 14 13:40:17 2008 +0200 +++ b/Beremiz.py Thu Oct 16 16:49:39 2008 +0200 @@ -36,7 +36,7 @@ if __name__ == '__main__': def usage(): print "\nUsage of Beremiz.py :" - print "\n %s [Projectpath]\n"%sys.argv[0] + print "\n %s [Projectpath] [Buildpath]\n"%sys.argv[0] try: opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) @@ -50,13 +50,17 @@ usage() sys.exit() - if len(args) > 1: + if len(args) > 2: usage() sys.exit() elif len(args) == 1: projectOpen = args[0] + elif len(args) == 2: + projectOpen = args[0] + buildpath = args[1] else: projectOpen = None + buildpath = None app = wx.PySimpleApp() wx.InitAllImageHandlers() @@ -404,7 +408,7 @@ self._init_sizers() - def __init__(self, parent, projectOpen): + def __init__(self, parent, projectOpen, buildpath): self._init_ctrls(parent) self.Log = LogPseudoFile(self.LogConsole) @@ -430,7 +434,7 @@ if projectOpen: self.PluginRoot = PluginsRoot(self, self.Log, self.runtime_port) - self.PluginRoot.LoadProject(projectOpen) + self.PluginRoot.LoadProject(projectOpen, buildpath) self.RefreshPLCParams() self.RefreshPluginTree() else: @@ -1173,11 +1177,10 @@ first = False def OnNewProjectMenu(self, event): - defaultpath = "" + defaultpath = config.Read("workspacedir") if self.PluginRoot is not None: defaultpath = self.PluginRoot.GetProjectPath() - if not defaultpath: - defaultpath = os.getcwd() + dialog = wx.DirDialog(self , "Choose a project", defaultpath, wx.DD_NEW_DIR_BUTTON) if dialog.ShowModal() == wx.ID_OK: projectpath = dialog.GetPath() @@ -1195,11 +1198,10 @@ event.Skip() def OnOpenProjectMenu(self, event): - defaultpath = "" + defaultpath = config.Read("workspacedir") if self.PluginRoot is not None: defaultpath = self.PluginRoot.GetProjectPath() - if not defaultpath: - defaultpath = os.getcwd() + dialog = wx.DirDialog(self , "Choose a project", defaultpath, wx.DD_NEW_DIR_BUTTON) if dialog.ShowModal() == wx.ID_OK: projectpath = dialog.GetPath() @@ -1442,8 +1444,16 @@ # Install a exception handle for bug reports AddExceptHook(os.getcwd(),__version__) - frame = Beremiz(None, projectOpen) + frame = Beremiz(None, projectOpen, buildpath) frame.Show() splash.Close() - + config = wx.ConfigBase.Get() + if not config.HasEntry("workspacedir"): + defaultpath = os.path.expanduser("~") + dialog = wx.DirDialog(frame, "Select a Workspace", defaultpath, wx.DD_NEW_DIR_BUTTON) + if dialog.ShowModal() == wx.ID_OK: + defaultpath = dialog.GetPath() + dialog.Destroy() + config.Write("workspacedir", defaultpath) + config.Flush() app.MainLoop() diff -r 1f660bed2ab1 -r 1da137b99948 plugger.py --- a/plugger.py Tue Oct 14 13:40:17 2008 +0200 +++ b/plugger.py Thu Oct 16 16:49:39 2008 +0200 @@ -682,6 +682,7 @@ self.PlugType = "Beremiz" # After __init__ root plugin is not valid self.ProjectPath = None + self.BuildPath = None self.PLCEditor = None self.PLCDebug = None # copy PluginMethods so that it can be later customized @@ -714,7 +715,7 @@ childs.append(child.GetPlugInfos()) return {"name" : "PLC (%s)"%self.GetProjectName(), "type" : None, "values" : childs} - def NewProject(self, ProjectPath): + def NewProject(self, ProjectPath, BuildPath=None): """ Create a new project in an empty folder @param ProjectPath: path of the folder where project have to be created @@ -740,13 +741,14 @@ self.PluggedChilds = {} # Keep track of the root plugin (i.e. project path) self.ProjectPath = ProjectPath + self.BuildPath = BuildPath # get plugins bloclist (is that usefull at project creation?) self.RefreshPluginsBlockLists() # this will create files base XML files self.SaveProject() return None - def LoadProject(self, ProjectPath): + def LoadProject(self, ProjectPath, BuildPath=None): """ Load a project contained in a folder @param ProjectPath: path of the project folder @@ -766,6 +768,7 @@ self.PluggedChilds = {} # Keep track of the root plugin (i.e. project path) self.ProjectPath = ProjectPath + self.BuildPath = BuildPath # If dir have already be made, and file exist if os.path.isdir(self.PlugPath()) and os.path.isfile(self.PluginXmlFilePath()): #Load the plugin.xml file into parameters members @@ -810,7 +813,9 @@ return os.path.join(self.PlugPath(PlugName), "beremiz.xml") def _getBuildPath(self): - return os.path.join(self.ProjectPath, "build") + if self.BuildPath is None: + return os.path.join(self.ProjectPath, "build") + return self.BuildPath def _getExtraFilesPath(self): return os.path.join(self._getBuildPath(), "extra_files") diff -r 1f660bed2ab1 -r 1da137b99948 plugins/svgui/svgui.py --- a/plugins/svgui/svgui.py Tue Oct 14 13:40:17 2008 +0200 +++ b/plugins/svgui/svgui.py Thu Oct 16 16:49:39 2008 +0200 @@ -230,7 +230,7 @@ if wx.Platform == '__WXMSW__': cxx_flags = "-I..\\..\\wxPython-src-2.8.8.1\\bld\\lib\\wx\\include\\msw-unicode-release-2.8 -I..\\..\\wxPython-src-2.8.8.1\\include -I..\\..\\wxPython-src-2.8.8.1\\contrib\\include -I..\\..\\matiec\\lib -DWXUSINGDLL -D__WXMSW__ -mthreads" - libs = "\"..\\lib\\libwxsvg.a\" \"..\\lib\\libwxsvg_agg.a\" \"..\\lib\\libagg.a\" \"..\\lib\\libaggplatformwin32.a\" \"..\\lib\\libaggfontwin32tt.a\" -L..\\..\\wxPython-src-2.8.8.1\\bld\\lib -mno-cygwin -mwindows -mthreads -mno-cygwin -mwindows -Wl,--subsystem,windows -mwindows -lwx_mswu_richtext-2.8 -lwx_mswu_aui-2.8 -lwx_mswu_xrc-2.8 -lwx_mswu_qa-2.8 -lwx_mswu_html-2.8 -lwx_mswu_adv-2.8 -lwx_mswu_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8" + libs = "\"..\\lib\\libwxsvg.a\" \"..\\lib\\libwxsvg_agg.a\" \"..\\lib\\libagg.a\" \"..\\lib\\libaggplatformwin32.a\" \"..\\lib\\libaggfontwin32tt.a\" -L..\\..\\wxPython-src-2.8.8.1\\bld\\lib -mwindows -mthreads -Wl,--subsystem,windows -mwindows -lwx_mswu_richtext-2.8 -lwx_mswu_aui-2.8 -lwx_mswu_xrc-2.8 -lwx_mswu_qa-2.8 -lwx_mswu_html-2.8 -lwx_mswu_adv-2.8 -lwx_mswu_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8" else: status, result, err_result = ProcessLogger(self.logger, "wx-config --cxxflags", no_stdout=True).spin() if status: diff -r 1f660bed2ab1 -r 1da137b99948 tests/linux/test_svgui/beremiz.xml --- a/tests/linux/test_svgui/beremiz.xml Tue Oct 14 13:40:17 2008 +0200 +++ b/tests/linux/test_svgui/beremiz.xml Thu Oct 16 16:49:39 2008 +0200 @@ -1,9 +1,6 @@ - + - + - - - diff -r 1f660bed2ab1 -r 1da137b99948 tests/linux/test_svgui/methods.py --- a/tests/linux/test_svgui/methods.py Tue Oct 14 13:40:17 2008 +0200 +++ b/tests/linux/test_svgui/methods.py Thu Oct 16 16:49:39 2008 +0200 @@ -1,11 +1,11 @@ -logger.write_error("Welcome to the Beremiz Demo\n\n") -logger.write("This demo provides a PLC working with the CANopen plugin\n") -logger.write("""Some external programs are also provided:\n +self.logger.write_error("Welcome to the Beremiz Demo\n\n") +self.logger.write("This demo provides a PLC working with the CANopen plugin\n") +self.logger.write("""Some external programs are also provided:\n - a CAN TCP server to simulate the CANopen network - a virtual slave node to simulate input block - a virtual slave node to simulate output block """) -logger.write("\nInfo: For this demo, %s plugin has some special methods to run external programs.\nThese methods are defined in methods.py\n" % (PlugName or "Root")) +self.logger.write("\nInfo: For this demo, %s plugin has some special methods to run external programs.\nThese methods are defined in methods.py\n" % (PlugName or "Root")) #open_pdf(os.path.join(os.path.split(__file__)[0], "doc", "manual_beremiz.pdf"), pagenum=21) if wx.Platform == '__WXMSW__': @@ -42,23 +42,23 @@ def my_methods(self): - def _Run(logger): + def _Run(): # External programs list # Launch them and get their pid for prog in self.listLaunchProg: logger.write("Starting %s\n" % prog['name']) - prog['pid'] = ProcessLogger(logger, prog['command'], no_gui=prog['no_gui']) + prog['pid'] = ProcessLogger(self.logger, prog['command'], no_gui=prog['no_gui']) prog['pid'].spin( timeout=200, keyword = prog['keyword'], kill_it = False) - PluginsRoot._Run(self,logger) + PluginsRoot._Run(self) - def _Stop(logger): - PluginsRoot._Stop(self,logger) + def _Stop(): + PluginsRoot._Stop(self) for prog in self.listLaunchProg: - logger.write("Stopping %s\n" % prog['name']) + self.logger.write("Stopping %s\n" % prog['name']) prog['pid'].kill() return _Run, _Stop