#!/bin/sh

LISTFILES=$@


plot()
{
TITLE=$(echo $1|sed "s/dwtlog.\(....\)\(..\)\(..\)/Humedad \3\/\2\/\1/")
(cat <<EOF
set terminal png
set output "png/$2"
set title "$TITLE"
set ylabel "Humedad (%)"
set xlabel "Tiempo (Hora Local Argentina)"
set grid
set xtics ("00" 000000, "01" 010000, "02" 020000, "03" 030000, "04" 040000, "05" 050000, "06" 060000, "07" 070000, "08" 080000, "09" 090000, "10" 100000, "11" 110000, "12" 120000, "13" 130000, "14" 140000, "15" 150000, "16" 160000, "17" 170000, "18" 180000, "19" 190000, "20" 200000, "21" 210000, "22" 220000, "23" 230000, "24" 240000) 
set ytics 10
#plot [0:240000] [0:100] "$1" u 1:3 title 'Hum. Interior' w l, "$1" u 1:5 title 'Hum. Exterior' w l
plot [0:240000] [0:100] "$1" u 1:5 notitle w l

EOF
) |gnuplot
}

for f in ${@}; do
    OUTPUT=$(echo $f|sed "s/dwtlog.\([0-9]*\)/hum_\1.png/")
    if [ ! -f $OUTPUT ];then
	plot $f $OUTPUT
    fi
done;


