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