author | lbessard |
Fri, 22 Aug 2008 13:34:58 +0200 | |
changeset 213 | d8dc1e51c3bf |
parent 170 | acc6a61c493c |
permissions | -rw-r--r-- |
170
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
1 |
logger.write_error("Welcome to the Beremiz Demo\n\n") |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
2 |
logger.write("This demo provides a PLC working with the CANopen plugin\n") |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
3 |
logger.write("""Some external programs are also provided:\n |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
4 |
- a CAN TCP server to simulate the CANopen network |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
5 |
- a virtual slave node to simulate input block |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
6 |
- a virtual slave node to simulate output block |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
7 |
""") |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
8 |
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")) |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
9 |
#open_pdf(os.path.join(os.path.split(__file__)[0], "doc", "manual_beremiz.pdf"), pagenum=21) |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
10 |
|
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
11 |
if wx.Platform == '__WXMSW__': |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
12 |
self.listLaunchProg = [ |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
13 |
{'name' : 'Can Tcp Server', |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
14 |
'command' : 'can_tcp_win32_server.exe', |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
15 |
'keyword' : 'Accepts', |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
16 |
'pid' : None, |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
17 |
'no_gui' : True}, |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
18 |
{'name' : 'DS401 Slave Gui NodeId 32', |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
19 |
'command' : 'DS401_Slave_Gui.exe -sI -l can_tcp_win32.dll -b 127.0.0.1 -i 20 -B 125K', |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
20 |
'keyword' : '[OK]', |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
21 |
'pid' : None, |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
22 |
'no_gui' : False}, |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
23 |
{'name' : 'DS401 Slave Gui NodeId 16', |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
24 |
'command' : 'DS401_Slave_Gui.exe -sO -l can_tcp_win32.dll -b 127.0.0.1 -i 10 -B 125K', |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
25 |
'keyword' : '[OK]', |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
26 |
'pid' : None, |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
27 |
'no_gui' : False} |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
28 |
] |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
29 |
else: |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
30 |
self.listLaunchProg = [ |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
31 |
{'name' : 'DS401 Slave Gui NodeId 32', |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
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', |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
33 |
'keyword' : '[OK]', |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
34 |
'pid' : None, |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
35 |
'no_gui' : False}, |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
36 |
{'name' : 'DS401 Slave Gui NodeId 16', |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
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', |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
38 |
'keyword' : '[OK]', |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
39 |
'pid' : None, |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
40 |
'no_gui' : False} |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
41 |
] |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
42 |
|
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
43 |
|
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
44 |
def my_methods(self): |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
45 |
def _Run(logger): |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
46 |
# External programs list |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
47 |
# Launch them and get their pid |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
48 |
for prog in self.listLaunchProg: |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
49 |
logger.write("Starting %s\n" % prog['name']) |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
50 |
prog['pid'] = ProcessLogger(logger, prog['command'], no_gui=prog['no_gui']) |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
51 |
prog['pid'].spin( |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
52 |
timeout=200, |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
53 |
keyword = prog['keyword'], |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
54 |
kill_it = False) |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
55 |
|
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
56 |
PluginsRoot._Run(self,logger) |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
57 |
|
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
58 |
def _Stop(logger): |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
59 |
PluginsRoot._Stop(self,logger) |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
60 |
for prog in self.listLaunchProg: |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
61 |
logger.write("Stopping %s\n" % prog['name']) |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
62 |
prog['pid'].kill() |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
63 |
|
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
64 |
return _Run, _Stop |
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
65 |
|
acc6a61c493c
Moved DS401 Slave Gui based demo to test_master_DS401GUI. test_master is now a pure simple master, supposed to work with test_slave.
etisserant
parents:
diff
changeset
|
66 |
self._Run, self._Stop = my_methods(self) |