forked from machinekoder/halanduino
/
rundemo.py
executable file
·73 lines (64 loc) · 2.86 KB
/
rundemo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/python
import sys
import os
import subprocess
import argparse
from time import *
from machinekit import launcher
launcher.register_exit_handler()
os.chdir(os.path.dirname(os.path.realpath(__file__)))
parser = argparse.ArgumentParser(description='This is the motorctrl demo run script '
'it demonstrates how a run script could look like '
'and of course starts the motorctrl demo')
parser.add_argument('-c', '--config', help='Starts the config server', action='store_true')
parser.add_argument('-v', '--video', help='Starts the video server', action='store_true')
parser.add_argument('-l', '--local', help='Enable local mode only', action='store_true')
parser.add_argument('-g', '--gladevcp', help='Starts the GladeVCP user interface', action='store_true')
parser.add_argument('-s', '--halscope', help='Starts the halscope', action='store_true')
parser.add_argument('-m', '--halmeter', help='Starts the halmeter', action='store_true')
parser.add_argument('-w', '--webtalk', help='Starts webtalk', action='store_true')
parser.add_argument('-d', '--debug', help='Enable debug mode', action='store_true')
args = parser.parse_args()
if args.debug:
launcher.set_debug_level(5)
#if not args.local:
# # override default $MACHINEKIT_INI with a version which was REMOTE=1
# launcher.set_machinekit_ini('machinekit.ini')
try:
launcher.check_installation()
launcher.cleanup_session()
launcher.load_bbio_file('halanduino.bbio')
launcher.install_comp('kalman.comp')
launcher.install_comp('hbridge.icomp')
if args.config:
# the point-of-contact for QtQUickVCP
launcher.start_process('configserver -n Motorctrl-Demo .')
if args.webtalk:
# the Websockets/JSON bridge into Machinetalk
launcher.start_process('webtalk --ini motorctrl.ini')
if args.video:
launcher.start_process('videoserver --ini video.ini Webcam1')
launcher.start_realtime()
# launcher.load_hal_file('hardware.hal', 'hardware.ini')
# launcher.load_hal_file('halanduino.hal', 'halanduino.ini')
# launcher.load_hal_file('threading.hal', 'halanduino.ini')
import hardware
if args.gladevcp:
# start the gladevcp version
if args.local:
# no -N flag - local case, use IPC sockets, no zeroconf resolution
launcher.start_process('gladevcp -E -u motorctrl.py motorctrl.ui')
else:
# -N - remote case, use zeroconf resolution
launcher.start_process('gladevcp -N -E -u motorctrl.py motorctrl.ui')
if args.halscope:
# load scope only now - because all sigs are now defined:
launcher.start_process('halscope')
if args.halmeter:
launcher.start_process('halmeter')
except subprocess.CalledProcessError:
launcher.end_session()
sys.exit(1)
while True:
sleep(1)
launcher.check_processes()