Skip to content

Commit

Permalink
attempt to synchronize pump clock if it's more than 10s off
Browse files Browse the repository at this point in the history
  • Loading branch information
scottleibrand committed May 8, 2017
1 parent 89fff77 commit 8364c08
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bin/oref0-pump-loop.sh
Expand Up @@ -75,6 +75,13 @@ function smb_reservoir_before {
&& echo -n "pumphistory.json: " && cat monitor/pumphistory.json | jq -C .[0]._description \
&& echo -n "Checking pump clock: " && (cat monitor/clock-zoned.json; echo) | tr -d '\n' \
&& echo -n " is within 1m of current time: " && date \
&& if ! ( (( $(bc <<< "$(date +%s -d $(cat monitor/clock-zoned.json | sed 's/"//g')) - $(date +%s)") > -10 )) \
&& (( $(bc <<< "$(date +%s -d $(cat monitor/clock-zoned.json | sed 's/"//g')) - $(date +%s)") < 10 )) ); then
echo "WARNING: pump clock does not match rig clock. Attempting to synchronize pump clock."
oref0-set-device-clocks
echo -n "Pump clock: "; (cat monitor/clock-zoned.json; echo) | tr -d '\n'
echo -n "; rig clock: "; date
fi \
&& (( $(bc <<< "$(date +%s -d $(cat monitor/clock-zoned.json | sed 's/"//g')) - $(date +%s)") > -60 )) \
&& (( $(bc <<< "$(date +%s -d $(cat monitor/clock-zoned.json | sed 's/"//g')) - $(date +%s)") < 60 )) \
&& echo -n "and that pumphistory is less than 1m old. " \
Expand Down

0 comments on commit 8364c08

Please sign in to comment.