def check_weather(self, side_port_group_1, side_port_group_2, side_port_group_3, side_port_group_4, telescope_state, slit_state, flap_state, mirror_cover_state, who_did_it_tel, who_did_it_sp): """ @brief: This function checks the weather through the song_checker class. This can open and close the dome if needed. """ if song_monitor_config.mon_telescope_actions == 1 and song_monitor_config.mon_telescope == 0: telescope_state = int( float(comm2tcs_read.GET_TSI().get_telescope_state( sender="Monitor"))) slit_state = int( float(comm2tcs_read.GET_TSI(). get_position_instrumental_dome_slit_currpos( sender="Monitor"))) flap_state = int( float(comm2tcs_read.GET_TSI(). get_position_instrumental_dome_flap_currpos( sender="Monitor"))) mirror_cover_state = int( float(comm2tcs_read.GET_TSI().get_auxiliary_cover_realpos( sender="Monitor"))) self.side_port_group_1 = side_port_group_1 self.side_port_group_2 = side_port_group_2 self.side_port_group_3 = side_port_group_3 self.side_port_group_4 = side_port_group_4 self.telescope_state = telescope_state self.slit_state = slit_state self.flap_state = flap_state self.mirror_cover_state = mirror_cover_state self.who_did_it_tel = who_did_it_tel self.who_did_it_sp = who_did_it_sp try: if self.test == 1: output, timestamp = self.check_handle.weather_check_test() else: output, timestamp = self.check_handle.weather_check( deduced=song_monitor_config.weather_deduced) output2, timestamp2 = self.check_handle.weather_check( deduced=1) # Returns the bits of the weather check except Exception, e: print clock.timename( ), " Error while collecting song_checker data, check_weather", e output = "" output2 = [""] timestamp2 = ""
def check_telescope(): try: tcs_ready = comm2tcs_read.GET_TSI().get_telescope_state(sender="observer") except Exception,e: print clock.timename(), "The tcs comm daemon was not running\nOr the ASTELCO tsi script was not running on the ASTELCO PC!\nOr there were no power on the Telescope." do_action.update_or_status("abort", obs_req_nr) do_action.update_or("constraint_4", "'TCS problem'", "req_no", obs_req_nr) sys.exit("The execution of the OR was cancelled!")
def check_dome(): slit_state = comm2tcs_read.GET_TSI().get_position_instrumental_dome_slit_currpos(sender="observer") if str(slit_state) != '1.0': print clock.timename(), "Monitor had not opened the dome! " do_action.update_or_status("wait", obs_req_nr) 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()
import songwriter_xmlrpcclient import songwriter_MFA_client import glob import xmlrpclib #attempt connection to server isong_server = xmlrpclib.ServerProxy('http://%s:%s' % ("iodinepipe.kvmtenerife.prv", 8050)) clock = song_timeclass.TimeClass() sun_handle = song_star_checker.sun_pos( site=m_conf.song_site) # site=1: Tenerife gettsi = comm2tcs_read.GET_TSI() settsi = comm2tcs_write.SET_TSI() pdu_handle = pdu_module.APC() class daily_daemon(Daemon): """ @brief: This class inherits Daemon from song.py and daemonizes the code. """ def run(self): """ @brief: This function overwrites the run function in song.py. """ global RUNNING RUNNING = True
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() # Check if there is a connection to the tcs comm daemon: if conf.check_telescope == 1: # ct = threading.Thread(target=check_telescope, args=()) # Move Calibration mirror out of the path # ct.start() try: tcs_ready = comm2tcs_read.GET_TSI().get_telescope_state(sender="observer") except Exception,e: print clock.timename(), "The tcs comm daemon was not running\nOr the ASTELCO tsi script was not running on the ASTELCO PC!\nOr there were no power on the Telescope." do_action.update_or_status("abort", obs_req_nr) do_action.update_or("constraint_4", "'TCS problem'", "req_no", obs_req_nr) sys.exit("The execution of the OR was cancelled!") print clock.timename(), "The telescope state was: ", tcs_ready if str(tcs_ready) == "1.0": print clock.timename(), "The telescope is powered on and ready to observe!" elif str(tcs_ready) == "0.0": print clock.timename(), "The telescope is powered off and needs to be started!" do_action.update_or_status("abort", obs_req_nr) do_action.update_or("constraint_4", "'Telescope off'", "req_no", obs_req_nr) sys.exit() sys.stdout.flush()
class Check_something(object): 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 if str(side_port_1_status) in ["0","1"]: self.side_port_group_1 = int(float(side_port_1_status)) self.side_port_group_2 = int(float(side_port_2_status)) self.side_port_group_3 = int(float(side_port_4_status)) self.side_port_group_4 = int(float(side_port_6_status)) print clock.timename(), " Side ports working fine" else: print clock.timename(), " Could not get the side port status" global RUNNING RUNNING = False # Ask the tcs daemon if the telescope is powered on or off try: if song_monitor_config.mon_telescope == 1 or song_monitor_config.mon_telescope_info == 1: print clock.timename(), " Now connecting to telescope" telescope_status = comm2tcs_read.GET_TSI().get_telescope_state(sender="Monitor") slit_status = comm2tcs_read.GET_TSI().get_position_instrumental_dome_slit_currpos(sender="Monitor") flap_status = comm2tcs_read.GET_TSI().get_position_instrumental_dome_flap_currpos(sender="Monitor") mirror_cover_status = comm2tcs_read.GET_TSI().get_auxiliary_cover_realpos(sender="Monitor") else: telescope_status = 0 slit_status = 0 flap_status = 0 mirror_cover_status = 0 except Exception, e: print clock.timename(), " An exception was thrown: ", e telescope_status = 0 slit_status = 0 flap_status = 0 mirror_cover_status = 0
def collect_tel_info(self): """ @brief: This function checks the state of the telescope and writes the state to the databasa: """ global RUNNING while RUNNING: try: try: t_ready_state = float(comm2tcs_read.GET_TSI().get_telescope_state(sender="monitor")) except Exception,e: print clock.timename(), e t_ready_state = comm2tcs_read.GET_TSI().get_telescope_state(sender="monitor") print clock.timename(), " The telescope replied : '%s' for the ready state in main monitor code" % str(t_ready_state) if type(self.telescope_state) == numpy.str: t_ready_state = -1 # Error state elif float(t_ready_state) == float(-3.0): t_ready_state = 10 # Local mode elif float(t_ready_state) == float(-2.0): t_ready_state = 9 # Emergency stop t_motion_state = comm2tcs_read.GET_TSI().get_telescope_motion_state(sender="monitor") t_ra = comm2tcs_read.GET_TSI().get_position_equatorial_ra_j2000(sender="monitor") t_dec = comm2tcs_read.GET_TSI().get_position_equatorial_dec_j2000(sender="monitor") t_az = comm2tcs_read.GET_TSI().get_position_horizontal_az(sender="monitor") t_zd = comm2tcs_read.GET_TSI().get_position_horizontal_zd(sender="monitor") t_alt = comm2tcs_read.GET_TSI().get_position_horizontal_alt(sender="monitor") t_error = comm2tcs_read.GET_TSI().get_telescope_status_global(sender="monitor") t_focus = comm2tcs_read.GET_TSI().get_position_instrumental_focus_currpos(sender="monitor") t_focus_offset = comm2tcs_read.GET_TSI().get_position_instrumental_hexapod_z_offset(sender="monitor") o_ra = comm2tcs_read.GET_TSI().get_object_equatorial_ra(sender="monitor") o_dec = comm2tcs_read.GET_TSI().get_object_equatorial_dec(sender="monitor") d_az = comm2tcs_read.GET_TSI().get_position_horizontal_dome(sender="monitor") d_slit = comm2tcs_read.GET_TSI().get_position_instrumental_dome_slit_currpos(sender="monitor") if float(d_slit) != 0.0 and float(d_slit) != 1.0 and float(d_slit) != -1.0: d_slit = 2 else: d_slit = int(float(d_slit)) d_flap = comm2tcs_read.GET_TSI().get_position_instrumental_dome_flap_currpos(sender="monitor") if float(d_flap) != 0.0 and float(d_flap) != 1.0 and float(d_flap) != -1.0: d_flap = 2 else: d_flap = int(float(d_flap)) if d_slit > 0 or d_flap > 0: d_state = 1 elif d_slit == 0 and d_flap == 0: d_state = 0 else: d_state = -1 m_cover = comm2tcs_read.GET_TSI().get_auxiliary_cover_realpos(sender="monitor") if float(m_cover) != 0.0 and float(m_cover) != 1.0 and float(m_cover) != -1.0: m_cover = 2 else: m_cover = int(float(m_cover)) thr_mirror = comm2tcs_read.GET_TSI().get_pointing_setup(sender="monitor") temp_cab = comm2tcs_read.GET_TSI().get_auxiliary_temp_cabinet(sender="monitor") temp_m1 = comm2tcs_read.GET_TSI().get_auxiliary_temp_m1(sender="monitor") temp_m2 = comm2tcs_read.GET_TSI().get_auxiliary_temp_m2(sender="monitor") temp_m3 = comm2tcs_read.GET_TSI().get_auxiliary_temp_m3(sender="monitor") temp_tt = comm2tcs_read.GET_TSI().get_auxiliary_ttelescope(sender="monitor") # derot_position = comm2tcs_read.GET_TSI().get_position_mechanical_derotator_currpos() derot_position = float(comm2tcs_read.GET_TSI().get_position_mechanical_derotator_currpos(sender="monitor")) % 360.0 derot_offset = comm2tcs_read.GET_TSI().get_position_mechanical_derotator_offset(sender="monitor") except Exception, e: print clock.timename(), " Could not get telescope status values: ", e
comm2tcs_write.SET_TSI().set_position_instrumental_az_offset( param=0.0, sender="Observer") comm2tcs_write.SET_TSI().set_position_instrumental_zd_offset( param=0.0, sender="Observer") # SETTING THE TELESCOPE TO POINT TO THE MOON: value = comm2tcs_write.SET_TSI().set_object_solarsystem_object( param=3, sender="Observer") # Set Object to Earth value = comm2tcs_write.SET_TSI().set_object_solarsystem_moon( param=1, sender="Observer") # Set moon to Moon # Setting the telescope to point to and track the moon: value = comm2tcs_write.SET_TSI().set_pointing_track( param=1, sender="Observer") # start to track the Moon track_value = comm2tcs_read.GET_TSI().get_telescope_motion_state( sender="Observer") timeout = time.time() + 120 # Timeout after n minutes. close_to = False time_out = time.time() + 120 while str(track_value) not in ['11', '11.0']: time.sleep(1.0) track_value = comm2tcs_read.GET_TSI().get_telescope_motion_state( sender="Observer") print clock.timename( ), "The telescope motion state value was: ", track_value if time.time() > time_out: break t1 = time.time() + 120