#!/bin/bash
# start observation: open everything, turn on power etc
export http_proxy=""

echo "Turn ON hardware power"
ssh obs@192.168.70.36 ~/bin/HWpoweron
echo "Open dome"
curl localhost:55555/open
sleep 5
echo "set camera temperature to -35degrC"
fli_control -t-35
echo "Turn ON mount"
ssh obs@192.168.70.36 ~/bin/MOUNTpoweronoff
while true; do
	ANS=$(curl localhost:55555/status 2>/dev/null)
	echo "Status: $ANS"
	[ $ANS = "2,2,90,90" ] && break
	sleep 1
done

echo "Open telescope doors"
COMDEV=/dev/ttyS0
stty -F $COMDEV -hupcl -opost -onlcr -isig -iexten -echo -echoe -echok -echoctl -echoke -icanon min 0 time 5
echo -ne "SHUTTEROPEN?1,1,1,1,1\r" > $COMDEV
cat $COMDEV
echo -e "\n"
