-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_db.sh
More file actions
executable file
·101 lines (85 loc) · 2.12 KB
/
create_db.sh
File metadata and controls
executable file
·101 lines (85 loc) · 2.12 KB
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
#!/bin/bash
# Parameters
N_PV_10Hz=150
N_PV_5Hz=0
N_PV_1Hz=0
SHOW_PLOT=false
Help()
{
echo " ************************************************************************ "
echo " Script to run create performance test EPICS .db file "
echo " - Usage:"
echo " ./create_db.sh <options...>"
echo " options:"
echo " -h | --help: display this help message"
echo " -n | --nrepeats: [optional] number of repeats. If not "
echo " provided then default is 1."
echo " E.g."
echo " ./create_db.sh"
echo " ./create_db.sh -n 2"
echo " ************************************************************************ "
}
VALID_ARGS=$(getopt -o hn: --long help,nrepeats:, -- "$@")
if [[ $? -ne 0 ]]; then
exit 1;
fi
eval set -- "$VALID_ARGS"
while [ : ]; do
case "$1" in
-h | --help)
Help
exit 1
;;
-n | --nrepeats)
N_REPEATS="$2"
shift 2
;;
--) shift;
break
;;
esac
done
if [ -z $N_REPEATS ]; then
N_REPEATS=1
fi
N_PVS=$(($N_PV_10Hz+$N_PV_5Hz+$N_PV_1Hz))
# Setup: create db file for EPICS
echo "-> Creating EPICS db with $N_PVS PVs:"
echo " $N_PV_10Hz @ 10Hz,"
echo " $N_PV_5Hz @ 5Hz,"
echo " $N_PV_1Hz @ 1Hz"
# Empty file
echo "" >performanceTestDbCustom.db
for ((i=0;i<$N_PVS;i++))
do
record_name="TEST:REC$i"
RATE=".1 second"
MAX=9
OFFSET=0
if [[ $i -ge $(($N_PV_10Hz+$N_PV_5Hz)) ]]; then
RATE="1 second"
OFFSET=100
elif [[ $i -ge $(($N_PV_10Hz)) ]]; then
RATE=".5 second"
OFFSET=10
fi
cat <<EOF
record(calcout, "$record_name")
{
field(DESC, "Performance test record")
field(SCAN, "$RATE")
field(A, "$OFFSET")
field(CALC, "A == ($OFFSET+$MAX) ? $OFFSET : A+1")
field(OUT, "$record_name.A")
}
EOF
done >>performanceTestDbCustom.db
if $if $SHOW_PLOT; then
echo '
record(waveform, "TEST:ARR'$repeat'")
{
field(DESC, "Performance test record")
field(NELM,"3000")
field(FTVL, "SHORT")
}' >>performanceTestDbCustom.db
fi