-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtlvoltage.sh
executable file
·58 lines (53 loc) · 1.59 KB
/
tlvoltage.sh
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
#!/bin/bash
#
# tlvoltage.sh
#
# Conversion of the dbg-log file, generated by solarmonitor.awk
# to a ocatave readable array v.dat
#
solog=/tmp/solarmonitor.log
if [ -f "$1" ] ; then
solog=$1
fi
if head -n 300 $solog | grep " re: " > /dev/null ; then
# process a dbg log file
cat $solog | awk '
/ re:/ { if(t0==0) {
t0=$2;
tstr=strftime("%F %T",t0);
print "# " tstr;
split(tstr, ys, "[: -]*", seps);
t00 = t0 - (3600*ys[4] + 60*ys[5] + ys[5]);
}
t=$2;
# t=$2-t0; # option: adjust time to start of recording
# t=$2-t00; # option: adjust time to start of day
}
/ re: sensor/ { # print $4;
split($4, sL, "[^0-9]*", seps);
# print sL[1] " " sL[2] " " sL[3]
}
/ re: sensor.*_v/ {
ii = (sL[2]-1)*3 + sL[3]; # V(t) as octave array
v[ii]=$6;
if(ii==6) {
printf("%12.6f ", t);
for(i=1; i<=ii; i++) {
printf("%8.3f ", v[i]);
}
printf("\n");
}
}
' > v.dat
#tag=$(head -n 1 v.dat | tr -d '#:-' | awk '{ print $1 "_" $2}')
tag=$(head -n 1 v.dat | tr -d '#:-' | awk '{ print $1}')
cp -p v.dat ${tag}_v.dat
cp -p $solog ${tag}_solarmonitor.log
else
for ii in $* ; do
jj=$(echo $ii | sed -e 's/json.*/dat/' | sed -e 's/aggregates/readings/')
echo "processing $ii --> $jj"
# process a json file
./teslogger.sh -e pattern='"date_time\|v_V\|p_W\|q_VAR"' $ii > $jj
done
fi