def __init__(self): super(EphemerisShooter, self).__init__() self.ObserverFactory = EphemObserverFactory() # self.continuousShooterThread = ContinuousShooterThread(int(info_cam[4])) self.continuousShooterThread = ContinuousShooterThread(0) self.console = ConsoleThreadOutput() self.config = ConfigProject() info = self.config.get_geographic_settings() info_sun = self.config.get_moonsun_settings() self.latitude = info[0] # '-45.51' self.longitude = info[1] # '-23.12' self.elevation = info[2] # 350 self.max_solar_elevation = info_sun[0] # -12 self.ignore_lunar_position = info_sun[1] self.max_lunar_elevation = info_sun[2] # 8 self.max_lunar_phase = info_sun[3] # 1 self.wait_temperature = False self.shootOn = False self.controller = True self.count = 1
def __init__(self, parent=None): super(SequenceFilters, self).__init__(parent) # Instance attributes create_filtros_disponiveis_group self.filters_disp = None self.showfilters = None # Instance attributes create_wish_filters_group self.wish_sequence_filters_l = None self.showfiltersl = None self.obs_msg = None # Instance attributes create_push_button_group self.saveButton = None self.cancelButton = None self.clearButton = None self.sequencia_filtros = SettingsSequenceFilters() self.filters_disp_var = None self.console = ConsoleThreadOutput() self.count_aux = 0 self.seq_filtros_parent = parent grid = QGridLayout() grid.addWidget(self.create_filtros_disponiveis_group(), 2, 0) grid.addWidget(self.create_wish_filters_group(), 4, 0) grid.addWidget(self.create_push_button_group(), 5, 0) self.setLayout(grid) self.setWindowTitle("Acquisition Schedule") self.setting_values()
def __init__(self, timeSleep): self.continuous = None super(DarkShooterThread, self).__init__() self.console = ConsoleThreadOutput() self.s = timeSleep self.ss = SThread() self.settings = SettingsCamera()
def __init__(self): self.lock = Locker() self.console = ConsoleThreadOutput() self.settings = SettingsCamera() self.settings.setup_settings() self.fan = Fan() # Campos da janela principal para as informações da câmera self.firmware_field = None self.model_field = None self.main = Status() self.now_plus_10 = datetime.now() self.settedhour = datetime.now() self.continuousShooterThread = ContinuousShooterThread( int(self.settings.get_camera_settings()[4])) self.ephemerisShooterThread = EphemerisShooter() self.sthread = SThread() self.commands = CameraQThread(self) self.shooting = False # Initiating the Slots self.init_slots() self.info_ini = [] info_ini = self.get_camera_settings_ini() self.aux_temperature = int(info_ini[0]) self.temp = 0 self.temp_contador = 0 self.temp_contador_manual = 0
def __init__(self, parent=None): super(SettingsCCDInfos, self).__init__(parent) # Instance attributes create_ccd_info_group self.p = parent self.info_port_ccd_l = None self.info_port_ccd_f = None self.info_camera_model_l = None self.info_camera_model_f = None self.info_pixel_array_l = None self.info_pixel_array_f = None # Instance attributes create_ccd_camera_group self.close_open = None self.temp_set_point_l = None self.temp_set_point_f = None self.temp_init_l = None self.temp_init_f = None self.time_between_photos_l = None self.time_between_photos_f = None self.one_photoButton = None self.tempButton = None self.fanButton = None # Instance attributes create_push_button_group self.saveButton = None self.cancelButton = None self.clearButton = None self.imager_window = parent self.cam = Camera() self.var_save_ini_camera = SettingsCamera() self.console = ConsoleThreadOutput() self.fan = Fan(self.fanButton) self.one_photo = SThread() self.lock = Locker() self.firmware = "????" self.model = "????" self.y_pixels = "????" self.x_pixels = "????" grid = QGridLayout() # Additional Parameters (Apparently Useless) 0, 1 | 1, 1 | 2, 1 grid.addWidget(self.create_ccd_info_group()) grid.addWidget(self.create_ccd_camera_group()) grid.addWidget(self.create_push_button_group()) self.setLayout(grid) self.w = grid.geometry().width() self.h = grid.geometry().height() self.setWindowTitle("Imager Box")
def __init__(self, sunElevationField, moonElevationField, moonPhaseField): self.sunElevationField = sunElevationField self.moonElevationField = moonElevationField self.moonPhaseField = moonPhaseField self.console = ConsoleThreadOutput() self.thread_sun_moon = QThreadSunMoon() self.thread_sun_moon.signal_update_sun_moon.connect(self.refresh_info) self.thread_sun_moon.start()
def __init__(self, parent=None): super(SettingsImageWindow, self).__init__(parent) # Instance attributes create_image_contrast_group self.getlevel1 = None self.getlevel1l = None self.getlevel2 = None self.getlevel2l = None # Instance attributes create_crop_group self.ignore_crop_l = None self.crop_msg = None self.crop_xi = None self.getcropxi_l = None self.crop_xf = None self.getcropxf_l = None self.crop_yi = None self.getcropyi_l = None self.crop_yf = None self.getcropyf_l = None # Instance attributes create_type_image_group # self.image_png_l = None self.image_tif_l = None self.image_fit_l = None # Instance attributes create_push_button_group self.saveButton = None self.cancelButton = None self.clearButton = None self.image_settings = SettingsImage() self.camera = Camera() self.console = ConsoleThreadOutput() self.image_parent = parent self.lock = Locker() self.x_pixels, self.y_pixels = self.get_pixels() grid = QGridLayout() grid.addWidget(self.create_image_contrast_group()) grid.addWidget(self.create_crop_group()) grid.addWidget(self.create_type_image_group()) grid.addWidget(self.create_push_button_group()) self.setLayout(grid) self.setWindowTitle("Imager Box") self.setting_values()
def __init__(self): super(ShutterControls, self).__init__() self.console = ConsoleThreadOutput() self.openaction = QPushButton('Open Shutter', self) self.openaction.clicked.connect(self.run_true) self.closeaction = QPushButton('Close Shutter', self) self.closeaction.clicked.connect(self.run_false) self.setLayout(set_hbox(self.openaction, self.closeaction))
def __init__(self, timeSleep): super(ContinuousShooterThread, self).__init__() self.continuous = True self.s = timeSleep self.ss = SThread() self.ss.started.connect(self.thread_iniciada) self.console = ConsoleThreadOutput() self.count = 0 self.wait_temperature = False self.not_two_dark = True
class SystemSettingsWindow(QtWidgets.QWidget): def __init__(self, parent=None): super(SystemSettingsWindow, self).__init__(parent) self.s = parent self.cs = ConfigSystem() self.console = ConsoleThreadOutput() # Creating Widgets self.wp = WidgetsPath(self) self.button_ok = QtWidgets.QPushButton('Save', self) self.button_clear = QtWidgets.QPushButton('Clear', self) self.button_cancel = QtWidgets.QPushButton('Cancel', self) # Setting Up self.button_settings() self.setting_up() self.filling_fields() def button_settings(self): self.button_clear.clicked.connect(self.clear_fields) self.button_cancel.clicked.connect(self.s.close) self.button_ok.clicked.connect(self.ok_button) def ok_button(self): try: self.saving_settings() self.console.raise_text("Saved settings successfully!", 1) except: self.console.raise_text("Unable to save the system settings.", 1) finally: self.s.close() def setting_up(self): self.setLayout( set_lvbox( set_hbox(self.wp), set_hbox(self.button_ok, self.button_clear, self.button_cancel, stretch2=1))) def saving_settings(self): info = self.wp.get_values() self.cs.set_site_settings(info[0], info[1], info[2]) self.cs.save_settings() def filling_fields(self): info = self.cs.get_site_settings() self.wp.set_values(info[0], info[1], info[2]) def clear_fields(self): self.wp.clear_path()
class ShutterControls(QtWidgets.QWidget): def __init__(self): super(ShutterControls, self).__init__() self.console = ConsoleThreadOutput() self.openaction = QPushButton('Open Shutter', self) self.openaction.clicked.connect(self.run_true) self.closeaction = QPushButton('Close Shutter', self) self.closeaction.clicked.connect(self.run_false) self.setLayout(set_hbox(self.openaction, self.closeaction)) def run_true(self): self.console.raise_text("Opening Shutter...", 2) time.sleep(1) if shutter_control(True) == "An Error Occured...": self.console.raise_text("An Error Occured...", 3) time.sleep(1) def run_false(self): self.console.raise_text("Closing Shutter...", 2) time.sleep(1) if shutter_control(False) == "An Error Occured...": self.console.raise_text("An Error Occured...", 3) time.sleep(1)
def __init__(self): super(SThread, self).__init__() self.prefix = None self.exposure_time = None self.binning = None self.get_level1 = None self.get_level2 = None self.get_axis_xi = None self.get_axis_xf = None self.get_axis_yi = None self.get_axis_yf = None self.get_ignore_crop = None self.console = ConsoleThreadOutput() self.get_image_tif = None self.get_image_fit = None self.get_image_png = None self.temperatura = None self.eof = EphemObserverFactory() self.obs = None self.path = None self.tempo = None self.info_matrix = None self.img = None self.new_image_name = None self.selected_filter = None self.dark_or_open = "Closed" self.one_photo = None self.for_headers_dic = {} self.lock = Locker() self.info_matrix = [] self.filter_split_label = None self.count_aux = 0 self.kwargs = None self.message_console_one_photo = None self.roda_filtros = FilterControl()
class SystemSettingsWindow(QtWidgets.QWidget): def __init__(self, parent=None): super(SystemSettingsWindow, self).__init__(parent) self.s = parent self.cs = ConfigSystem() self.console = ConsoleThreadOutput() # Creating Widgets self.wp = WidgetsPath(self) self.button_ok = QtWidgets.QPushButton('Save', self) self.button_clear = QtWidgets.QPushButton('Clear', self) self.button_cancel = QtWidgets.QPushButton('Cancel', self) # Setting Up self.button_settings() self.setting_up() self.filling_fields() def button_settings(self): self.button_clear.clicked.connect(self.clear_fields) self.button_cancel.clicked.connect(self.s.close) self.button_ok.clicked.connect(self.ok_button) def ok_button(self): try: self.saving_settings() self.console.raise_text("Saved settings successfully!", 1) except: self.console.raise_text("Unable to save the system settings.", 1) finally: self.s.close() def setting_up(self): self.setLayout(set_lvbox(set_hbox(self.wp), set_hbox(self.button_ok, self.button_clear, self.button_cancel, stretch2=1))) def saving_settings(self): info = self.wp.get_values() self.cs.set_site_settings(info[0], info[1], info[2], info[3], info[4]) self.cs.save_settings() def filling_fields(self): info = self.cs.get_site_settings() self.wp.set_values(info[0], info[1], info[2], info[3], info[4]) def clear_fields(self): self.wp.clear_path()
def __init__(self, timeSleep): super(ContinuousShooterThread, self).__init__() self.continuous = True self.s = timeSleep ''' SThread manda para o Sbigdriver as informações para se tirar a foto em si. ''' self.ss = SThread() self.ss.started.connect(self.thread_iniciada) self.console = ConsoleThreadOutput() self.count = 0 self.wait_temperature = False self.not_two_dark = True self.one_photo = False
class DarkShooterThread(QtCore.QThread): def __init__(self, timeSleep): self.continuous = None super(DarkShooterThread, self).__init__() self.console = ConsoleThreadOutput() self.s = timeSleep self.ss = SThread() self.settings = SettingsCamera() def run(self): self.s = int(self.settings.get_camera_settings()[4]) while self.continuous: time.sleep(self.s) if self.continuous: self.console.raise_text("Taking dark photo", 1) self.ss.take_dark()
def __init__(self, parent=None): super(Shooter, self).__init__(parent) self.console = ConsoleThreadOutput() self.cam = Camera() self.cond = 0 self.sref_calc = SettingsCamera() # Label for Image self.img = QtWidgets.QLabel(self) self.config_img_label() # Creating a Pallete self.pa = QtGui.QPalette() self.set_layout() self.link_signals()
def __init__(self, parent=None): super(SettingsWindow, self).__init__(parent) self.p = parent self.console = ConsoleThreadOutput() self.site = WidgetsSite(self) self.geo = WidgetsGeography(self) self.sun = WidgetsSun(self) self.button_clear = QtWidgets.QPushButton('Clear', self) self.button_ok = QtWidgets.QPushButton('Save', self) self.button_cancel = QtWidgets.QPushButton('Cancel', self) self.button_settings() # Init Interface self.setting_up() self.refresh_all_fields()
def __init__(self): super(EphemerisShooter, self).__init__() self.camconfig = SettingsCamera() self.camconfig.setup_settings() infocam = self.camconfig.get_camera_settings() self.ObserverFactory = EphemObserverFactory() self.continuousShooterThread = ContinuousShooterThread(int(infocam[4])) self.console = ConsoleThreadOutput() self.config = ConfigProject() info = self.config.get_geographic_settings() infosun = self.config.get_moonsun_settings() self.latitude = info[0] # '-45.51' self.longitude = info[1] # '-23.12' self.elevation = info[2] # 350 self.max_solar_elevation = infosun[0] # -12 self.ignore_lunar_position = infosun[1] self.max_lunar_elevation = infosun[2] # 8 self.max_lunar_phase = infosun[3] # 1 self.t = False print(int(infocam[4])) try: self.s = int(infocam[4]) self.continuousShooterThread.set_sleep_time(self.s) except Exception as e: self.s = 5 self.shootOn = False self.controller = True self.count = 1
def __init__(self, parent=None): super(SystemSettingsWindow, self).__init__(parent) self.s = parent self.cs = ConfigSystem() self.console = ConsoleThreadOutput() # Creating Widgets self.wp = WidgetsPath(self) self.button_ok = QtWidgets.QPushButton('Save', self) self.button_clear = QtWidgets.QPushButton('Clear', self) self.button_cancel = QtWidgets.QPushButton('Cancel', self) # Setting Up self.button_settings() self.setting_up() self.filling_fields()
def __init__(self, valor=None): self.console = ConsoleThreadOutput() self.object = valor self.stemp = QThreadTemperature() self.stemp.temp_signal.connect(self.refresh_temp) self.stemp.start()
def __init__(self, timeSleep): super(ContinuousShooterThread, self).__init__() self.continuous = True self.s = timeSleep self.ss = SThread() self.ss.started.connect(self.thread_iniciada) self.console = ConsoleThreadOutput() self.count = 0
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) # Init the Layouts self.MainHBox = QtWidgets.QHBoxLayout() # Main Box self.VBox = QtWidgets.QVBoxLayout() # Vertical Box in the Left Box self.all_h_boxes = [] self.console = ConsoleThreadOutput() self.console.set_widget_console(ConsoleLogWidget(self)) self.MainHBox.addLayout(self.VBox) self.MainHBox.addStretch(1) self.MainHBox.addLayout(set_wvbox(self.console.get_widget_console(), Shooter(self))) add_all_to_vbox(self.VBox, Clock(self), ConfigsInfo(self), StartEndEphem(self), CameraInfo(self)) self.VBox.addStretch(1) self.setLayout(self.MainHBox)
def __init__(self): self.lock = Locker() self.console = ConsoleThreadOutput() self.settings = SettingsCamera() self.settings.setup_settings() self.fan = Fan() # Campos da janela principal para as informações da câmera self.firmware_field = None self.model_field = None self.valor_pixels_x = None self.valor_pixels_y = None self.main = Status() self.now_plus = datetime.now() self.settedhour = datetime.now() """ executa o modo manual continuousShooterThread """ self.continuousShooterThread = ContinuousShooterThread( int(self.settings.get_camera_settings()[4])) """ executa o modo automatico ephemerisShooterThread """ self.ephemerisShooterThread = EphemerisShooter() self.sthread = SThread() self.commands = CameraQThread(self) self.shooting = False # Initiating the Slots self.init_slots() self.info_ini = [] self.pass_list = [1024, 1024] self.pass_list_str = ["1024", "1024"] info_ini = self.get_camera_settings_ini() self.aux_temperature = int(info_ini[0]) self.temp = 0 self.temp_contador = False self.temp_contador_manual = False self.is_connected = False
class MainWindow(QtWidgets.QWidget): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) # Init the Layouts self.MainHBox = QtWidgets.QHBoxLayout() # Main Box self.VBox = QtWidgets.QVBoxLayout() # Vertical Box in the Left Box self.all_h_boxes = [] self.console = ConsoleThreadOutput() self.console.set_widget_console(ConsoleLogWidget(self)) self.MainHBox.addLayout(self.VBox) self.MainHBox.addStretch(1) self.MainHBox.addLayout(set_wvbox(self.console.get_widget_console(), Shooter(self))) add_all_to_vbox(self.VBox, Clock(self), ConfigsInfo(self), CameraInfo(self)) self.VBox.addStretch(1) self.setLayout(self.MainHBox)
class SchedSunMoonPositions(metaclass=Singleton): def __init__(self, sunElevationField, moonElevationField, moonPhaseField): self.sunElevationField = sunElevationField self.moonElevationField = moonElevationField self.moonPhaseField = moonPhaseField self.console = ConsoleThreadOutput() self.thread_sun_moon = QThreadSunMoon() self.thread_sun_moon.signal_update_sun_moon.connect(self.refresh_info) self.thread_sun_moon.start() def refresh_info(self, info): try: self.sunElevationField.setText(info[0]) self.moonElevationField.setText(info[1]) self.moonPhaseField.setText(info[2]) except Exception as e: self.console.raise_text( "Error sun and moon Scheduler\n{}".format(e))
class SchedSunMoonPositions(metaclass=Singleton): def __init__(self, sunElevationField, moonElevationField, moonPhaseField): self.sunElevationField = sunElevationField self.moonElevationField = moonElevationField self.moonPhaseField = moonPhaseField self.console = ConsoleThreadOutput() self.thread_sun_moon = QThreadSunMoon() self.thread_sun_moon.signal_update_sun_moon.connect(self.refresh_info) self.thread_sun_moon.start() def refresh_info(self, info): try: self.sunElevationField.setText(info[0]) self.moonElevationField.setText(info[1]) self.moonPhaseField.setText(info[2]) except Exception as e: self.console.raise_text("Error sun and moon Scheduler\n{}".format(e))
def __init__(self, parent=None): super(SettingsWindow, self).__init__(parent) self.cam = SettingsCamera() self.camera = Camera() self.console = ConsoleThreadOutput() self.create_cam_widgets() self.p = parent self.fan = Fan(self.fanButton) self.lock = Locker() self.setting_values() self.one_photo = SThread() self.setLayout( set_lvbox( set_hbox(self.setField_temperature_label, self.setField_temperature), set_hbox(self.pre, self.prel), set_hbox(self.exp, self.expl), set_hbox(self.binning, self.combo), set_hbox(self.dark, self.close_open), set_hbox(self.tempo_fotos_label, self.tempo_fotos), set_hbox(self.time_colling_label, self.time_colling), set_hbox(self.contrast_msg), set_hbox(self.getlevel1, self.getlevel1l, self.getlevel2, self.getlevel2l), set_hbox(self.ignore_crop_l), set_hbox(self.crop_msg), set_hbox(self.crop_xi, self.getcropxi_l, self.crop_xf, self.getcropxf_l), set_hbox(self.crop_yi, self.getcropyi_l, self.crop_yf, self.getcropyf_l), set_hbox(self.image_tif_l), set_hbox(self.image_fit_l), set_hbox(self.btn_one_photo, self.tempButton, self.fanButton, stretch2=1), set_hbox(self.buttonok, self.button_clear, self.buttoncancel, stretch2=1)))
class ContinuousShooterThread(QtCore.QThread): signalAfterShooting = QtCore.pyqtSignal(name="signalAfterShooting") def __init__(self, timeSleep): super(ContinuousShooterThread, self).__init__() self.continuous = True self.s = timeSleep self.ss = SThread() self.ss.started.connect(self.thread_iniciada) self.console = ConsoleThreadOutput() self.count = 0 def set_sleep_time(self, t): self.s = t def run(self): self.count = 1 while self.continuous: try: self.ss.start() while self.ss.isRunning(): time.sleep(1) except Exception as e: print(e) time.sleep(self.s) self.signalAfterShooting.emit() def start_continuous_shooter(self): self.continuous = True def stop_continuous_shooter(self): self.count = 1 self.continuous = False def thread_iniciada(self): self.console.raise_text("Taking photo N: {}".format(self.count), 2) self.count += 1
def __init__(self, parent=None): super(FilterWindow, self).__init__(parent) self.setField_label_label = None self.setField_wavelength_label = None self.setField_exposure_label = None self.setField_binning_label = None self.setField_1 = None self.setField_label_filter1 = None self.setField_wavelength_filter1 = None self.setField_exposure_filter1 = None self.setField_binning_filter1 = None self.button_ok = None self.button_clear = None self.button_cancel = None self.create_filters_widgets() self.var_save_ini_filters = SettingsFilters() self.f = parent self.console = ConsoleThreadOutput() self.setting_values() self.setLayout( set_lvbox( set_hbox(self.setField_label_label, self.setField_wavelength_label, self.setField_exposure_label, self.setField_binning_label), set_hbox(self.setField_1, self.setField_label_filter1, self.setField_wavelength_filter1, self.setField_exposure_filter1, self.setField_binning_filter1), set_hbox(self.button_ok, self.button_clear, self.button_cancel, stretch2=1)))
def __init__(self, time_sleep): super(ContinuousShooterThread, self).__init__() self.continuous = True # SThread manda para o Sbigdriver as informações para se tirar a foto em si. self.ss = SThread() self.photo_type = self.ss.recebe_argumento self.ss.started.connect(self.thread_iniciada) self.console = ConsoleThreadOutput() self.count = 0 self.wait_temperature = False self.not_two_dark = True self.one_photo = False self.one_photo_shutter_state = None self.select_filter_manual = None self.select_filter_shutter = None
class ContinuousShooterThread(QtCore.QThread): """classe para modo manual""" signalAfterShooting = QtCore.pyqtSignal(name="signalAfterShooting") signal_temp = QtCore.pyqtSignal(name="signalTemp") def __init__(self, timeSleep): super(ContinuousShooterThread, self).__init__() self.continuous = True self.s = timeSleep self.ss = SThread() self.ss.started.connect(self.thread_iniciada) self.console = ConsoleThreadOutput() self.count = 0 self.wait_temperature = False self.not_two_dark = True def set_sleep_time(self, t): self.s = t def run(self): self.count = 1 while self.continuous: try: self.signal_temp.emit() if self.wait_temperature: self.ss.start() while self.ss.isRunning(): time.sleep(1) except Exception as e: print(e) time.sleep(self.s) self.signalAfterShooting.emit() def start_continuous_shooter(self): self.continuous = True def stop_continuous_shooter(self): self.wait_temperature = False self.continuous = False self.not_two_dark = False self.console.raise_text("Taking dark photo", 1) self.ss.take_dark() time.sleep(1) self.count = 1 def thread_iniciada(self): if self.count == 1: self.console.raise_text("Taking dark photo", 1) self.ss.take_dark() self.count += 1 self.not_two_dark = False elif self.count != 1: self.console.raise_text("Taking photo N: {}".format(self.count), 1) self.count += 1
def __init__(self): super(EphemerisShooter, self).__init__() self.camconfig = SettingsCamera() self.camconfig.setup_settings() infocam = self.camconfig.get_camera_settings() self.ObserverFactory = EphemObserverFactory() self.continuousShooterThread = ContinuousShooterThread(int(infocam[4])) self.console = ConsoleThreadOutput() self.config = ConfigProject() info = self.config.get_geographic_settings() self.latitude = info[0] # '-45.51' self.longitude = info[1] # '-23.12' self.elevation = info[2] # 350 info_sun = self.config.get_moonsun_settings() self.max_solar_elevation = float(info_sun[0]) # -12 self.ignore_lunar_position = info_sun[1] self.max_lunar_elevation = float(info_sun[2]) # 8 self.max_lunar_phase = float(info_sun[3]) # 1 self.wait_temperature = False print(int(infocam[4])) try: self.s = int(infocam[4]) self.continuousShooterThread.set_sleep_time(self.s) except Exception as e: self.s = 5 self.shootOn = False self.controller = True self.count = 1
def __init__(self, parent=None): super(SettingsWindow, self).__init__(parent) self.cam = SettingsCamera() self.camera = Camera() self.console = ConsoleThreadOutput() #self.a_temp_regulation = TempRegulation(self) self.create_cam_widgets() self.p = parent self.fan = Fan(self.fanButton) #self.button_clear = QtWidgets.QPushButton('Clear', self) self.setField_temperature = QtWidgets.QLineEdit(self) self.setting_values() self.one_photo = SThread() self.setLayout( set_lvbox( set_hbox(self.setField_temperature_label, self.setField_temperature), set_hbox(self.pre, self.prel), set_hbox(self.exp, self.expl), set_hbox(self.binning, self.combo), set_hbox(self.tempo_fotos_label, self.tempo_fotos), set_hbox(self.time_colling_label, self.time_colling), set_hbox(self.dark, self.close_open), set_hbox(self.getlevel1, self.getlevel1l), set_hbox(self.getlevel2, self.getlevel2l), set_hbox(self.btn_one_photo, self.tempButton, self.fanButton, stretch2=1), set_hbox(self.buttonok, self.button_clear, self.buttoncancel, stretch2=1)))
def __init__(self, parent=None): super(StartEndEphem, self).__init__(parent) self.start_obs_info_display = QtWidgets.QLabel(self) self.end_obs_info_display = QtWidgets.QLabel(self) self.total_obs_info_display = QtWidgets.QLabel(self) self.consolethreadoutput = ConsoleThreadOutput() self.schedstartend = SchedStartEnd( start_obs_info=self.start_obs_info_display, end_obs_info=self.end_obs_info_display, total_obs_info=self.total_obs_info_display) self.init_thread_start_end_obs() self.init_widgets() self.config_widgets() self.title = None
def __init__(self, parent=None): super(SettingsWindow, self).__init__(parent) self.cam = SettingsCamera() self.camera = Camera() self.console = ConsoleThreadOutput() #self.a_temp_regulation = TempRegulation(self) self.create_cam_widgets() self.p = parent self.fan = Fan(self.fanButton) #self.button_clear = QtWidgets.QPushButton('Clear', self) self.setField_temperature = QtWidgets.QLineEdit(self) self.setting_values() self.setLayout(set_lvbox(set_hbox(self.setField_temperature_label, self.setField_temperature), set_hbox(self.pre, self.prel), set_hbox(self.exp, self.expl), set_hbox(self.binning, self.combo), set_hbox(self.tempo_fotos_label, self.tempo_fotos), set_hbox(self.tempButton, self.fanButton, stretch2=1), set_hbox(self.buttonok, self.button_clear, self.buttoncancel, stretch2=1)))
def __init__(self): self.lock = Locker() self.console = ConsoleThreadOutput() self.settings = SettingsCamera() self.settings.setup_settings() self.fan = Fan() # Campos da janela principal para as informações da câmera self.firmware_field = None self.model_field = None self.main = Status() self.settedhour = datetime.now() self.continuousShooterThread = ContinuousShooterThread(int(self.settings.get_camera_settings()[4])) self.ephemerisShooterThread = EphemerisShooter() self.commands = CameraQThread(self) self.shooting = False # Initiating the Slots self.init_slots() self.temp = 0 self.temp_contador = 0
def __init__(self): self.lock = Locker() self.console = ConsoleThreadOutput()
class SettingsWindow(QtWidgets.QWidget): def __init__(self, parent=None): super(SettingsWindow, self).__init__(parent) self.p = parent self.console = ConsoleThreadOutput() self.site = WidgetsSite(self) self.geo = WidgetsGeography(self) self.sun = WidgetsSun(self) self.button_clear = QtWidgets.QPushButton('Clear', self) self.button_ok = QtWidgets.QPushButton('Save', self) self.button_cancel = QtWidgets.QPushButton('Cancel', self) self.button_settings() # Init Interface self.setting_up() self.refresh_all_fields() def button_settings(self): self.button_clear.clicked.connect(self.clear_all) self.button_cancel.clicked.connect(self.func_cancel) self.button_ok.clicked.connect(self.func_ok) def func_cancel(self): self.p.close() #self.clear_all() def func_ok(self): try: self.save_settings() self.console.raise_text("Project settings successfully saved!", 1) except: self.console.raise_text("Unable to save the project settings.", 3) finally: self.p.close() self.clear_all() self.refresh_all_fields() def clear_all(self): self.site.clear_site() self.geo.clear_geography() self.sun.clear_sun() def refresh_all_fields(self): try: st = ConfigProject() infoSite = st.get_site_settings() self.site.set_site_info(infoSite[0], infoSite[1], infoSite[2]) infoGeo = st.get_geographic_settings() self.geo.set_geography(infoGeo[0], infoGeo[1], infoGeo[2], infoGeo[3], infoGeo[4]) infoSun = st.get_moonsun_settings() self.sun.set_sun(str(infoSun[0]), infoSun[1], str(infoSun[2]), str(infoSun[3])) except Exception as e: print(e) def save_settings(self): try: st = ConfigProject() self.save_site(st) self.save_geo(st) self.save_sun(st) st.save_settings() except Exception as e: print(e) def save_site(self, set): info1 = self.site.get_site_info() set.set_site_settings(info1[0], info1[1], info1[2]) def save_geo(self, set): info2 = self.geo.get_geography() set.set_geographic_settings(info2[0], info2[1], info2[2], info2[3], info2[4]) def save_sun(self, set): info3 = self.sun.get_sun() set.set_moonsun_settings(info3[0], info3[1], info3[2], info3[3]) def setting_up(self): self.setLayout(set_lvbox(set_hbox(self.site), set_hbox(self.geo), set_hbox(self.sun), set_hbox(self.button_ok, self.button_clear, self.button_cancel, stretch2=1)))
def __init__(self): self._settings = QtCore.QSettings() self.setup_settings() self.console = ConsoleThreadOutput()
class Camera(metaclass=Singleton): def __init__(self): self.lock = Locker() self.console = ConsoleThreadOutput() self.settings = SettingsCamera() self.settings.setup_settings() self.fan = Fan() # Campos da janela principal para as informações da câmera self.firmware_field = None self.model_field = None self.main = Status() self.settedhour = datetime.now() self.continuousShooterThread = ContinuousShooterThread(int(self.settings.get_camera_settings()[4])) self.ephemerisShooterThread = EphemerisShooter() self.commands = CameraQThread(self) self.shooting = False # Initiating the Slots self.init_slots() self.temp = 0 self.temp_contador = 0 def init_slots(self): # Ephemeris Shooter Slots self.ephemerisShooterThread.started.connect(self.eshooter_started) self.ephemerisShooterThread.finished.connect(self.eshooter_finished) self.ephemerisShooterThread.signal_started_shooting.connect(self.shooter_mode) self.ephemerisShooterThread.signal_temp.connect(self.check_temp) self.ephemerisShooterThread.continuousShooterThread.started.connect(self.eshooter_observation_started) self.ephemerisShooterThread.continuousShooterThread.finished.connect(self.eshooter_observation_finished) # Criando connect da temperatura # self.ephemerisShooterThread.continuousShooterThread.signalAfterShooting.connect() self.continuousShooterThread.finished.connect(self.standby_mode) # Camera Commands Slots self.commands.finished.connect(self.eita) self.commands.connectSignal.connect(self.connect_mainwindow_update) def get_firmware_and_model(self): info = self.get_info() return str(info[0]), str(info[2])[2:len(str(info[2]))-1] def set_firmware_and_model_fields(self, firmwareField, modelField): self.firmware_field = firmwareField self.model_field = modelField def set_firmware_and_model_values(self): firmware, model = self.get_firmware_and_model() self.firmware_field.setText("Firmware: " + firmware) self.model_field.setText("Camera: " + model) def clear_firmware_and_model_values(self): self.firmware_field.setText("Firmware: ") self.model_field.setText("Camera: ") def get_info(self): """ Function to get the CCD Info This function will return [CameraFirmware, CameraType, CameraName] """ ret = None self.lock.set_acquire() try: ret = tuple(ccdinfo()) except Exception as e: self.console.raise_text("Failed to get camera information.\n{}".format(e)) finally: self.lock.set_release() return ret def connect(self): try: a = open_driver() open_deviceusb() c = establishinglink() if a is True and c is True: self.console.raise_text("Successfully connected! {} {}".format(a, c), 2) self.set_firmware_and_model_values() ''' Fan Field sera atualizado automaticamente atualizado pela thread de refresh temp. ''' # self.fan.refresh_fan_status() return True else: self.console.raise_text("Connection error", 3) except Exception as e: self.console.raise_text('Failed to connect the camera!\n{}'.format(e), 3) return False def disconnect(self): try: self.standby_mode() cd = close_device() cdr = close_driver() if cd and cdr: self.console.raise_text("Successfully disconnected!{} {}".format(cd, cdr), 2) self.clear_firmware_and_model_values() else: self.console.raise_text("Error disconnect! {} {}".format(cd, cdr), 3) except Exception as e: self.console.raise_text("It failed to disconnect the camera!\n{}".format(e), 3) def set_temperature(self, value): if getlinkstatus() is True: self.lock.set_acquire() try: set_temperature(regulation=True, setpoint=value, autofreeze=False) except Exception as e: self.console.raise_text("Error setting the temperature.\n{}".format(e), 3) finally: self.lock.set_release() self.console.raise_text("Temperature set to {}".format(int(value)), 1) else: self.console.raise_text("The camera is not connected!", 3) def get_temperature(self): temp = "None" try: if getlinkstatus() is True: if not self.lock.is_locked(): self.lock.set_acquire() temp = tuple(get_temperature())[3] self.temp = temp self.lock.set_release() else: temp = "None" else: # if getlinkstatus() is True: # sleep(1) # self.lock.set_acquire() # temp = tuple(get_temperature())[3] # self.lock.set_release() # else: temp = "None" except Exception as e: self.console.raise_text("Unable to retrieve the temperature.\n{}".format(e), 3) return temp def check_link(self): return getlinkstatus() # Camera Mode def standby_mode(self): self.set_temperature(15.00) self.fan.set_fan_off() def shooter_mode(self): self.set_temperature(-16.00) self.fan.set_fan_on() while self.get_temperature() < -15: sleep(1) # Shooters def start_taking_photo(self): try: if getlinkstatus() is True: self.continuousShooterThread.start_continuous_shooter() self.continuousShooterThread.start() else: self.console.raise_text("The camera is not connected", 3) except Exception as e: print(e) def stop_taking_photo(self): if getlinkstatus() is True: self.continuousShooterThread.stop_continuous_shooter() else: self.console.raise_text("The camera is not connected!", 3) def start_ephemeris_shooter(self): if getlinkstatus() is True: self.ephemerisShooterThread.start() else: self.console.raise_text("The camera is not connected!", 3) def stop_ephemeris_shooter(self): if getlinkstatus() is True: self.ephemerisShooterThread.stop_shooter() else: self.console.raise_text("The camera is not connected!", 3) # All PyQt Slots def eshooter_started(self): self.console.raise_text("Shooter Ephemeris Started!", 1) self.standby_mode() def eshooter_finished(self): self.console.raise_text('Shooter finalized', 1) def eshooter_observation_started(self): self.shooting = True self.console.raise_text("Observation Started", 1) def eshooter_observation_finished(self): self.console.raise_text("Observation Finalized", 1) self.standby_mode() self.shooting = False # Commands Slots def check_temp(self): if self.temp <= -15 or self.temp_contador == 60: self.ephemerisShooterThread.t = True else: self.console.raise_text("Temp_contador = " + str(self.temp_contador), 1) self.console.raise_text("CCD cooling to -15", 1) self.temp_contador += 1 def connect_mainwindow_update(self): self.set_firmware_and_model_values() self.fan.refresh_fan_status() def eita(self): self.console.raise_text(self.commands.text, 1)
class EphemerisShooter(QtCore.QThread): signal_started_shooting = QtCore.pyqtSignal(name="signalStartedShooting") signal_temp = QtCore.pyqtSignal(name="signalTemp") def __init__(self): super(EphemerisShooter, self).__init__() self.camconfig = SettingsCamera() self.camconfig.setup_settings() infocam = self.camconfig.get_camera_settings() self.ObserverFactory = EphemObserverFactory() self.continuousShooterThread = ContinuousShooterThread(int(infocam[4])) self.console = ConsoleThreadOutput() self.config = ConfigProject() info = self.config.get_geographic_settings() infosun = self.config.get_moonsun_settings() self.latitude = info[0] # '-45.51' self.longitude = info[1] # '-23.12' self.elevation = info[2] # 350 self.max_solar_elevation = infosun[0] # -12 self.ignore_lunar_position = infosun[1] self.max_lunar_elevation = infosun[2] # 8 self.max_lunar_phase = infosun[3] # 1 self.t = False print(int(infocam[4])) try: self.s = int(infocam[4]) self.continuousShooterThread.set_sleep_time(self.s) except Exception as e: self.s = 5 self.shootOn = False self.controller = True self.count = 1 def refresh_data(self): try: info = self.config.get_geographic_settings() self.latitude = info[0] # '-45.51' self.longitude = info[1] # '-23.12' self.elevation = info[2] # 350 infosun = self.config.get_moonsun_settings() self.max_solar_elevation = float(infosun[0]) # -12 self.ignore_lunar_position = infosun[1] self.max_lunar_elevation = float(infosun[2]) # 8 self.max_lunar_phase = float(infosun[3]) # 1 except Exception as e: self.console.raise_text("Exception thrown to acquire information\n" "Please set an observatory information on settings\n" + str(e), level=3) self.latitude = 0 self.longitude = 0 self.elevation = 0 self.max_solar_elevation = 0 self.max_lunar_elevation = 0 self.max_lunar_phase = 0 infocam = self.camconfig.get_camera_settings() try: self.s = int(infocam[4]) except Exception as e: self.s = 0 def calculate_moon(self, obs): aux = obs aux.compute_pressure() aux.horizon = '8' moon = ephem.Moon(aux) return aux.previous_setting(moon), aux.next_rising(moon) def calculate_sun(self, obs): aux = obs aux.compute_pressure() aux.horizon = '-12' sun = ephem.Sun(aux) return aux.previous_setting(sun), aux.next_rising(sun) def set_solar_and_lunar_parameters(self, maxSolarElevation, maxLunarElevation, maxLunarPhase): self.max_solar_elevation = maxSolarElevation self.max_lunar_elevation = maxLunarElevation self.max_lunar_phase = maxLunarPhase def run(self): self.refresh_data() obs = self.ObserverFactory.create_observer(longitude=self.longitude, latitude=self.latitude, elevation=self.elevation) self.controller = True self.shootOn = False c = 0 try: while self.controller: obs.date = ephem.date(datetime.datetime.utcnow()) sun = ephem.Sun(obs) moon = ephem.Moon(obs) frac = moon.moon_phase a = ephem.degrees(sun.alt) b = ephem.degrees(str(moon.alt)) # Variavel de controle do shooter t = 1 if float(math.degrees(a)) < self.max_solar_elevation or t == 1: if (self.ignore_lunar_position == False and float(math.degrees(b)) < self.max_lunar_elevation and frac < self.max_lunar_phase) or self.ignore_lunar_position: if not self.shootOn: if not c: self.signal_started_shooting.emit() c = 1 self.signal_temp.emit() time.sleep(5) if self.t: # Iniciar as Observações self.start_taking_photo() self.shootOn = True else: if self.shootOn: # Finalizar as Observações self.stop_taking_photo() c = 0 self.shootOn = False time.sleep(5) except Exception as e: self.console.raise_text("Exception no Ephemeris Shooter -> " + str(e)) def stop_shooter(self): self.controller = False self.continuousShooterThread.stop_continuous_shooter() def start_taking_photo(self): self.continuousShooterThread.set_sleep_time(self.s) self.continuousShooterThread.start_continuous_shooter() self.continuousShooterThread.start() def stop_taking_photo(self): self.continuousShooterThread.stop_continuous_shooter()
class Shooter(QtWidgets.QWidget): """ Class for Taking photo Widget """ def __init__(self, parent=None): super(Shooter, self).__init__(parent) self.console = ConsoleThreadOutput() self.cam = Camera() self.cond = 0 self.sref_calc = SettingsCamera() # Label for Image self.img = QtWidgets.QLabel(self) self.config_img_label() # Creating a Pallete self.pa = QtGui.QPalette() self.set_layout() self.link_signals() def log_ephem_infos(self): elevations = make_elevations_info() headers_camera = get_camera_settings() temp = SbigDriver.get_temperature()[3] set_temp = headers_camera[0] ephem_infos_1 = "Sun Elevation: " + str(elevations[2]) + "; Moon Elevation: " + str(elevations[1]) +\ "; Moon Phase: " + str(elevations[0]) self.console.save_log(ephem_infos_1) time.sleep(1) ephem_infos_2 = "Camera Temperature: " + "{0:.2f}".format(temp) + "; Set Temperature: " +\ set_temp + "; Status Temp. Filtro: 25ºC" self.console.save_log(ephem_infos_2) def link_signals(self): self.cam.ephemerisShooterThread.continuousShooterThread.ss.finished.connect( self.get_image_automatic) self.cam.continuousShooterThread.ss.finished.connect( self.get_image_manual) def get_image_automatic(self): img = self.cam.ephemerisShooterThread.continuousShooterThread.ss.get_image_info( ) self.set_image(img) def get_image_manual(self): img = self.cam.continuousShooterThread.ss.get_image_info() self.set_image(img) def set_layout(self): hb2 = set_hbox(self.prefix, self.date, self.hour) self.setLayout(set_lvbox(set_hbox(self.img), hb2)) self.config_pallete() def config_img_label(self): self.img.setPixmap(QtGui.QPixmap("noimage.png")) self.img.setMaximumSize(425, 425) self.prefix = QtWidgets.QLabel(self) self.date = QtWidgets.QLabel(self) self.hour = QtWidgets.QLabel(self) def config_pallete(self): self.pa.setColor(QtGui.QPalette.Foreground, QtCore.Qt.red) # Setting the style self.prefix.setPalette(self.pa) self.date.setPalette(self.pa) self.hour.setPalette(self.pa) def shoot_function(self): self.cam.shoot(int(self.tb.text()), self.pre.text(), int(self.combo.currentIndex())) self.set_image() def auto_shoot(self): try: self.cam.autoshoot(int(self.htext.text()), int(self.mtext.text()), int(self.tb.text()), self.pre.text(), int(self.combo.currentIndex())) except Exception as e: print(e) def set_image(self, img): print("Setting Pixmap") print("CCCCCCCCCCCCCCCCCCCCCCCCCCC") try: path = img.final_image_name # image = Image.open(path)] try: if os.path.splitext(path)[1] == '.fit': print("1111111111111111111") img = getdata(path) else: print("222222222222222222222") # img = skimage.io.imread('/home/cristiano') img = skimage.io.imread(path) print("\n\n>>>>>>>>>>>>>>>>>>>>>>") print(img) except Exception as e: print("Exception os.path.splitext -> {}".format(e)) image = img #im sref_min = float(self.sref_calc.get_camera_settings()[6]) sref_max = float(self.sref_calc.get_camera_settings()[7]) img_hist_equal = Image_Processing.img_hist_equal( image, sref_min, sref_max) im3 = toimage(img_hist_equal) im4 = im3.resize((int(425), int(425))) im5 = Image_Processing.draw_image(im4, path) try: qim = ImageQt(im5) self.img.setPixmap(QtGui.QPixmap.fromImage(qim)) except Exception as e: print( "Exception setPixmap(QtGui.QPixmap(image_to_show)) -> {}". format(e)) print(path) self.log_ephem_infos() except Exception as e: print("Exception Setting Pixmap -> {}".format(e)) def fill_combo(self): self.combo.addItem("1x1", 0) self.combo.addItem("2x2", 1) self.combo.addItem("3x3", 2) def clear_image_info(self): self.prefix.clear()
class Fan(metaclass=Singleton): def __init__(self): self.lock = Locker() self.console = ConsoleThreadOutput() def set_fanField(self, fanField): self.fanField = fanField def fan_status(self): # Acquiring the Lock self.lock.set_acquire() status = True try: # Doing requisition to Driver status = SbigDriver.is_fanning() except Exception as e: self.console.raise_text("Error acquiring the status of Fan.\n{}".format(e)) # Release the Lock self.lock.set_release() return "ON" if status else "OFF" def refresh_fan_status(self): self.fanField.setText(self.fan_status()) def set_fan(self): t = Thread(target=self.s_fan) t.start() def s_fan(self): self.lock.set_acquire() try: if SbigDriver.is_fanning(): SbigDriver.stop_fan() self.fanField.setText('Fan Off') else: SbigDriver.start_fan() self.fanField.setText('Fan On') except Exception as e: self.console.raise_text("Error off/on the Fan.\n{}".format(e)) finally: self.lock.set_release() self.fanField.setText(self.fan_status()) def set_fan_off(self): self.lock.set_acquire() try: SbigDriver.stop_fan() except Exception as e: self.console.raise_text("Error off/on the Fan.\n{}".format(e)) finally: self.lock.set_release() self.fanField.setText(self.fan_status()) def set_fan_on(self): self.lock.set_acquire() try: SbigDriver.start_fan() except Exception as e: self.console.raise_text("Error off/on the Fan.\n{}".format(e)) finally: self.lock.set_release() self.fanField.setText(self.fan_status())
class SettingsWindow(QtWidgets.QWidget): def __init__(self, parent=None): super(SettingsWindow, self).__init__(parent) self.cam = SettingsCamera() self.camera = Camera() self.console = ConsoleThreadOutput() #self.a_temp_regulation = TempRegulation(self) self.create_cam_widgets() self.p = parent self.fan = Fan(self.fanButton) #self.button_clear = QtWidgets.QPushButton('Clear', self) self.setField_temperature = QtWidgets.QLineEdit(self) self.setting_values() self.setLayout(set_lvbox(set_hbox(self.setField_temperature_label, self.setField_temperature), set_hbox(self.pre, self.prel), set_hbox(self.exp, self.expl), set_hbox(self.binning, self.combo), set_hbox(self.tempo_fotos_label, self.tempo_fotos), set_hbox(self.tempButton, self.fanButton, stretch2=1), set_hbox(self.buttonok, self.button_clear, self.buttoncancel, stretch2=1))) def get_values(self): return self.cam.get_camera_settings() def setting_values(self): info = self.get_values() self.set_values(info[0], info[1], info[2], info[3], info[4]) def set_values(self, temperature_camera, prefixo, exposicao, binning, tempo_entre_fotos): self.setField_temperature.setText(temperature_camera) self.prel.setText(prefixo) self.expl.setText(exposicao) try: b = int(binning) except: b = 0 self.tempo_fotos.setText(tempo_entre_fotos) self.combo.setCurrentIndex(b) def create_cam_widgets(self): self.setField_temperature_label = QtWidgets.QLabel("Temperature:", self) self.pre = QtWidgets.QLabel("Filter:", self) self.prel = QtWidgets.QLineEdit(self) self.exp = QtWidgets.QLabel("Exposure time:", self) self.expl = QtWidgets.QLineEdit(self) self.binning = QtWidgets.QLabel("Binning:", self) self.combo = QtWidgets.QComboBox(self) self.fill_combo() self.button_clear = QtWidgets.QPushButton('Clear', self) self.button_clear.clicked.connect(self.clear_all) self.tempButton = QtWidgets.QPushButton("Set Temp", self) self.tempButton.clicked.connect(self.btn_temperature) self.fanButton = QtWidgets.QPushButton("Fan") self.fanButton.clicked.connect(self.button_fan_func) self.buttonok = QtWidgets.QPushButton("Save", self) self.buttonok.clicked.connect(self.button_ok_func) self.buttoncancel = QtWidgets.QPushButton("Cancel", self) self.buttoncancel.clicked.connect(self.func_cancel) self.tempo_fotos_label = QtWidgets.QLabel("Time between photos:", self) self.tempo_fotos = QtWidgets.QLineEdit(self) def button_ok_func(self): try: # Setting the Temperature '''value = self.setField_temperature.text() if value is '': value = 20 self.camera.set_temperature(float(value))''' # Saving the Settings self.cam.set_camera_settings(self.setField_temperature.text(), self.prel.text(), self.expl.text(), self.combo.currentIndex(), self.tempo_fotos.text()) self.cam.save_settings() self.console.raise_text("Camera settings successfully saved!", 1) except Exception as e: self.console.raise_text("Camera settings were not saved.", 3) finally: self.p.close() def clear_all(self): self.setField_temperature.clear() self.prel.clear() self.expl.clear() self.tempo_fotos.clear() def func_cancel(self): self.p.close() def button_fan_func(self): if getlinkstatus() is True: try: self.fan.set_fan() self.console.raise_text('State changed Fan!', 2) except Exception: self.console.raise_text("The camera is not connected!", 3) self.console.raise_text('State Fan unchanged', 3) else: self.console.raise_text("The camera is not connected!", 3) self.console.raise_text('State Fan unchanged', 3) def fill_combo(self): self.combo.addItem("1x1", 0) self.combo.addItem("2x2", 1) self.combo.addItem("3x3", 2) def btn_temperature(self): try: value = self.setField_temperature.text() if value is '': pass else: self.camera.set_temperature(float(value)) except Exception as e: print("Exception -> {}".format(e))