-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartCRED2
executable file
·199 lines (129 loc) · 4.08 KB
/
startCRED2
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/bin/bash
# CRED2 camera startup script
# number of arguments to script
NBARGS=1
# ======================= PROCESS NAME =================================
pname=`basename "$0"`
EDTCONFFILE="/home/scexao/src/hardw-cred2/config/cred2_FGSetup_14bit.cfg"
SRCDIR="/home/scexao/src/hardw-cred2/src"
function printHELP {
echo "------------------------------------------------------------------------"
echo "$(tput bold) $pname : CRED2 CAMERA STARTUP SCRIPT $(tput sgr0)"
echo " Full path name: $0"
echo "------------------------------------------------------------------------"
echo " Start processes for CRED2 camera acquisition (server and acquisition)"
echo " Processes are running in tmux sessions"
echo " "
echo " $(tput bold)USAGE:$(tput sgr0)"
echo " $0 [-hHLNCc] <CAM number>"
echo ""
echo " $(tput bold)OPTIONS:$(tput sgr0)"
echo " $(tput bold)-h$(tput sgr0) help"
echo ""
echo " $(tput bold)INPUT:$(tput sgr0)"
echo " <CAM number> camera number (0 or 1)"
echo ""
echo "------------------------------------------------------------------------"
}
printHELP1 ()
{
printf "%20s CRED2 camera startup script\n" "$0"
}
EXITSTATUS=0
function checkFile {
if [ -f $1 ]
then
echo "[$(tput setaf 2)$(tput bold) OK $(tput sgr0)] File $(tput bold)$1$(tput sgr0) found"
else
echo "[$(tput setaf 1)$(tput bold) FAILED $(tput sgr0)] File $(tput bold)$1$(tput sgr0) not found"
EXITSTATUS=1
fi
}
function checkDir {
if [ -d $1 ]
then
echo "[$(tput setaf 2)$(tput bold) OK $(tput sgr0)] Directory $(tput bold)$1$(tput sgr0) found"
else
echo "[$(tput setaf 1)$(tput bold) FAILED $(tput sgr0)] Directory $(tput bold)$1$(tput sgr0) not found"
EXITSTATUS=1
fi
}
function cmdexists()
{
command -v "$1" >/dev/null 2>&1
}
function checkCommand {
if cmdexists $1; then
echo "[$(tput setaf 2)$(tput bold) OK $(tput sgr0)] Command $(tput bold)$1$(tput sgr0) found"
else
echo "[$(tput setaf 1)$(tput bold) FAILED $(tput sgr0)] Command $(tput bold)$1$(tput sgr0) not installed. Aborting."; EXITSTATUS=1;
fi
}
# ================= OPTIONS =============================
# Transform long options to short ones
singlelinehelp=0
for arg in "$@"; do
shift
case "$arg" in
"--help") set -- "$@" "-h" ;;
"--help1")
set -- "$@" "-h"
singlelinehelp=1;
;;
*) set -- "$@" "$arg"
esac
done
while getopts :hH:L:N:Cc FLAG; do
case $FLAG in
h) #show help
if [ "$singlelinehelp" -eq "0" ]; then
printHELP
else
printHELP1
fi
exit
;;
\?) #unrecognized option - show help
echo -e \\n"Option -${BOLD}$OPTARG${NORM} not allowed."
printHELP
;;
esac
done
shift $((OPTIND-1)) #This tells getopts to move on to the next argument.
### End getopts code ###
if [ "$1" = "help" ] || [ "$#" -ne $NBARGS ]; then
if [ "$#" -ne $NBARGS ]; then
echo "$(tput setaf 1)$(tput bold) Illegal number of parameters ($NBARGS params required, $# entered) $(tput sgr0)"
fi
printHELP
exit
fi
# ======================= CHECK REQUIRED FILES =================================
echo ""
checkFile ${EDTCONFFILE}
# ============================= CHECK IF COMMAND EXISTS ==========================
checkCommand tmux
if [ $EXITSTATUS -eq 1 ]; then
echo ""
echo "$(tput setaf 1)$(tput bold) REQUIRED FILES, COMMANDS NOT FOUND: EXITING $(tput sgr0)"
echo ""
exit
else
echo ""
fi
# ======================= SCRIPT CODE STARTS HERE =================================
unit="$1"
echo "STARTING CRED2 CAMERA UNIT $unit"
/opt/EDTpdv/initcam -c 0 -u $unit -f ${EDTCONFFILE}
tmux new-session -d -s ircam${unit}ctrl
tmux new-session -d -s ircam${unit}run
tmux send-keys -t ircam${unit}ctrl "" C-c
tmux send-keys -t ircam${unit}ctrl "" C-c
tmux send-keys -t ircam${unit}run "" C-c
tmux send-keys -t ircam${unit}run "" C-c
tmux send-keys -t ircam${unit}ctrl "cd ${SRCDIR}" C-m
tmux send-keys -t ircam${unit}run "cd ${SRCDIR}" C-m
sleep 0.5
tmux send-keys -t ircam${unit}ctrl "./ircamserver -u ${unit}" C-m
tmux send-keys -t ircam${unit}ctrl "setcrop 0" C-m
#tmux send-keys -t ircam0ctrl "start" C-m