-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartCRED1
executable file
·190 lines (124 loc) · 3.79 KB
/
startCRED1
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
#!/bin/bash
# CRED1 camera startup script
# number of arguments to script
NBARGS=0
FGUNIT=1
# ======================= PROCESS NAME =================================
pname=`basename "$0"`
SRCDIR="/home/scexao/src/cred1"
EDTCONFFILE="${SRCDIR}/bin/cred1_FGSetup_16bit.cfg"
function printHELP {
echo "------------------------------------------------------------------------"
echo "$(tput bold) $pname : CRED1 CAMERA STARTUP SCRIPT $(tput sgr0)"
echo " Full path name: $0"
echo "------------------------------------------------------------------------"
echo " Start processes for CRED1 camera acquisition (server and acquisition)"
echo " Processes are running in tmux sessions"
echo " "
echo " $(tput bold)USAGE:$(tput sgr0)"
echo " $0 [-hHLNCc]"
echo ""
echo " $(tput bold)OPTIONS:$(tput sgr0)"
echo " $(tput bold)-h$(tput sgr0) help"
echo ""
echo "------------------------------------------------------------------------"
}
printHELP1 ()
{
printf "%20s CRED1 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 =================================
echo "STARTING CRED1 CAMERA UNIT $FGUNIT"
/opt/EDTpdv/initcam -c 0 -u $FGUNIT -f ${EDTCONFFILE}
tmux new-session -d -s cred1ctrl
tmux new-session -d -s cred1acqu
tmux send-keys -t cred1ctrl "" C-c
tmux send-keys -t cred1ctrl "" C-c
tmux send-keys -t cred1acqu "" C-c
tmux send-keys -t cred1acqu "" C-c
tmux send-keys -t cred1ctrl "cd ${SRCDIR}/bin" C-m
tmux send-keys -t cred1acqu "cd ${SRCDIR}/bin" C-m
sleep 0.5
tmux send-keys -t cred1ctrl "./cred1ctrl" C-m