예제 #1
0
	def check_weather():
		weather_value = song_checker.Checker().weather_check()
		print clock.timename(), "Weather value was: ", weather_value[0]
		if str(weather_value[0]) != "0":
			print clock.timename(), "The weather was not good for observing!\n"
			do_action.update_or_status("wait", obs_req_nr)
			do_action.update_or("constraint_4", "'Bad weather'", "req_no", obs_req_nr)
			sys.exit("The execution of the OR was cancelled!")  
		sys.stdout.flush()
예제 #2
0
	def check_daytime():
		day_value = song_checker.Checker().day_check()
		if str(day_value) == "4" and obs_req_values["object_name"].lower() != "sun":
			print clock.timename(), "The Sun has not set yet!"
			do_action.update_or_status("abort", obs_req_nr)
			do_action.update_or("constraint_4", "'It was daytime'", "req_no", obs_req_nr)
			sys.exit("The execution of the OR was cancelled!") 
		elif str(day_value) != "4" and obs_req_values["object_name"].lower() != "sun":
			night_values = ["Night","","Astronomical twilight", "Nautical twilight", "Civil twilight", "Day"]
			print clock.timename(), "The Suns position means that it is: ", night_values[int(day_value)+1]
		elif  str(day_value) != "4" and obs_req_values["object_name"].lower() == "sun":
			print clock.timename(), "The Sun has set so it can not be observed!"
			sys.exit("The execution of the OR was cancelled!")
		sys.stdout.flush()
	def __init__(self):

		print ""
		print clock.timename(), " Monitor daemon started"
 
		self.verbose = song_monitor_config.verbose # yes / no

		self.who_did_it_tel = "time"    # Who did it for the telescope
		self.who_did_it_sp = "time"     # Who did it for the side ports
	
		self.monitor_hangs_send_mail = 0
		self.telescope_hangs_sms = 0
		self.i2_counter = 0

		output, timestamp = song_checker.Checker().weather_check(deduced=song_monitor_config.weather_deduced)
		print clock.timename(), " Weather output at daemon start was: ", output
		if output > 0:
			self.who_did_it_tel = "weather"    # Who did it for the telescope
			self.who_did_it_sp = "weather"     # Who did it for the side ports

		self.old_output = ''

		global RUNNING

		# Ask the bf2300 if the side ports are opened or closed:
		try:
			if song_monitor_config.mon_side_ports == 1:
				side_port_1_status = bf_2300_controller.bf_reader().read_input(input_number=1)
				time.sleep(1)
				side_port_2_status = bf_2300_controller.bf_reader().read_input(input_number=2)
				time.sleep(1)
				side_port_3_status = bf_2300_controller.bf_reader().read_input(input_number=3)
				time.sleep(1)
				side_port_4_status = bf_2300_controller.bf_reader().read_input(input_number=4)
				time.sleep(1)
				side_port_5_status = bf_2300_controller.bf_reader().read_input(input_number=5)
				time.sleep(1)
				side_port_6_status = bf_2300_controller.bf_reader().read_input(input_number=6)
				time.sleep(1)
				side_port_7_status = bf_2300_controller.bf_reader().read_input(input_number=7)
				time.sleep(1)
			else:
				side_port_1_status = 0
				side_port_2_status = 0
				side_port_4_status = 0
				side_port_6_status = 0

		except Exception, e:
			print clock.timename(), e
			side_port_1_status = e
예제 #4
0
    def __init__(self):
        """
			Initialization of the weather checks.
		"""

        self.test = song_monitor_config.weather_test

        self.check_handle = song_checker.Checker()
        self.perform_actions = mon_actions.Do_Actions()
        self.sun_handle = song_star_checker.sun_pos(
            site=m_conf.song_site)  # site=1: Tenerife

        self.verbose = song_monitor_config.verbose  # yes or no

        try:
            value1 = self.check_weather(
                deduced_value=song_monitor_config.weather_deduced)
        except Exception, e:
            value1 = 1
예제 #5
0
    def __init__(self):
        """
			Initialization of the time checks.
		"""
        self.mon_house_hold_value = song_monitor_config.mon_house_hold_actions  # 1 = do things, 0 = do nothing.
        self.verbose = song_monitor_config.verbose
        self.checker = song_checker.Checker()
        self.delay_time = time.time()
        self.specbox_delay_time = time.time()
        self.email_slony = 0
        self.email_ds = 0
        self.email_ds_alarm = 0
        self.email_ds_scratch = 0
        self.email_ds_scratch_alarm = 0
        self.slony_delay = time.time()
        self.notify_swap_delay = 0
        self.notify_mem_delay = 0
        self.notify_test_i2_heater_delay = 0
        self.notify_i2_heater_delay = 0
예제 #6
0
	def check_object():
		object_value = song_checker.Checker().object_check(obs_req_values["right_ascension"],obs_req_values["declination"])
		if object_value == 1:
			print clock.timename(), "The object was not above %f degrees" % (m_conf.telescope_min_altitude)
			do_action.update_or_status("abort", obs_req_nr)
			do_action.update_or("constraint_4", "'Too low object'", "req_no", obs_req_nr)
			sys.exit("The execution of the OR was cancelled!")  
		elif object_value == 2:
			print clock.timename(), "The wind speed was too high in direction of the object\n"
			do_action.update_or_status("abort", obs_req_nr)
			do_action.update_or("constraint_4", "'High wind speed'", "req_no", obs_req_nr)
			sys.exit("The execution of the OR was cancelled!")  
		elif object_value == 3:
			print clock.timename(), "The object was not above %f degrees and wind speed in that direction was too high" % (m_conf.telescope_min_altitude)
			do_action.update_or_status("abort", obs_req_nr)
			do_action.update_or("constraint_4", "'Low object'", "req_no", obs_req_nr)
			sys.exit("The execution of the OR was cancelled!")  
		elif object_value == 0:
			print clock.timename(), "The object was observable"
		sys.stdout.flush()	
예제 #7
0
                print clock.timename(), "Starting the Scheduler..."
                os.popen(
                    "python /home/madsfa/subversion/trunk/scheduler/scheduler.py -s",
                    "w")

                self.scheduler_val = 1

        #### This will check for ORs just before sunset.... ###
        if self.check_ors == 0 and float(sun_alt_d) < 1.0 and float(
                sun_alt_d) > 0.0 and float(
                    clock.timename().split("T")[1][0:2]) > 12.0:
            if song_monitor_config.mon_OR_insertion == 1:
                print clock.timename(), " Checking for ORs before sunset!"
                ors_val = 0
                try:
                    ors_val = song_checker.Checker().check_for_ors()
                except Exception, e:
                    print clock.timename(), " Could not check for ORs"
                    print clock.timename(), e

                #### Checking for calibration files:
                try:
                    folder = "/scratch/star_spec/%s/night/raw/" % (
                        time.strftime("%Y%m%d", time.localtime()))
                    numb_of_files = len(os.listdir(folder))
                except Exception, e:
                    print clock.timename(), e
                    print clock.timename(
                    ), " Could not get the number of files!"

                else:
예제 #8
0
			do_action.update_or("constraint_4", "'Dome was closed'", "req_no", obs_req_nr)
			sys.exit()
		else:
			print clock.timename(), "The dome was open "
		sys.stdout.flush()


#######################################
#######################################
#######################################

	obs_req_values = get_or_values("obs_request_1", ["right_ascension", "declination", "ra_pm", "dec_pm", "object_name", "imagetype", "observer", "exp_time", "x_bin", "y_bin", "x_begin", "y_begin", "x_end", "y_end", "no_exp", "no_target_exp", "no_thar_exp", "amp_gain", "readoutmode", "iodine_cell", "obs_mode", "slit", "start_window", "stop_window", "project_name", "ang_rot_offset", "adc_mode", "epoch", "site", "project_id", "req_prio", "req_chain_previous", "req_chain_next", "magnitude"], obs_req_nr)

	same_as_last_OR = "not_same"
	try:
		same_as_last_OR = song_checker.Checker().check_last_observed_target(next_object=obs_req_nr)
	except Exception,e:
		print clock.timename(), e
		print clock.timename(), "Could not check if the same object was to be observed again."					

	if same_as_last_OR == "not_same":
		if conf.finish_off == 1:
			print clock.timename(), "Now doing stuff like stopping sigu and pugu and stopping telescope..."
			try:
				do_action.finishing_off()
				do_action.thread_slew()		# Setting the self.slewing variable to one to make sure image acquisition will not happen premature.
			except Exception,e:
				print clock.timename(), e
	else:
		print clock.timename(), "Now starting the guiders..."
		try:
예제 #9
0
    def __init__(self):
        """
		Initialise object. This is done primarily through a configuration file.
		@param config_file: Filename or -handle from which configuration options are read.
		@throws: ConfigParser.Error, ConfigParser.NoSectionError, ConfigParser.NoOptionError
		@return: None
		"""

        self.cfg = scheduler_config

        #logging related options
        loglevels = {
            'debug': logging.DEBUG,
            'info': logging.INFO,
            'critical': logging.CRITICAL,
            'error': logging.ERROR,
            'warning': logging.WARNING
        }
        self.loglevel = loglevels[self.cfg.level]
        self.loglocation = self.cfg.outstream
        logging.basicConfig(filename=self.loglocation,
                            level=self.loglevel,
                            format='%(levelname)s:(%(asctime)s): %(message)s',
                            datefmt='%Y-%m-%d %H:%M:%S')

        #site-specific information
        self.site_num = self.cfg.site_num

        #number of entries to read out at a time, when determining the next OR to execute
        self.readout_lim = self.cfg.readout_lim

        #add three sorting parameters to self.sort_params. they are added in correct order
        self.sort_params = []
        self.sort_params.append(self.cfg.sort_param1)
        #self.sort_params.append(self.cfg.sort_param2)
        #self.sort_params.append(self.cfg.sort_param3)

        self.mode = self.cfg.scheduler_mode

        #connection and table information on the OR-part of the database
        self.ORdb = {}
        self.ORdb['host'] = m_conf.db_host
        self.ORdb['db'] = m_conf.or_db
        self.ORdb['table'] = m_conf.or_table
        self.ORdb['user'] = m_conf.db_user
        self.ORdb['password'] = m_conf.db_password

        self.ORcdb = {}
        self.ORcdb['host'] = m_conf.db_c_host
        self.ORcdb['db'] = m_conf.or_db
        self.ORcdb['table'] = m_conf.or_table
        self.ORcdb['user'] = m_conf.db_user
        self.ORcdb['password'] = m_conf.db_password

        #connection and table information on the status-part of the database
        self.statusdb = {}
        self.statusdb['host'] = m_conf.db_host
        self.statusdb['db'] = m_conf.data_db
        self.statusdb['table'] = m_conf.or_status_table
        self.statusdb['user'] = m_conf.db_user
        self.statusdb['password'] = m_conf.db_password

        #script related options
        self.script = {}
        self.script['timeout_overhead'] = self.cfg.timeout_overhead
        self.script['or_script_name'] = self.cfg.or_script_name
        self.script['template_script_name'] = self.cfg.template_script_name
        self.script['sun_script_name'] = self.cfg.sun_script_name
        self.script['sun_fibre_script'] = self.cfg.sun_fibre_script
        self.script['moon_script'] = self.cfg.moon_script

        #checker related options
        self.checker_values = {}
        self.checker = song_checker.Checker()

        #allowed values for the weather checker
        if ('all' in self.cfg.weather_allowed_values):
            self.checker_values['weather'] = range(128)
        else:
            self.checker_values['weather'] = [
                int(a) for a in self.cfg.weather_allowed_values
            ]

        logging.debug('weather-checker values: ' +
                      str(self.checker_values['weather']))
        logging.info('weather-checker values: ' +
                     str(self.checker_values['weather']))

        #allowed values for the day-checker
        if ('all' in self.cfg.day_allowed_values):
            self.checker_values['day'] = [-1, 1, 0, 2, 3, 4]
        else:
            self.checker_values['day'] = self.cfg.day_allowed_values

        logging.debug('day-checker values: ' + str(self.checker_values['day']))
        logging.info('day-checker values: ' + str(self.checker_values['day']))

        #whether to check if object is observable
        if (self.cfg.object_check == False):
            self.checker_values['object'] = [0, 1]
        else:
            self.checker_values['object'] = [
                0,
            ]
        logging.debug('object-checker values: ' +
                      str(self.checker_values['object']))
        logging.info('object-checker values: ' +
                     str(self.checker_values['object']))

        ### Starting the real-time-scheduling thread:
        if self.mode == "advanced":
            self.real_time_scheduling()

        logging.info('Scheduler initialized.')
예제 #10
0
import xmlrpclib
sys.path.append("/home/obs/programs/DMC")
import pst
import lamp
import Set_M8
import get_db_values
import pdu_module
import song_star_checker
import song_checker

ccd_server = xmlrpclib.ServerProxy('http://%s:%s' % (m_conf.ccd_server, m_conf.ccd_port))

sigu = slit_module.SIGU()
pugu = pupil_module.PUGU()
sun_handle = song_star_checker.sun_pos(m_conf.song_site)
checker_handle = song_checker.Checker()

clock = song_timeclass.TimeClass()
pdu_handle = pdu_module.APC()

def update_or_status(status, obs_req_nr):
	"""
	@brief Update the status.
	Updates the status in the database. Since the req_no is locked to the instance of the ObservationStatus object, all you need to supply here is the new status. The ins_at-field in the database will be updated as well.
	    
	@param status The new value for the status.
	@exception AssertionError Bad value of status provided.
	
	"""
	if obs_req_nr == "":
		return 0