#!/bin/bash

#day=$(date +%Y%m%d)
prev_day=$(printf "%(%Y%m%d)T\n" $(( $(printf "%(%s)T") + 30 * 60 )))
day=$(printf "%(%Y%m%d)T\n" $(( $(printf "%(%s)T") + 120 * 60 )))

if [ "$#" -eq 1 ] ; then
        day="$1"
        prev_day="$1"
fi
echo "Generowanie rysunkow z $day"
python3 graph_das.py --24h --lim=24:108 --conv=auto --path=348/mic0 --file-filter="$day" --file-name="imgen/348_mic0_$day.png"
python3 graph_das.py --24h --lim=24:108 --conv=auto --path=421/mic0 --file-filter="$day" --file-name="imgen/421_mic0_$day.png"
python3 graph_das.py --24h --lim=24:108 --conv=auto --path=425/mic0 --file-filter="$day" --file-name="imgen/425_mic0_$day.png"
python3 graph_das.py --24h --lim=24:108 --conv=107.00 --path=423/mic0 --file-filter="$day" --file-name="imgen/423_mic0_$day.png"
python3 graph_das.py --24h --lim=24:108 --conv=107.00 --path=423/mic1 --file-filter="$day" --file-name="imgen/423_mic1_$day.png"
python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5001/mic0 --file-filter="$day" --file-name="imgen/5001_mic0_$day.png"
python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5002/mic0 --file-filter="$day" --file-name="imgen/5002_mic0_$day.png"
python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5004/mic0 --file-filter="$day" --file-name="imgen/5004_mic0_$day.png"
python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5005/mic0 --file-filter="$day" --file-name="imgen/5005_mic0_$day.png"
python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5006/mic0 --file-filter="$day" --file-name="imgen/5006_mic0_$day.png"

python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5008/mic0 --file-filter="$day" --file-name="imgen/5008_mic0_$day.png"
python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5009/mic0 --file-filter="$day" --file-name="imgen/5009_mic0_$day.png"
python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5010/mic0 --file-filter="$day" --file-name="imgen/5010_mic0_$day.png"
python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5011/mic0 --file-filter="$day" --file-name="imgen/5011_mic0_$day.png"
python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5012/mic0 --file-filter="$day" --file-name="imgen/5012_mic0_$day.png"
python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5013/mic0 --file-filter="$day" --file-name="imgen/5013_mic0_$day.png"

python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5014/mic0 --file-filter="$day" --file-name="imgen/5014_mic0_$day.png"

echo "Kopiowanie rysunkow"
cp "imgen/348_mic0_$day.png" /store/audio-web/html/img/.
cp "imgen/421_mic0_$day.png" /store/audio-web/html/img/.
cp "imgen/425_mic0_$day.png" /store/audio-web/html/img/.
cp "imgen/423_mic0_$day.png" /store/audio-web/html/img/.
cp "imgen/423_mic1_$day.png" /store/audio-web/html/img/.
cp "imgen/5001_mic0_$day.png" /store/audio-web/html/img/.
cp "imgen/5002_mic0_$day.png" /store/audio-web/html/img/.
cp "imgen/5004_mic0_$day.png" /store/audio-web/html/img/.
cp "imgen/5005_mic0_$day.png" /store/audio-web/html/img/.
cp "imgen/5006_mic0_$day.png" /store/audio-web/html/img/.

cp "imgen/5008_mic0_$day.png" /store/audio-web/html/img/.
cp "imgen/5009_mic0_$day.png" /store/audio-web/html/img/.
cp "imgen/5010_mic0_$day.png" /store/audio-web/html/img/.
cp "imgen/5011_mic0_$day.png" /store/audio-web/html/img/.
cp "imgen/5012_mic0_$day.png" /store/audio-web/html/img/.
cp "imgen/5013_mic0_$day.png" /store/audio-web/html/img/.

cp "imgen/5014_mic0_$day.png" /store/audio-web/html/img/.

if [ "$prev_day" -ne "$day" ] ; then
	echo "Generowanie rysunkow z $prev_day"
	python3 graph_das.py --24h --lim=24:108 --conv=auto --path=348/mic0 --file-filter="$prev_day" --file-name="imgen/348_mic0_$prev_day.png"
	python3 graph_das.py --24h --lim=24:108 --conv=auto --path=421/mic0 --file-filter="$prev_day" --file-name="imgen/421_mic0_$prev_day.png"
	python3 graph_das.py --24h --lim=24:108 --conv=auto --path=425/mic0 --file-filter="$prev_day" --file-name="imgen/425_mic0_$prev_day.png"
	python3 graph_das.py --24h --lim=24:108 --conv=107.00 --path=423/mic0 --file-filter="$prev_day" --file-name="imgen/423_mic0_$prev_day.png"
	python3 graph_das.py --24h --lim=24:108 --conv=107.00 --path=423/mic1 --file-filter="$prev_day" --file-name="imgen/423_mic1_$prev_day.png"
	python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5001/mic0 --file-filter="$prev_day" --file-name="imgen/5001_mic0_$prev_day.png"
	python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5002/mic0 --file-filter="$prev_day" --file-name="imgen/5002_mic0_$prev_day.png"
	python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5004/mic0 --file-filter="$prev_day" --file-name="imgen/5004_mic0_$prev_day.png"
	python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5005/mic0 --file-filter="$prev_day" --file-name="imgen/5005_mic0_$prev_day.png"
	python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5006/mic0 --file-filter="$prev_day" --file-name="imgen/5006_mic0_$prev_day.png"

	python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5008/mic0 --file-filter="$prev_day" --file-name="imgen/5008_mic0_$prev_day.png"
	python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5009/mic0 --file-filter="$prev_day" --file-name="imgen/5009_mic0_$prev_day.png"
	python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5010/mic0 --file-filter="$prev_day" --file-name="imgen/5010_mic0_$prev_day.png"
	python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5011/mic0 --file-filter="$prev_day" --file-name="imgen/5011_mic0_$prev_day.png"
	python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5012/mic0 --file-filter="$prev_day" --file-name="imgen/5012_mic0_$prev_day.png"
	python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5013/mic0 --file-filter="$prev_day" --file-name="imgen/5013_mic0_$prev_day.png"

	python3 graph_das.py --24h --lim=24:108 --conv=auto --path=5014/mic0 --file-filter="$prev_day" --file-name="imgen/5014_mic0_$prev_day.png"

	echo "Kopiowanie rysunkow"
	cp "imgen/348_mic0_$prev_day.png" /store/audio-web/html/img/.
	cp "imgen/421_mic0_$prev_day.png" /store/audio-web/html/img/.
	cp "imgen/425_mic0_$prev_day.png" /store/audio-web/html/img/.
	cp "imgen/423_mic0_$prev_day.png" /store/audio-web/html/img/.
	cp "imgen/423_mic1_$prev_day.png" /store/audio-web/html/img/.
	cp "imgen/5001_mic0_$prev_day.png" /store/audio-web/html/img/.
	cp "imgen/5002_mic0_$prev_day.png" /store/audio-web/html/img/.
	cp "imgen/5004_mic0_$prev_day.png" /store/audio-web/html/img/.
	cp "imgen/5005_mic0_$prev_day.png" /store/audio-web/html/img/.
	cp "imgen/5006_mic0_$prev_day.png" /store/audio-web/html/img/.

	cp "imgen/5008_mic0_$prev_day.png" /store/audio-web/html/img/.
	cp "imgen/5009_mic0_$prev_day.png" /store/audio-web/html/img/.
	cp "imgen/5010_mic0_$prev_day.png" /store/audio-web/html/img/.
	cp "imgen/5011_mic0_$prev_day.png" /store/audio-web/html/img/.
	cp "imgen/5012_mic0_$prev_day.png" /store/audio-web/html/img/.
	cp "imgen/5013_mic0_$prev_day.png" /store/audio-web/html/img/.

	cp "imgen/5014_mic0_$prev_day.png" /store/audio-web/html/img/.
fi
echo "Koniec"
printf "%(%Y%m%d_%H%M%S)T\n" $(( $(printf "%(%s)T") + 120 * 60 ))
