ADDRESS_socat=TCP:192.168.2.220:10001
DAS=01 02 03 

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 5`; do make getdata IP=220 ADDRESS="$${i}_$${j}" CHAN=$$i ;done; awk '{print NR-1"E-6\t" $$1}' pool > PapouchSt_$$i;sleep 1s;done
	#for i in 01 02 03 06 07 08 09; do rm -f pool; echo DAS Papouch $$i;for j in `seq 1 5`; do make getdata IP=220 ADDRESS="$${i}_$${j}" CHAN=$$i ;done; awk '{print NR-1"E-6\t" $$1}' pool > PapouchSt_$$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'

graphs:
	echo "set terminal png;$(BASE1)"|gnuplot >graph1.png
	convert -resize 150 graph1.png icon.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><h2>Graphs:</h2><img src="graph1.png"></img><br/>">>index.html;\
	echo "<h2>Data:</h2><ul><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></ul></body></html>">>index.html;\
