Esempio n. 1
0
    def make_from_preferences(cls, preferences: Preferences):
        """Create a DataModel instance from the saved preferences"""
        model = DataModel()
        model.set_default_frame_count(preferences.get_default_frame_count())
        model.set_target_adus(preferences.get_target_adus())
        model.set_adu_tolerance(preferences.get_adu_tolerance())
        model.set_server_address(preferences.get_server_address())
        model.set_port_number(preferences.get_port_number())
        model.set_warm_when_done(preferences.get_warm_when_done())
        model.set_use_filter_wheel(preferences.get_use_filter_wheel())
        model.set_filter_specs(preferences.get_filter_spec_list())
        model.set_binning_specs(preferences.get_binning_spec_list())
        model.set_save_files_locally(False)
        model.set_flat_frame_count_table(
            FlatFrameTable(preferences.get_default_frame_count(),
                           preferences.get_filter_spec_list(),
                           preferences.get_binning_spec_list()))
        model.set_source_alt(float(preferences.get_source_alt()))
        model.set_source_az(float(preferences.get_source_az()))
        model.set_dither_flats(bool(preferences.get_dither_flats()))
        model.set_dither_radius(float(preferences.get_dither_radius()))
        model.set_dither_max_radius(float(preferences.get_dither_max_radius()))

        return model
Esempio n. 2
0
    def load_ui_from_prefs(self, preferences: Preferences):
        """Load the UI fields from the given preferences"""

        # Filter wheel?
        ufw = preferences.get_use_filter_wheel()
        self.ui.useFilterWheel.setChecked(ufw if ufw is not None else False)
        self.enable_filter_fields()

        # Number of flats
        self.ui.numFlats.setText(str(preferences.get_default_frame_count()))

        # Target ADUs
        self.ui.targetADUs.setText(str(preferences.get_target_adus()))
        self.ui.aduTolerance.setText(str(preferences.get_adu_tolerance() * 100.0))

        # Server address and port number
        self.ui.serverAddress.setText(preferences.get_server_address())
        self.ui.portNumber.setText(str(preferences.get_port_number()))

         # Information about slewing to the flat light source

        self.ui.sourceAlt.setText(str(round(preferences.get_source_alt(), 4)))
        self.ui.sourceAz.setText(str(round(preferences.get_source_az(), 4)))

        # Dithering

        self.ui.ditherFlats.setChecked(preferences.get_dither_flats())
        self.ui.ditherRadius.setText(str(preferences.get_dither_radius()))
        self.ui.ditherMaxRadius.setText(str(preferences.get_dither_max_radius()))

        # Filter specifications
        filter_specs = preferences.get_filter_spec_list()
        fs: FilterSpec
        for fs in filter_specs:
            check_box_name: str = f"useFilter_{fs.get_slot_number()}"
            this_check_box: QCheckBox = self.ui.findChild(QCheckBox, check_box_name)
            assert this_check_box is not None
            this_check_box.setChecked(fs.get_is_used())
            name_field_name: str = f"filterName_{fs.get_slot_number()}"
            this_name_field: QLineEdit = self.ui.findChild(QLineEdit, name_field_name)
            assert this_name_field is not None
            this_name_field.setText(fs.get_name())

        # Binning specifications
        binning_specs = preferences.get_binning_spec_list()
        bs: BinningSpec
        for bs in binning_specs:
            this_default_name: str = f"binDefault_{bs.get_binning_value()}"
            this_available_name: str = f"binAvailable_{bs.get_binning_value()}"
            this_off_name: str = f"binOff_{bs.get_binning_value()}"
            default_button: QRadioButton = self.ui.findChild(QRadioButton, this_default_name)
            assert default_button is not None
            available_button: QRadioButton = self.ui.findChild(QRadioButton, this_available_name)
            assert available_button is not None
            off_button: QRadioButton = self.ui.findChild(QRadioButton, this_off_name)
            assert off_button is not None
            if bs.get_is_default():
                default_button.setChecked(True)
            elif bs.get_is_available():
                available_button.setChecked(True)
            else:
                off_button.setChecked(True)