示例#1
0
    def load_additional_args(self, config):
        """
        """
        self.set_attribute(config, 'request_powermin', 'General',
                           'power min', cast='float')
        self.set_attribute(config, 'request_powermax', 'General',
                           'power max', cast='float')

        # read in the coefficients from file
        coeffs = self.config_get(config, 'PowerMeter', 'coefficients')
        if coeffs is not None:
            self.power_meter_calibration = MeterCalibration(coeffs)

        coeffs = self.config_get(config, 'PowerOutput', 'coefficients')
        if coeffs is not None:

            p = os.path.join(paths.hidden_dir, '{}_power_calibration'.format(self.name.split('.')[0]))

            obj = MeterCalibration(coeffs)
            # dump to the hidden dir
            # the manager will use it directly
            try:
                self.info('loading power calibration from config file')
                with open(p, 'wb') as f:
                    pickle.dump(obj, f)
            except (OSError, pickle.PickleError):
                self.warning('failed loading power output calibration')

        return super(FusionsCO2LogicBoard, self).load_additional_args(config)
示例#2
0
    def _set_coeff_string(self, v):
        cal = self.calibration
        if cal is None:
            cal = MeterCalibration()
            self.calibration = cal

        cal.coeff_string = v
    def load_power_calibration(self, calibration_path=None, verbose=True, warn=True):
#        calibration_path = self._get_calibration_path(calibration_path)
#        if os.path.isfile(calibration_path):
#            if verbose:
#                self.info('loading power calibration {}'.format(calibration_path))

#            with open(calibration_path, 'rb') as f:
#                try:
#                    pc = pickle.load(f)
#                except (pickle.PickleError, EOFError, OSError), e:
#                    self.warning('unpickling error {}'.format(e))
#                    pc = MeterCalibration([1, 0])

#        else:
#            pc = MeterCalibration([1, 0])

        if self.parent is not None:
            lb = self.parent.laser_controller
            config = lb.get_configuration()
            section = 'PowerOutput'
            if config.has_section(section):
                coefficients = config.get(section, 'coefficients')
                cs = self._parse_coefficient_string(coefficients, warn)
                if cs is None:
                    return
            else:
                cs = [1, 0]

        pc = MeterCalibration(cs)
        return pc
    def _apply_calibration(self):

        if self.confirmation_dialog('Apply Calibration'):
            self._calculate_calibration()
#            pc = PowerCalibrationObject()
            pc = MeterCalibration(self._coefficients)
            self.dump_calibration(pc)
示例#5
0
    def _calibration_factory(self, calibration):
        coeffs = None
        if calibration == 'watts':
            config = self.get_configuration()
            coeffs = self._get_watt_calibration_coefficients(config)

        if coeffs is None:
            coeffs = [1, 0]
        return MeterCalibration(coeffs)
示例#6
0
    def _dump_calibration(self):
        pc = MeterCalibration()
        coeffs = []
        bounds = []
        for s in self.selected_calibrations:
            coeffs.append(s.coefficients)
            bounds.append(s.calibration_bounds)
        pc.coefficients = coeffs
        pc.bounds = bounds

        p = self._get_calibration_path()
        self.info('saving calibration to {}'.format(p))
        with open(p, 'wb') as f:
            pickle.dump(pc, f)
示例#7
0
    def _calibration_factory(self, calibration):
        coeffs = None
        nmapping = False
        if calibration == 'watts':
            path = os.path.join(paths.device_dir, self.configuration_dir_name,
                                'calibrated_power.cfg')
            if os.path.isfile(path):
                config = self.get_configuration(path=path)
                coeffs, nmapping = self._get_watt_calibration(config)

        if coeffs is None:
            coeffs = [1, 0]

        return MeterCalibration(coeffs, normal_mapping=bool(nmapping))
示例#8
0
    def load_additional_args(self, config):
        """
        """
        self.set_attribute(config, 'use_pid_bin', 'Output', 'use_pid_bin', cast='boolean', default=False)
        self.set_attribute(config, 'min_output_scale', 'Output', 'scale_low', cast='float')
        self.set_attribute(config, 'max_output_scale', 'Output', 'scale_high', cast='float')

        self.set_attribute(config, 'setpointmin', 'Setpoint', 'min', cast='float')
        self.set_attribute(config, 'setpointmax', 'Setpoint', 'max', cast='float')

        self.set_attribute(config, 'memory_blocks_enabled', 'MemoryBlock', 'enabled', cast='boolean')
        if self.memory_blocks_enabled:
            self.set_attribute(config, 'program_memory_blocks', 'MemoryBlock', 'program', cast='boolean')
            #            if self.program_memory_blocks:
        #                self.memory_blocks=[]
        #                for option in config.options('MemoryBlock'):
        #                    if option.startswith('block'):
        #                        self.memory_blocks.append(config.get('MemoryBlock',option))

        coeffs = self.config_get(config, 'Calibration', 'coefficients')
        if coeffs:
            self.calibration = MeterCalibration(coeffs)
            # self.use_calibrated_temperature = True
        return True
    def _save_fired(self):
#        pc = PowerCalibrationObject()
        pc = MeterCalibration(self.coefficients)
        self.dump_power_calibration(pc.coefficients)