def _load_button_fired(self):
        path = self.open_file_dialog(default_directory=paths.device_dir)
        # path = os.path.join(root_dir, 'zobs', 'NewStage-Axis-1.txt')
        if path is not None:

            # sniff the file to get the axis
            lines = parse_file(path)

            aid = lines[0][0]
            try:
                ax = self._get_axis_by_id(aid)
                func = ax.load_parameters_from_file
            except ValueError:
                # this is a txt file not a cfg
                ax = self._get_selected()
                if ax is not None:
                    func = ax.load

            if ax is not None:
                func(path)
    def _load_button_fired(self):
        path = self.open_file_dialog(default_directory=paths.device_dir)
        # path = os.path.join(root_dir, 'zobs', 'NewStage-Axis-1.txt')
        if path is not None:

            # sniff the file to get the axis
            lines = parse_file(path)

            aid = lines[0][0]
            try:
                ax = self._get_axis_by_id(aid)
                func = ax.load_parameters_from_file
            except ValueError:
                # this is a txt file not a cfg
                ax = self._get_selected()
                if ax is not None:
                    func = ax.load

            if ax is not None:
                func(path)
Exemplo n.º 3
0
    def _get_pid_bin(self, temp):
        """
            load pid_bins from file
        """
        if not self.configuration_dir_path:
            self.debug('no configuration_dir_path. this device was not initialized. check initialization.xml')
            return

        p = os.path.join(self.configuration_dir_path, 'pid.csv')
        if not os.path.isfile(p):
            self.warning('No pid.csv file in configuration dir. {}'.format(self.configuration_dir_path))
            return

        lines = parse_file(p, delimiter=',', cast=float)
        for i, li in enumerate(lines):
            if li[0] > temp:
                i = max(0, i - 1)

                return lines[i][1:]
        else:
            t = lines[-1][0]
            self.warning(
                'could not find appropriate bin for in pid file. using pid for {} bin. temp={}'.format(t, temp))
            return lines[-1][1:]
Exemplo n.º 4
0
    def load(self):
        lines = parse_file(self.file_path)
        if not lines:
            return

        # line 0 shape, dimension
        shape, dimension = lines[0].split(',')
        self.g_shape = shape
        self.g_dimension = float(dimension)

        # line 1 list of holes to default draw
        valid_holes = lines[1].split(',')

        # line 2 list of calibration holes
        # should always be N,E,S,W,center
        self.calibration_holes = lines[2].split(',')

        for hi, line in enumerate(lines[3:]):
            if not line.startswith('#'):
                try:
                    hole, x, y = line.split(',')
                except ValueError:
                    try:
                        x, y = line.split(',')
                        hole = str(hi + 1)
                    except ValueError:
                        break

                self.sample_holes.append(SampleHole(id=hole,
                                                     x=float(x),
                                                     y=float(y),
                                                     render='x' if hole in valid_holes else '',
                                                     shape=shape,
                                                     dimension=float(dimension)

                                                     ))
Exemplo n.º 5
0
    def load_parameters_from_file(self, path):
        """

        """
        self.loaded = False
        # self.kind='Commutated step motor'
        parameters = parse_file(path)
        #        with open(path, 'r') as f:
        #            parameters = []
        #            for line in f:
        #                parameters.append(line.strip())

        self._kind = int(parameters[0][-1:])  # QM
        self._unit = int(parameters[1][-1:])  # SN

        self.encoder_resolution = float(parameters[2][3:])  # SU
        self.encoder_full_step_resolution = float(parameters[3][3:])  # FR
        self.microstep_factor = float(parameters[4][3:])  # QS

        self.average_motor_voltage = float(parameters[5][3:])  # QV
        self.maximum_motor_current = float(parameters[6][3:])  # QI
        self.gear_constant = float(parameters[7][3:])  # QG
        self.tachometer_gain = float(parameters[8][3:])  # QT

        self.software_negative_limit = float(parameters[9][3:])  # SL
        self.software_positive_limit = float(parameters[10][3:])  # SR

        self._trajectory_mode = int(parameters[11][-1:]) - 1  # TJ
        self._home_search_mode = int(parameters[12][-1:])  # OM

        self.maximum_velocity = float(parameters[13][3:])  # VU
        self.velocity = float(parameters[14][3:])  # VA
        self.jog_high_speed = float(parameters[15][3:])  # JH
        self.jog_low_speed = float(parameters[16][3:])  # JW

        self.home_search_high_speed = float(parameters[17][3:])  # OH
        self.home_search_low_speed = float(parameters[18][3:])  # OL
        self.base_velocity = float(parameters[19][3:])  # VB

        self.maximum_acceleration_deceleration = float(
            parameters[20][3:])  # AU
        self.acceleration = float(parameters[21][3:])  # AC
        self.deceleration = float(parameters[22][3:])  # AG
        self.estop_deceleration = float(parameters[23][3:])  # AE

        self.jerk_rate = float(parameters[24][3:])  # JK

        self.proportional_gain = float(parameters[25][3:])  # KP
        self.integral_gain = float(parameters[26][3:])  # KI
        self.derivative_gain = float(parameters[27][3:])  # KD

        self.velocity_feed_forward_gain = float(parameters[28][3:])  # VF
        self.acceleration_feed_forward_gain = float(parameters[29][3:])  # AF

        self.integral_saturation_level = float(parameters[30][3:])  # KS

        self.maximum_following_error_threshold = float(
            parameters[31][3:])  # FE
        self.position_deadband = float(parameters[32][3:])  # DB

        self.update_interval = float(parameters[33][3:])  # CL

        a, b = parameters[34][3:].split(',')
        self.reduce_motor_torque_time = float(a)  # QR
        self.reduce_motor_torque_percent = float(b)  # QR

        self.slave_axis = int(parameters[35][3:])  # SS
        self.master_slave_reduction_ratio = float(parameters[36][3:])  # GR
        self.master_slave_jog_velocity_update = float(parameters[37][3:])  # SI
        self.master_slave_jog_velocity_scaling_coefficients = parameters[38][
            3:]  # SK

        self.backlash_compensation = float(parameters[39][3:])  # BA
        self.linear_compensation = float(parameters[40][3:])  # CO

        self._amplifier_io_configuration = int(parameters[41][3:-1], 16)  # ZA
        self._feedback_configuration = int(parameters[42][3:-1], 16)  # ZB
        self._estop_configuration = int(parameters[43][3:-1], 16)  # ZE
        self._following_error_configuration = int(parameters[44][3:-1],
                                                  16)  # ZF
        self._hardware_limit_configuration = int(parameters[45][3:-1],
                                                 16)  # ZH
        self._software_limit_configuration = int(parameters[46][3:-1],
                                                 16)  # ZS

        self.loaded = True
Exemplo n.º 6
0
    def load_parameters_from_file(self, path):
        """

        """
        self.loaded = False
        # self.kind='Commutated step motor'
        parameters = parse_file(path)
        #        with open(path, 'r') as f:
        #            parameters = []
        #            for line in f:
        #                parameters.append(line.strip())

        self._kind = int(parameters[0][-1:])  # QM
        self._unit = int(parameters[1][-1:])  # SN

        self.encoder_resolution = float(parameters[2][3:])  # SU
        self.encoder_full_step_resolution = float(parameters[3][3:])  # FR
        self.microstep_factor = float(parameters[4][3:])  # QS

        self.average_motor_voltage = float(parameters[5][3:])  # QV
        self.maximum_motor_current = float(parameters[6][3:])  # QI
        self.gear_constant = float(parameters[7][3:])  # QG
        self.tachometer_gain = float(parameters[8][3:])  # QT

        self.software_negative_limit = float(parameters[9][3:])  # SL
        self.software_positive_limit = float(parameters[10][3:])  # SR

        self._trajectory_mode = int(parameters[11][-1:]) - 1  # TJ
        self._home_search_mode = int(parameters[12][-1:])  # OM

        self.maximum_velocity = float(parameters[13][3:])  # VU
        self.velocity = float(parameters[14][3:])  # VA
        self.jog_high_speed = float(parameters[15][3:])  # JH
        self.jog_low_speed = float(parameters[16][3:])  # JW

        self.home_search_high_speed = float(parameters[17][3:])  # OH
        self.home_search_low_speed = float(parameters[18][3:])  # OL
        self.base_velocity = float(parameters[19][3:])  # VB

        self.maximum_acceleration_deceleration = float(parameters[20][3:])  # AU
        self.acceleration = float(parameters[21][3:])  # AC
        self.deceleration = float(parameters[22][3:])  # AG
        self.estop_deceleration = float(parameters[23][3:])  # AE

        self.jerk_rate = float(parameters[24][3:])  # JK

        self.proportional_gain = float(parameters[25][3:])  # KP
        self.integral_gain = float(parameters[26][3:])  # KI
        self.derivative_gain = float(parameters[27][3:])  # KD

        self.velocity_feed_forward_gain = float(parameters[28][3:])  # VF
        self.acceleration_feed_forward_gain = float(parameters[29][3:])  # AF

        self.integral_saturation_level = float(parameters[30][3:])  # KS

        self.maximum_following_error_threshold = float(parameters[31][3:])  # FE
        self.position_deadband = float(parameters[32][3:])  # DB

        self.update_interval = float(parameters[33][3:])  # CL

        a, b = parameters[34][3:].split(",")
        self.reduce_motor_torque_time = float(a)  # QR
        self.reduce_motor_torque_percent = float(b)  # QR

        self.slave_axis = int(parameters[35][3:])  # SS
        self.master_slave_reduction_ratio = float(parameters[36][3:])  # GR
        self.master_slave_jog_velocity_update = float(parameters[37][3:])  # SI
        self.master_slave_jog_velocity_scaling_coefficients = parameters[38][3:]  # SK

        self.backlash_compensation = float(parameters[39][3:])  # BA
        self.linear_compensation = float(parameters[40][3:])  # CO

        self._amplifier_io_configuration = int(parameters[41][3:-1], 16)  # ZA
        self._feedback_configuration = int(parameters[42][3:-1], 16)  # ZB
        self._estop_configuration = int(parameters[43][3:-1], 16)  # ZE
        self._following_error_configuration = int(parameters[44][3:-1], 16)  # ZF
        self._hardware_limit_configuration = int(parameters[45][3:-1], 16)  # ZH
        self._software_limit_configuration = int(parameters[46][3:-1], 16)  # ZS

        self.loaded = True