266
|
1 |
self.logger.write_error("Welcome to the Beremiz Demo\n\n")
|
|
2 |
self.logger.write("This demo provides a PLC working with the CANopen plugin\n")
|
|
3 |
self.logger.write("""Some external programs are also provided:\n
|
|
4 |
- a CAN TCP server to simulate the CANopen network
|
|
5 |
- a virtual slave node to simulate input block
|
|
6 |
- a virtual slave node to simulate output block
|
|
7 |
""")
|
|
8 |
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"))
|
|
9 |
#open_pdf(os.path.join(os.path.split(__file__)[0], "doc", "manual_beremiz.pdf"), pagenum=21)
|
|
10 |
|
|
11 |
if wx.Platform == '__WXMSW__':
|
|
12 |
self.listLaunchProg = [
|
|
13 |
{'name' : 'Can Tcp Server',
|
|
14 |
'command' : 'can_tcp_win32_server.exe',
|
|
15 |
'keyword' : 'Accepts',
|
|
16 |
'pid' : None,
|
|
17 |
'no_gui' : True}]
|
|
18 |
else:
|
|
19 |
self.listLaunchProg = []
|
|
20 |
|
|
21 |
def my_methods(self):
|
|
22 |
def _Run():
|
|
23 |
# External programs list
|
|
24 |
# Launch them and get their pid
|
|
25 |
for prog in self.listLaunchProg:
|
|
26 |
self.logger.write("Starting %s\n" % prog['name'])
|
|
27 |
prog['pid'] = ProcessLogger(self.logger, prog['command'], no_gui=prog['no_gui'])
|
|
28 |
prog['pid'].spin(
|
|
29 |
timeout=200,
|
|
30 |
keyword = prog['keyword'],
|
|
31 |
kill_it = False)
|
|
32 |
|
|
33 |
PluginsRoot._Run(self)
|
|
34 |
|
|
35 |
def _Stop():
|
|
36 |
PluginsRoot._Stop(self)
|
|
37 |
for prog in self.listLaunchProg:
|
|
38 |
self.logger.write("Stopping %s\n" % prog['name'])
|
|
39 |
prog['pid'].kill()
|
|
40 |
|
|
41 |
return _Run, _Stop
|
|
42 |
|
|
43 |
self._Run, self._Stop = my_methods(self) |