ADDRESS_socat=TCP:192.168.2.220:10001
DAS=01 02 03 04 05
#kanal 7 je mimo provoz
DAS_=01 02 08 09


arming:
	echo -e -n $$"\x2A\x61\x00\x05\xfe\x02\x78\xf7\x0d"|socat -u - $(ADDRESS_socat);sleep 1; socat -T 0.5 -u  $(ADDRESS_socat)  /dev/null

acquisition:
	rm -f PapouchSt*
	for i in $(DAS); do rm -f pool; echo DAS Papouch $$i;for j in `seq 1 10`; do make getdata IP=220 ADDRESS="$${i}_$${j}" CHAN=$$i ;done; awk '{print NR-1"E-6\t" $$1}' pool > PapouchSt_$$i;echo $$i;sleep 1s;done
	make graphs
	make html
	paste `for i in $(DAS); do echo PapouchSt_$$i; done` > matrice 



getdata:
	socat -u commstrings/getdata$(ADDRESS) $(ADDRESS_socat); socat  -u $(ADDRESS_socat),readbytes=8199 STDOUT |  od  -j 7 -v -A n -s -w2 |LC_ALL=C awk '{print  $$1 / 32768 *10}' >> pool; 

anal:
	#perl < analyza.pl

BASE1=unset key;set xrange [0:22000e-6];set style data dots;set format y '%3.1f';set multiplot;set size 1,0.33;set origin 0,0;set ylabel 'ch3';plot 'PapouchSt_03';set origin 0,0.33;unset xtics;set ylabel 'ch2';plot 'PapouchSt_02';set origin 0,0.66;unset xtics;set ylabel 'ch1';plot 'PapouchSt_01'

BASE2=unset key;set xrange [0:22000e-6];set style data dots;set format y '%3.1f';set multiplot;set size 1,0.33;set origin 0,0.33;set ylabel 'ch5';plot 'PapouchSt_05';set origin 0,0.66;set ylabel 'ch4';plot 'PapouchSt_04'





graphs:
	#echo "set terminal x11;$(BASE)"|gnuplot -persist
	echo "set terminal png;$(BASE1)"|gnuplot >graph1.png
	convert -resize 150 graph1.png icon.png
	echo "set terminal png;$(BASE2)"|gnuplot >graph2.png	


html:
	echo "<html><head><title>DAS Papouch</title><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-2'><style></style></head>">index.html;\
	echo "<h1>DAS: Papouch_ST</h1>Channel 7 is not in operation!<h2>Graphs:</h2><img src="graph1.png"></img><br/><img src="graph2.png"></img><br/>">>index.html;\
	echo "<h2>Data:</h2><ul><li><a href="matrice">matrice</a></li><li><a href="PapouchSt_01">PapouchSt_01</a></li><li><a href="PapouchSt_02">PapouchSt_02</a></li><li><a href="PapouchSt_03">PapouchSt_03</a></li><li><a href="PapouchSt_04">PapouchSt_04</a></li><li><a href="PapouchSt_05">PapouchSt_05</a></li></ul></body></html>">>index.html;\
