#!/usr/bin/python

# * ccd_process 
#
#   * Use INDI to start a ccd exposure for a time already set

# Copyright (c) 2011-2012 John Kielkopf and Karen Collins        
# kielkopf@louisville.edu                                                  
#                                                                          
#                                                                          
# Date: April 12, 2012                                                      
# Version: 1.0                                                             
#                                                                          
# This file is part of XmCCD                                              
#                                                                          
# XmCCD is free software: you can redistribute it and/or modify           
# it under the terms of the GNU General Public License as published by     
# the Free Software Foundation, either version 3 of the License, or        
# (at your option) any later version.                                      
#                                                                          
# XmCCD is distributed in the hope that it will be useful,                
# but WITHOUT ANY WARRANTY; without even the implied warranty of           
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
# GNU General Public License for more details.                             

import sys
from subprocess import Popen, PIPE
import string
import time

# Wait for ds9 to load the latest image

time.sleep(5)

# Make guiding corrections 

Popen('/usr/local/bin/guide.py', shell=True, stdout=PIPE).wait()

# Wait for telescope to respond to guide commands

time.sleep(5)

# Adjust the dome

Popen('/usr/local/bin/dome_track.py', shell=True, stdout=PIPE).wait()

# Wait for dome to adjust

time.sleep(5)

# Start the next exposure

Popen('/usr/local/bin/ccd_expose.py', shell=True, stdout=PIPE).wait()

exit()
