Voltage monitoring script for iseg high voltage module
The HV monitoring script for iseg using API. (Created by Yano-san from Kyoto University)
Script to output “Measured Voltage” in “Unixtime.txt”.
For apikey, the sections for user and password need to be modified.
#!/bin/bash
apikey=`curl http://hvws2-gp:8081/api/login/"user"/"password"`
echo $apikey
fname=`date +'%s'`
curl -o data/$fname.txt http://hvws2-gp:8081/api/getItem/$apikey/0/0/*/Status.voltageMeasureScript to monitor voltage.
jq and festival are required.
The contents of “Unixtime.txt” are in JSON format.
Set the value with vset.
Set the variation with vrange.
If there’s an anomaly, it will notify with an audible alert.
#!/bin/bash
latestdat=`ls ./data | tail -n 1`
echo $latestdat
vset=(-2100.0 -2100.0 -2200.0 -2200.0 -2200.0 -2200.0)
vrange=5.0
jsonbody=`cat data/$latestdat`
for i in `seq 0 5`
do
v=`echo $jsonbody | jq -r ".[].c[$i].d.v"`
echo $i: $v
vtest=`echo "$v-1*${vset[$i]}<-$vrange||$v-1*${vset[$i]}>$vrange" | bc -l`
echo $vtest
if [[ "$vtest" -eq "1" ]]; then
echo "Check voltage!" | festival --tts
fi
doneCommand to run the script at 30-second intervals.
watch -n 30 "shell_script_filename"