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 |
{'name' : 'DS401 Slave Gui NodeId 32',
|
|
19 |
'command' : 'DS401_Slave_Gui.exe -sI -l can_tcp_win32.dll -b 127.0.0.1 -i 20 -B 125K',
|
|
20 |
'keyword' : '[OK]',
|
|
21 |
'pid' : None,
|
|
22 |
'no_gui' : False},
|
|
23 |
{'name' : 'DS401 Slave Gui NodeId 16',
|
|
24 |
'command' : 'DS401_Slave_Gui.exe -sO -l can_tcp_win32.dll -b 127.0.0.1 -i 10 -B 125K',
|
|
25 |
'keyword' : '[OK]',
|
|
26 |
'pid' : None,
|
|
27 |
'no_gui' : False}
|
|
28 |
]
|
|
29 |
else:
|
|
30 |
self.listLaunchProg = [
|
|
31 |
{'name' : 'DS401 Slave Gui NodeId 32',
|
|
32 |
'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',
|
|
33 |
'keyword' : '[OK]',
|
|
34 |
'pid' : None,
|
|
35 |
'no_gui' : False},
|
|
36 |
{'name' : 'DS401 Slave Gui NodeId 16',
|
|
37 |
'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',
|
|
38 |
'keyword' : '[OK]',
|
|
39 |
'pid' : None,
|
|
40 |
'no_gui' : False}
|
|
41 |
]
|
|
42 |
|
|
43 |
|
|
44 |
def my_methods(self):
|
|
45 |
def _Run():
|
|
46 |
# External programs list
|
|
47 |
# Launch them and get their pid
|
|
48 |
for prog in self.listLaunchProg:
|
|
49 |
self.logger.write("Starting %s\n" % prog['name'])
|
|
50 |
prog['pid'] = ProcessLogger(self.logger, prog['command'], no_gui=prog['no_gui'])
|
|
51 |
prog['pid'].spin(
|
|
52 |
timeout=200,
|
|
53 |
keyword = prog['keyword'],
|
|
54 |
kill_it = False)
|
|
55 |
|
|
56 |
PluginsRoot._Run(self)
|
|
57 |
|
|
58 |
def _Debug():
|
|
59 |
# External programs list
|
|
60 |
# Launch them and get their pid
|
|
61 |
for prog in self.listLaunchProg:
|
|
62 |
self.logger.write("Starting %s\n" % prog['name'])
|
|
63 |
prog['pid'] = ProcessLogger(self.logger, prog['command'], no_gui=prog['no_gui'])
|
|
64 |
prog['pid'].spin(
|
|
65 |
timeout=200,
|
|
66 |
keyword = prog['keyword'],
|
|
67 |
kill_it = False)
|
|
68 |
|
|
69 |
PluginsRoot._Debug(self)
|
|
70 |
|
|
71 |
def _Stop():
|
|
72 |
PluginsRoot._Stop(self)
|
|
73 |
for prog in self.listLaunchProg:
|
|
74 |
self.logger.write("Stopping %s\n" % prog['name'])
|
|
75 |
prog['pid'].kill()
|
|
76 |
|
|
77 |
return _Run, _Stop, _Debug
|
|
78 |
|
|
79 |
self._Run, self._Stop, self._Debug = my_methods(self)
|