added rijeka, fixed y axes, offset to 0
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 9 Oct 2020 11:29:47 +0000 (13:29 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 9 Oct 2020 11:29:47 +0000 (13:29 +0200)
gnuplot/offset.txt [new file with mode: 0644]
gnuplot/template.gnuplot [new file with mode: 0644]
gnuplot/template.sql [new file with mode: 0644]
www/cgi-bin/template.cgi [new file with mode: 0755]
www/index.html
www/rijeka.html [new file with mode: 0644]

diff --git a/gnuplot/offset.txt b/gnuplot/offset.txt
new file mode 100644 (file)
index 0000000..14011f4
--- /dev/null
@@ -0,0 +1,9 @@
+2008050077 0.14648342520240845 0.4419172473160959
+2008050078 -0.26737614827496664 0.6446930067879814
+2008050079 0.24542222714170497 -0.24910957521580634
+2008050080 -0.47140570481618244 -0.5059835244331682
+2008050082 -0.17280303359031676 0.3452259429693222
+2008050083 -0.5107064163389284 -0.5597924875818994
+2008050084 0.4263695485737859 -0.44388545593436884
+2008050086 -0.024463149181877572 0.47625536262989043
+2008050087 0.1922562310937565 0.09658566782050464
diff --git a/gnuplot/template.gnuplot b/gnuplot/template.gnuplot
new file mode 100644 (file)
index 0000000..8768927
--- /dev/null
@@ -0,0 +1,46 @@
+set terminal pngcairo color size 800,600
+#set output 'axes.png'
+set output
+
+set xdata time
+set timefmt "%Y-%m-%d %H:%M:%S"
+
+set datafile separator ","
+
+#unset border
+#set key outside
+#set key top left horizontal
+
+set grid
+set key outside tmargin center
+
+#set ylabel "°"
+#set ylabel "deg."
+set ylabel "degrees"
+
+set format x "%H:%M"
+#set format y "%.2f"
+set yrange [ -0.1 : 0.1 ]
+
+#set arrow 1 from first,3 to last,3 nohead linestyle rgb "#ff0000"
+
+set multiplot
+set size 1,0.5
+set origin 0, 0.5
+
+#set linetype 1 lc 'green'
+set linetype 99 lc 'red'
+
+#plot "axes.txt" using 1:2 with lines title "X angle", "" using 1:(3) with dots notitle, "" using 1:(-3) with dots notitle
+
+plot "axes.txt" using 1:2:(abs($2) < 3 ? 1: 99) with lines lc variable title "X angle"
+# http://gnuplot-surprising.blogspot.com/2011/09/gnuplot-background-image.html
+#'/home/dpavlin/zc/www/logo-color.png' binary filetype=png origin=(0,0)  dx=0.5 dy=0.5 with rgbimage notitle
+
+set origin 0, 0
+
+set xlabel "time"
+#plot "axes.txt" using 1:3 with lines title "Y angle", "" using 1:(3) with dots notitle, "" using 1:(-3) with dots notitle
+
+plot "axes.txt" using 1:3:(abs($3) < 3 ? 2: 99) with lines lc variable title "Y angle"
+#, "" using 1:(3) with dots notitle, "" using 1:(-3) with dots notitle
diff --git a/gnuplot/template.sql b/gnuplot/template.sql
new file mode 100644 (file)
index 0000000..87596cb
--- /dev/null
@@ -0,0 +1,5 @@
+select to_char(time, 'YYYY-MM-DD HH24:MI:SS'), x_axis_angle, y_axis_angle
+from zc
+where pn = 2008050087 -- and time > now() - interval '24 hours'
+order by time asc 
+
diff --git a/www/cgi-bin/template.cgi b/www/cgi-bin/template.cgi
new file mode 100755 (executable)
index 0000000..d2d22d3
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+dir=/home/dpavlin/zc/gnuplot/
+
+echo "Content-type: image/svg+xml"
+echo
+
+pn=$( basename $0 | sed 's/.cgi//' )
+offset=$( grep "^$pn" $dir/offset.txt )
+offset_x=$( echo $offset | cut -d' ' -f2 )
+offset_y=$( echo $offset | cut -d' ' -f3 )
+
+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," > /dev/shm/$pn.gnuplot
+gnuplot /dev/shm/$pn.gnuplot
+
+#rm /dev/shm/axes.txt.$$ /dev/shm/axes.gnuplot.$$
index e6ab246..b59c7a3 100644 (file)
@@ -11,6 +11,7 @@
                <li><a href="demo1.html">Demo 1</a></li>
                <li><a href="demo2.html">Demo 2</a></li>
                <li><a href="864823042077016.html">Demo 3</a></li>
+               <li><a href="rijeka.html">Rijeka</a></li>
        </ul>
 
        <br>
diff --git a/www/rijeka.html b/www/rijeka.html
new file mode 100644 (file)
index 0000000..247d3d8
--- /dev/null
@@ -0,0 +1,34 @@
+<html>
+<head>
+       <meta charset="utf-8" />
+       <title>Rijeka - senzori nagiba</title>
+</head>
+<body>
+
+       <p>
+       <img src="logo-color.png">
+
+       <h1>201-000115</h1>
+       <img src="cgi-bin/2008050082.cgi" width="100%">
+
+       <h1>201-000116</h1>
+       <img src="cgi-bin/2008050080.cgi" width="100%">
+
+       <h1>201-000117</h1>
+       <img src="cgi-bin/2008050078.cgi" width="100%">
+
+       <h1>201-000118</h1>
+       <img src="cgi-bin/2008050083.cgi" width="100%">
+
+       <h1>201-000119</h1>
+       <img src="cgi-bin/2008050084.cgi" width="100%">
+
+       <h1>201-000120</h1>
+       <img src="cgi-bin/2008050079.cgi" width="100%">
+
+
+
+
+       </p>
+
+</body>