Beispiel #1
0
    def initialize_axis(self, axis):
        def set_pos(move_done, axis=axis):
            if move_done:
                self.set_position(axis, axis.dial()*axis.steps_per_unit)

        self._axis_moves[axis] = {
            "measured_simul": False,
            "measured_noise": 0.0,
            "end_t": 0,
            "end_pos": 0,
            "move_done_cb": set_pos }

        event.connect(axis, "move_done", set_pos)

        # this is to test axis are initialized only once
        axis.settings.set('init_count', axis.settings.get('init_count') + 1)

        # Add new axis oject methods as tango commands.
        add_axis_method(axis, self.custom_park, types_info=("None", "None"))
        add_axis_method(axis, self.custom_get_forty_two, types_info=("None", "int"))
        add_axis_method(axis, self.custom_get_twice, types_info=("int", "int"))
        add_axis_method(axis, self.custom_get_chapi, types_info=("str", "str"))
        add_axis_method(axis, self.custom_send_command, types_info=("str", "None"))
        add_axis_method(axis, self.custom_command_no_types, types_info=("None", "None"))
        add_axis_method(axis, self.custom_set_measured_noise, types_info=("float", "None"))

        add_axis_method(axis, self.put_discrepancy, types_info=("int", "None"))


        if axis.encoder:
            self.__encoders.setdefault(axis.encoder, {})["axis"] = axis
Beispiel #2
0
    def initialize_axis(self, axis):
        axis.driver = axis.config.get("driver", str)
        axis.channel = axis.config.get("channel", int)
        axis.accumulator = None

        event.connect(axis, "move_done", self._axis_move_done)

        # self._write_no_reply(axis, "JOF") #, raw=True)
        self._write_no_reply(axis, "MON %s" % axis.driver)
Beispiel #3
0
    def initialize_axis(self, axis):
        """
        - Reads specific config
        - Adds specific methods
        - Switches piezo to ONLINE mode so that axis motion can be caused
        by move commands.

        Args:
            - <axis>
        Returns:
            - None
        """
        axis.channel = axis.config.get("channel", int)
        axis.chan_letter = axis.config.get("chan_letter")

        add_axis_method(axis, self.get_id, types_info=(None, str))

        '''Closed loop'''
        add_axis_method(axis, self.open_loop, types_info=(None, None))
        add_axis_method(axis, self.close_loop, types_info=(None, None))

        '''DCO'''
        add_axis_method(axis, self.activate_dco, types_info=(None, None))
        add_axis_method(axis, self.desactivate_dco, types_info=(None, None))

        '''GATE'''
        # to enable automatic gating (ex: zap)
        add_axis_method(axis, self.enable_auto_gate, types_info=(bool, None))

        # to trig gate from external device (ex: HPZ with setpoint controller)
        add_axis_method(axis, self.set_gate, types_info=(bool, None))

        if axis.channel == 1:
            self.ctrl_axis = axis

        # NO automatic gating by default.
        self.auto_gate_enabled = False

        '''end of move event'''
        event.connect(axis, "move_done", self.move_done_event_received)

        # Enables the closed-loop.
        # self.sock.write("SVO 1 1\n")

        self.send_no_ans(axis, "ONL %d 1" % axis.channel)

        # VCO for velocity control mode ?
        # self.send_no_ans(axis, "VCO %d 1" % axis.channel)

        # Updates cached value of closed loop status.
        self.closed_loop = self._get_closed_loop_status(axis)

        # Reads high/low limits of the piezo to use in set_gate
        self.low_limit  = self._get_low_limit(axis)
        self.high_limit = self._get_high_limit(axis)
Beispiel #4
0
    def test_move_done_event(self):
        res = {"ok": False}

        def callback(move_done, res=res):
            if move_done:
                res["ok"] = True
        roby = emotion.get_axis("roby")
        roby_pos = roby.position()
        robz = emotion.get_axis("robz")
        robz_pos = robz.position()
        event.connect(self.grp, "move_done", callback)
        self.grp.rmove({robz: 2, roby: 3})
        self.assertEquals(res["ok"], True)
        self.assertEquals(robz.position(), robz_pos+2)
        self.assertEquals(roby.position(), roby_pos+3)
Beispiel #5
0
 def initialize_axis(self, axis):
     CalcController.initialize_axis(self, axis)
     event.connect(axis, "s_param", self._calc_from_real)