Newer
Older
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
#!/bin/bash
#set -u
if [[ -z ${1} ]] ; then
echo " first argument is the previous hcRunSettingAccumulatedCharge "
exit
fi
if [[ -z ${2} ]] ; then
echo " second argument is the previous value of hcRunSettingTIme "
exit
fi
previous_charge=$1
previous_time=$2 # minuites
#caget hcRunSettingAccumulatedCharge
##caget hcRunSettingTime
#
current_charge=$(caget hcRunSettingAccumulatedCharge | awk ' {print $2} ' )
current_time=$( caget hcRunSettingTime | awk ' {print $2} ' )
#echo ${current_charge}
#echo ${current_time}
update_time=$(echo "$current_time + $previous_time * 60" | bc )
update_charge=$(echo "$current_charge + $previous_charge * 1000" | bc )
echo "time $update_time"
echo "charge $update_charge"
function yes_or_no {
while true; do
read -p "$* [y/n]: " yn
case $yn in
[Yy]*) return 0 ;;
[Nn]*) echo "No entered" ; return 1 ;;
esac
done
}
echo " update epics variables?"
yes_or_no && {
caput hcRunSettingAccumulatedCharge $update_charge
#caput hcRunSettingTime $update_time
}