added optional ?voltage
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 7 Jan 2021 14:01:54 +0000 (15:01 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 7 Jan 2021 14:01:54 +0000 (15:01 +0100)
gnuplot/template.gnuplot
gnuplot/template.sql
www/cgi-bin/template.cgi
www/index.html

index 0a8e7c6..3038cf7 100644 (file)
@@ -27,7 +27,11 @@ set yrange [ -0.2 : 0.2 ]
 #set arrow 1 from first,3 to last,3 nohead linestyle rgb "#ff0000"
 
 #set multiplot
-set multiplot layout 3,1
+if ( voltage ) {
+       set multiplot layout 4,1
+} else {
+       set multiplot layout 3,1
+}
 
 set lmargin at screen 0.125
 
@@ -52,11 +56,23 @@ plot "axes.txt" using 1:3:(abs($3) < 0.2 ? 2: 99) with lines lc variable notitle
 
 set tmargin 0
 
-set xlabel "time"
-set format x "%H:%M\n%d.%m."
+if ( ! voltage ) {
+       set xlabel "time"
+       set format x "%H:%M\n%d.%m."
+}
 
 set ylabel "celsius"
 set yrange [ * : * ]
 
 plot "axes.txt" using 1:4 with lines lc 'blue' notitle
 
+if ( voltage ) {
+       set xlabel "time"
+       set format x "%H:%M\n%d.%m."
+
+       set ylabel "V"
+       set ytics 0.1 
+
+       plot "axes.txt" using 1:5 with dots lc 'red' notitle
+
+}
index 1677f97..4f90e9e 100644 (file)
@@ -1,4 +1,4 @@
-select to_char(time, 'YYYY-MM-DD HH24:MI:SS'), x_axis_angle, y_axis_angle, sensor_temperature
+select to_char(time, 'YYYY-MM-DD HH24:MI:SS'), x_axis_angle, y_axis_angle, sensor_temperature, power_source_voltage
 from zc
 where pn = 2008050087 -- and time > now() - interval '24 hours'
 order by time asc 
index 5d157c3..d4652a3 100755 (executable)
@@ -18,10 +18,14 @@ gnuplot_sed='';
 yrange=$( echo $QUERY_STRING | grep '^yrange=[0-9]*\.[0-9]*$' | cut -d= -f2 )
 test -z "$yrange" && yrange=0.2
 
+voltage=0
+echo $HTTP_REFERER | grep -q voltage && voltage=1
+echo $QUERY_STRING | grep -q voltage && voltage=1
+
 set > /dev/shm/$pn.env
 
 cat $dir/template.sql | sed -e "s/2008050087/$pn/" -e "s/x_axis_angle/x_axis_angle + $offset_x/" -e "s/y_axis_angle/y_axis_angle + $offset_y/" | psql --username=dpavlin -A -F "," -t zc > /dev/shm/$pn.txt
 cat $dir/template.gnuplot | sed -e "s,axes.txt,/dev/shm/$pn.txt," -e "s,^set terminal.*$,set terminal svg," -e "s,^set output.*$,set output," -e "s,-0.2 : 0.2,-$yrange : $yrange," > /dev/shm/$pn.gnuplot
-gnuplot /dev/shm/$pn.gnuplot
+gnuplot -e "voltage=$voltage" /dev/shm/$pn.gnuplot
 
 #rm /dev/shm/axes.txt.$$ /dev/shm/axes.gnuplot.$$
index 254f74f..a5ade47 100644 (file)
                <li><a href="demo1.html">Demo 1</a></li>
                <li><a href="demo2.html">Demo 2</a></li>
                <li><a href="demo3.html">Demo 3</a></li>
-               <li><a href="rijeka.html">Rijeka</a></li>
+               <li><a href="rijeka.html">Rijeka</a> <a href="rijeka.html?voltage">[voltage]</a></li>
                <li><a href="vg5-rijeka.html">VG5 Rijeka</a></li>
                <li><a href="rijeka-by_day.html">Rijeka svakih sat vremena</a></li>
                <li><a href="rijeka-by_temp.html">Rijeka temperatura po opsezima, dnevno</a></li>
-               <li><a href="sviz.html">Sv. Ivan Zelina - crkveni toranj</a></li>
+               <li><a href="sviz.html">Sv. Ivan Zelina - crkveni toranj</a> <a href="sviz.html?voltage">[voltage]</a></li>
        </ul>
 
        <br>