etisserant@170: logger.write_error("Welcome to the Beremiz Demo\n\n") etisserant@170: logger.write("This demo provides a PLC working with the CANopen plugin\n") etisserant@170: logger.write("""Some external programs are also provided:\n etisserant@170: - a CAN TCP server to simulate the CANopen network etisserant@170: - a virtual slave node to simulate input block etisserant@170: - a virtual slave node to simulate output block etisserant@170: """) etisserant@170: 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")) etisserant@170: #open_pdf(os.path.join(os.path.split(__file__)[0], "doc", "manual_beremiz.pdf"), pagenum=21) etisserant@170: etisserant@170: if wx.Platform == '__WXMSW__': etisserant@170: self.listLaunchProg = [ etisserant@170: {'name' : 'Can Tcp Server', etisserant@170: 'command' : 'can_tcp_win32_server.exe', etisserant@170: 'keyword' : 'Accepts', etisserant@170: 'pid' : None, etisserant@170: 'no_gui' : True}, etisserant@170: {'name' : 'DS401 Slave Gui NodeId 32', etisserant@170: 'command' : 'DS401_Slave_Gui.exe -sI -l can_tcp_win32.dll -b 127.0.0.1 -i 20 -B 125K', etisserant@170: 'keyword' : '[OK]', etisserant@170: 'pid' : None, etisserant@170: 'no_gui' : False}, etisserant@170: {'name' : 'DS401 Slave Gui NodeId 16', etisserant@170: 'command' : 'DS401_Slave_Gui.exe -sO -l can_tcp_win32.dll -b 127.0.0.1 -i 10 -B 125K', etisserant@170: 'keyword' : '[OK]', etisserant@170: 'pid' : None, etisserant@170: 'no_gui' : False} etisserant@170: ] etisserant@170: else: etisserant@170: self.listLaunchProg = [ etisserant@170: {'name' : 'DS401 Slave Gui NodeId 32', etisserant@170: 'command' : '../CanFestival-3/examples/DS401_Slave_Gui/DS401_Slave_Gui -sI -l ../CanFestival-3/drivers/can_socket/libcanfestival_can_socket.so -b vcan0 -i 20 -B 125K', etisserant@170: 'keyword' : '[OK]', etisserant@170: 'pid' : None, etisserant@170: 'no_gui' : False}, etisserant@170: {'name' : 'DS401 Slave Gui NodeId 16', etisserant@170: 'command' : '../CanFestival-3/examples/DS401_Slave_Gui/DS401_Slave_Gui -sO -l ../CanFestival-3/drivers/can_socket/libcanfestival_can_socket.so -b vcan0 -i 10 -B 125K', etisserant@170: 'keyword' : '[OK]', etisserant@170: 'pid' : None, etisserant@170: 'no_gui' : False} etisserant@170: ] etisserant@170: etisserant@170: etisserant@170: def my_methods(self): etisserant@170: def _Run(logger): etisserant@170: # External programs list etisserant@170: # Launch them and get their pid etisserant@170: for prog in self.listLaunchProg: etisserant@170: logger.write("Starting %s\n" % prog['name']) etisserant@170: prog['pid'] = ProcessLogger(logger, prog['command'], no_gui=prog['no_gui']) etisserant@170: prog['pid'].spin( etisserant@170: timeout=200, etisserant@170: keyword = prog['keyword'], etisserant@170: kill_it = False) etisserant@170: etisserant@170: PluginsRoot._Run(self,logger) etisserant@170: etisserant@170: def _Stop(logger): etisserant@170: PluginsRoot._Stop(self,logger) etisserant@170: for prog in self.listLaunchProg: etisserant@170: logger.write("Stopping %s\n" % prog['name']) etisserant@170: prog['pid'].kill() etisserant@170: etisserant@170: return _Run, _Stop etisserant@170: etisserant@170: self._Run, self._Stop = my_methods(self)