forked from yimuchen/SiPMCalibControl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrol.py
executable file
·82 lines (73 loc) · 2.18 KB
/
control.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
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python3
import ctlcmd.cmdbase as cmdbase
import ctlcmd.motioncmd as motioncmd
import ctlcmd.getset as getset
import ctlcmd.digicmd as digicmd
import ctlcmd.viscmd as viscmd
import ctlcmd.picocmd as picocmd
import cmod.logger as logger
import copy
import sys
if __name__ == '__main__':
cmd = cmdbase.controlterm([
motioncmd.moveto,
motioncmd.movespeed,
motioncmd.halign,
motioncmd.zscan,
motioncmd.timescan,
motioncmd.showreadout,
viscmd.visualhscan,
viscmd.visualzscan,
viscmd.visualmaxsharp,
viscmd.visualshowchip,
viscmd.visualcenterchip,
getset.set,
getset.get,
getset.getcoord,
getset.savecalib,
getset.loadcalib,
getset.lighton,
getset.lightoff,
getset.promptaction,
digicmd.pulse,
picocmd.picoset,
picocmd.picorunblock,
picocmd.picorange,
])
"""
Duplicating the session to allow for default override.
"""
# Weird bug in python 3.4 that doesn't allow deepcopy of argparser
prog_parser = copy.deepcopy(cmd.set.parser)
# Augmenting help messages
prog_parser.prog = "control.py"
prog_parser.add_argument('-h',
'--help',
action='store_true',
help='print help message and exit')
## Using map to store Default values:
default_overide = {
'-printerdev': '/dev/ttyUSB0',
'-camdev': '/dev/video0',
#'-boardtype': 'cfg/static_calib.json',
'-action': 'cfg/useractions.json',
'-picodevice': 'MYSERIAL', #Cannot actually set. Just dummy for now
#'-remotehost' : ['hepcms.umd.edu', '']
}
for action in prog_parser._actions:
for option, default in default_overide.items():
if option in action.option_strings:
action.default = default
args = prog_parser.parse_args()
if args.help:
prog_parser.print_help()
sys.exit(0)
try:
cmd.set.run(args)
cmd.trigger.init()
except Exception as err:
logger.printerr(str(err))
logger.printwarn(
'There was error in the setup process, program will '
'continue but will most likely misbehave! Use at your own risk!')
cmd.cmdloop()