#!/bin/sh

LISTFILES=$@


plot()
{
TITLE=$(echo $1|sed "s/dwtlog.\(....\)\(..\)\(..\)/Temperatura \3\/\2\/\1/")
(cat <<EOF
set terminal png
set output "png/$2"
set title "$TITLE"
set ylabel "Temperatura (Grados Celsius)"
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 1
#plot [0:240000] [] "$1" u 1:2 title 'Temp. Interior' w l, "$1" u 1:4 title 'Temp. Exterior' w l
plot [0:240000] [] "$1" u 1:4 title 'Temperatura' w l, "$1" u 1:6 title 'Punto de Rocío' w l

EOF
) |gnuplot
}

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



