greg@266: self.logger.write_error("Welcome to the Beremiz Demo\n\n") greg@266: self.logger.write("This demo provides a PLC working with the CANopen plugin\n") greg@266: self.logger.write("""Some external programs are also provided:\n greg@266: - a CAN TCP server to simulate the CANopen network greg@266: - a virtual slave node to simulate input block greg@266: - a virtual slave node to simulate output block greg@266: """) greg@266: 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")) greg@266: #open_pdf(os.path.join(os.path.split(__file__)[0], "doc", "manual_beremiz.pdf"), pagenum=21) greg@266: greg@266: if wx.Platform == '__WXMSW__': greg@266: self.listLaunchProg = [ greg@266: {'name' : 'Can Tcp Server', greg@266: 'command' : 'can_tcp_win32_server.exe', greg@266: 'keyword' : 'Accepts', greg@266: 'pid' : None, greg@266: 'no_gui' : True}] greg@266: else: greg@266: self.listLaunchProg = [] greg@266: greg@266: def my_methods(self): greg@266: def _Run(): greg@266: # External programs list greg@266: # Launch them and get their pid greg@266: for prog in self.listLaunchProg: greg@266: self.logger.write("Starting %s\n" % prog['name']) greg@266: prog['pid'] = ProcessLogger(self.logger, prog['command'], no_gui=prog['no_gui']) greg@266: prog['pid'].spin( greg@266: timeout=200, greg@266: keyword = prog['keyword'], greg@266: kill_it = False) greg@266: greg@266: PluginsRoot._Run(self) greg@266: greg@266: def _Stop(): greg@266: PluginsRoot._Stop(self) greg@266: for prog in self.listLaunchProg: greg@266: self.logger.write("Stopping %s\n" % prog['name']) greg@266: prog['pid'].kill() greg@266: greg@266: return _Run, _Stop greg@266: greg@266: self._Run, self._Stop = my_methods(self)