CHANNELS=1 2 3 4

scope_address=nc -q 3 RigolDS1074b 5555

output=RigolDS1074b

turn_on:


turn_off:

	
arming:
	echo ":SINGLe"|$(scope_address) 

	
	
	
acquisition:
	echo "Performing Rigol DS1074b DAS acquisition"|tee -a /home/svoboda/GOLEM/web/roperation/RemoteTokamak/actions.log
	#python2 acquisition.py
	for channel in $(CHANNELS);\
	do make getdata CHANNEL=$$channel ;\
	done;\
	paste data* > data_all

	make getscreenshot 	

	#python2 main.py acquisition

plots:
	echo '<html><body><h1>Rigol oscilloscope</h1><h2>Screenshot</h2><img src="screenshot.png" width="50%"><h2>Data</h2><ul>'>$(output).html
	#for channel in $(CHANNELS);\
	#do echo '<li><a href="data'$$channel'">Channel '$$channel'</a></li>' >> $(output).html;done
	echo '<li><a href="data_all">Time axis and all channels (as columns)</a></li>' >> $(output).html
	echo '</ul><hr/>Generated by <a href="makefile">makefile</a>.</body></html>' >> $(output).html
	#python2 main.py plots

getdata:
	echo "Rigol DS1074b: Downloading data for channel $(CHANNEL)"
	echo ":WAV:SOURCE CHAN$(CHANNEL);:WAV:FORM ASCii;:WAV:MODE NORM" |$(scope_address);sleep 0.5s;echo ":WAV:DATA?" |$(scope_address)|cut -c 12-|sed 's/,/\n/g'|tee data$(CHANNEL)|gnuplot -e 'set terminal jpeg;plot "<cat" w l' > plot$(CHANNEL).jpg;
	
getscreenshot:
	echo "display:data?" |$(scope_address)| dd bs=1 skip=11 2>/dev/null | convert bmp:- screenshot.png
	convert -resize 150x120\! screenshot.png icon.png

clean:

off:	
