コード例 #1
0
ファイル: IcePAP.py プロジェクト: mguijarr/bliss
    def initialize_axis(self, axis):
        """Axis initialization"""
        self.log_info("initialize_axis() called for axis %r" % axis.name)

        # Get axis config from bliss config
        # address form is XY : X=rack {0..?} Y=driver {1..8}
        axis.address = axis.config.get("address", int)

        # Create an IcePAP lib axis object
        device = self.libdevice
        address = axis.address
        name = axis.name
        axis.libaxis = libicepap.Axis(device, address, name)

        # Add the axis to the default IcePAP lib group
        self.libgroup.add_axis(axis.libaxis)

        # Initialiaze hardware
        # if set_power fails, display exception but let axis
        # be created properly
        try:
            self.libgroup.set_power(libicepap.ON, axis.libaxis)
        except:
            sys.excepthook(*sys.exc_info())

        # Add new axis oject methods
        add_axis_method(axis, self.get_identifier, types_info=("None", "str"))
コード例 #2
0
ファイル: ID31Diffract.py プロジェクト: mguijarr/bliss
 def initialize_axis(self, axis):
     orig_initialize_axis(self, axis)
     for name, ptype in ctrl_pars.items():
         mname = 'set_%s' % name
         method = getattr(self, mname)
         add_axis_method(axis, method, mname, types_info=(ptype, 'None'))
         mname = 'get_%s' % name
         method = getattr(self, mname)
         add_axis_method(axis, method, mname, types_info=('None', ptype))
コード例 #3
0
ファイル: FlexDC.py プロジェクト: mguijarr/bliss
    def initialize_axis(self, axis):

        axis.channel = axis.config.get("channel")

        if axis.channel == "X":
            self.ctrl_axis = axis

        axis.target_radius = axis.config.get("target_radius", int)
        axis.target_time = axis.config.get("target_time", int)
        axis.min_dead_zone = axis.config.get("min_dead_zone", int)
        axis.max_dead_zone = axis.config.get("max_dead_zone", int)
        axis.smoothing = axis.config.get("smoothing", int)
        axis.deceleration = axis.config.get("deceleration", float)

        add_axis_method(axis, self.get_id)

        # Enabling servo mode.
        self._flexdc_query("%sMO=1" % axis.channel)

        # Sets "point to point" motion mode.
        # 0 -> point to point
        # ( 1 -> jogging ;    2 -> position based gearing    )
        # ( 5 -> position based ECAM ;    8 -> Step command (no profile) )
        self._flexdc_query("%sMM=0" % axis.channel)

        # Special motion mode attribute parameter
        # 0 -> no special mode
        # ( 1 -> repetitive motion )
        self._flexdc_query("%sSM=0" % axis.channel)

        # Defines smoothing (typically 4).
        self._flexdc_query("%sWW=%d" % (axis.channel, axis.smoothing))

        # Target Time (settling time?)
        self.flexdc_parameter(axis, "TT", axis.target_time)

        # Target Radius (target window ?)
        self.flexdc_parameter(axis, "TR", axis.target_radius)

        # Checks if closed loop parameters have been set.
        _ans = self._flexdc_query("%sTT" % axis.channel)
        if _ans == "0":
            elog.error("Missing closed loop param TT (Target Time)!!")

        _ans = self._flexdc_query("%sTR" % axis.channel)
        if _ans == "0":
            elog.error("Missing closed loop param TR (Target Radius)!!")

        # Minimum dead zone
        self.flexdc_parameter(axis, "CA[36]", axis.min_dead_zone)

        # Maximum dead zone
        self.flexdc_parameter(axis, "CA[37]", axis.max_dead_zone)
コード例 #4
0
ファイル: TacoMaxe.py プロジェクト: mguijarr/bliss
    def initialize_axis(self, axis):
        """Axis initialization"""
        tacomaxe_info("initialize_axis() called for axis \"%s\"" % axis.name)

        # Get axis config from bliss config
        axis.channel = axis.config.get("channel", int)
        axis.myvelocity = axis.config.get("velocity", int)
        axis.mybacklash = axis.config.get("backlash", int)
        axis.myacceleration = axis.config.get("acceleration", int)
        axis.steps_per_u = axis.config.get("steps_per_unit", int)

	add_axis_method(axis, self.custom_read_firststeprate,types_info=("None","float"))
	add_axis_method(axis, self.custom_set_firststeprate,types_info=("float","None"))
コード例 #5
0
ファイル: PiezoJack.py プロジェクト: mguijarr/bliss
    def initialize_axis(self, axis):
        """

        :type self: object
        """
        # To get rid of cache coherency problems.
        add_axis_method(axis, self.sync, name="sync", types_info=(None, None))
        add_axis_method(axis, self.set_log_level, name="SetLogLevel", types_info=(int, None))

        # Reads sensors coefficients (previously calibrated...) for the current piezo axis
        # from the PI E712
        self.piezo.coeffs = self.piezo.controller.get_sensor_coeffs(self.piezo)
        if self.bender_factor < 0 and self.piezo.coeffs[1] > 0 or self.bender_factor > 0 and self.piezo.coeffs[1] < 0:
            # Needed, when in the table, when senson works the opposite way
            self.piezo.controller.set_sensor_coeffs(self.piezo, 1, -self.piezo.coeffs[1])
        print "--PJ-- coefficients", self.bender_factor, self.piezo.coeffs[1], self.piezo.coeffs #HWHWHW
コード例 #6
0
ファイル: VSCANNER.py プロジェクト: mguijarr/bliss
    def initialize_axis(self, axis):
        """
        - Reads specific config
        - Adds specific methods
        """
        # can be "X" or "Y"
        axis.chan_letter = axis.config.get("chan_letter")

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

        axis.config.config_dict.update({"steps_per_unit": {"value": axis.config.get("steps_per_unit")}})

        ini_pos = self.read_position(axis)
        if ini_pos < 0:
            elog.info("reseting VSCANNER negative position to 0 !!")
            _cmd = "V%s 0" % (axis.chan_letter)
            self.send_no_ans(axis, _cmd)

        if ini_pos > 10:
            elog.info("reseting VSCANNER >10-position to 10 !!")
            _cmd = "V%s 10" % (axis.chan_letter)
            self.send_no_ans(axis, _cmd)
コード例 #7
0
ファイル: PMD206.py プロジェクト: mguijarr/bliss
    def initialize_axis(self, axis):
        """
        Args:
            - <axis>
        Returns:
            - None
        """
        axis.channel = axis.config.get("channel", int)

        # Stores one axis to talk to the controller.
        if axis.channel == 1:
            self.ctrl_axis = axis
            elog.debug("AX CH =%r" % axis.channel)

        # Adds new axis oject methods.
        add_axis_method(axis, self.park_motor, types_info=("None", "None"))
        add_axis_method(axis, self.unpark_motor, types_info=("None", "None"))
        add_axis_method(axis, self.raw_write_read_axis, types_info=(str, str))
コード例 #8
0
ファイル: IcePAPTraj.py プロジェクト: mguijarr/bliss
    def initialize_axis(self, axis):
        """Axis initialization"""
        self.log_info("initialize_axis() called for axis %r" % axis.name)

        # Get the list of IcePAP axes
        axes_names = axis.config.get("axislist").split()
        if len(axes_names) == 0:
            raise ValueError('missing mandatory config parameter "axislist"')

        # Check the list of IcePAP axes
        dev = None
        for axis_name in axes_names:

            # Get EMotion axis object
            hw_axis = bliss.get_axis(axis_name)

            # Check that it's an IcePAP controlled one
            if type(hw_axis.controller).__name__ is not 'IcePAP':
                raise ValueError('invalid axis "%s", not an IcePAP'%axis_name)

            # Get underlying libicepap object
            axis_dev = hw_axis.controller.libdevice
            if dev is None:
                dev = axis_dev

            # Let's impone that the trajectories work only on the same system
            if axis_dev.hostname() != dev.hostname():
                raise ValueError( 
                    'invalid axis "%s", not on the same IcePAP'%axis_name)

        # At this point we have configuration
        # Create an empty libicepap trajectory object
        self.libtraj[axis] = libicepap.Trajectory(axis.name)

        # Keep a record of axes
        for axis_name in axes_names:
            self.axes_names.append(axis_name)
            hw_axis = bliss.get_axis(axis_name)
            self.axis_list[axis_name] = hw_axis

        # Keep a record of the IcePAP system for faster access
        self.libdevice = dev

        # Add new axis oject methods
        add_axis_method(axis, self.set_parameter)
        add_axis_method(axis, self.get_parameter)
        add_axis_method(axis, self.set_trajectory)
        add_axis_method(axis, self.drain)
        add_axis_method(axis, self.load)
        add_axis_method(axis, self.sync)
コード例 #9
0
ファイル: ID31Diffract.py プロジェクト: mguijarr/bliss
 def initialize_axis(self, axis):
     super(ID31Diffract, self).initialize_axis(axis)
     add_axis_method(axis, self.get_lm_2th, types_info=('None', 'float'))
     if axis.name in self.has_extra:
         self.has_extra[axis.name] = True
コード例 #10
0
ファイル: PI_E51X.py プロジェクト: mguijarr/bliss
    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)
コード例 #11
0
ファイル: PI_E712.py プロジェクト: mguijarr/bliss
    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
        """
        elog.info("initialize_axis() called for axis %r" % axis.name)

        self._hw_status = AxisState("READY")


        """ Documentation uses the word AxisID instead of channel
            Note: any function used as axis method must accept axis as an argument! Otherwise
                  you will see:
                  TypeError: check_power_cut() takes exactly 1 argument (2 given)
        """
        axis.channel = axis.config.get("channel", int)

        add_axis_method(axis, self.check_power_cut, name = "CheckPowerCut", types_info = (None, None))
        add_axis_method(axis, self._get_tns, name = "Get_TNS", types_info = (None, float))
        add_axis_method(axis, self._get_tsp, name = "Get_TSP", types_info = (None, float))
        add_axis_method(axis, self._get_sva, name = "Get_SVA", types_info = (None, float))
        add_axis_method(axis, self._get_vol, name = "Get_VOL", types_info = (None, float))
        add_axis_method(axis, self._get_mov, name = "Get_MOV", types_info = (None, float))
        add_axis_method(axis, self._get_offset, name = "Get_Offset", types_info = (None, float))
        add_axis_method(axis, self._put_offset, name = "Put_Offset", types_info = (float, None))
        add_axis_method(axis, self._get_tad, name = "Get_TAD", types_info = (None, float))
        add_axis_method(axis, self._get_closed_loop_status, name = "Get_Closed_Loop_Status", types_info = (None, bool))
        add_axis_method(axis, self._set_closed_loop, name = "Set_Closed_Loop", types_info = (bool, None))
        #add_axis_method(axis, self._get_on_target_status, name = "Get_On_Target_Status", types_info = (None, bool))
        add_axis_method(axis, self._get_pos, name = "Get_Pos", types_info = (None, float))

        try:
            axis.paranoia_mode = axis.config.get("paranoia_mode")  # check error after each command
        except KeyError :
            axis.paranoia_mode = False

        self._gate_enabled = False

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

        elog.debug("axis = %r" % axis.name)
コード例 #12
0
ファイル: mockup.py プロジェクト: mguijarr/bliss
    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_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._set_closed_loop, name = "Set_Closed_Loop", types_info = (bool, None))

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


        if axis.encoder:
            self.__encoders.setdefault(axis.encoder, {})["axis"] = axis
コード例 #13
0
ファイル: PM600.py プロジェクト: mguijarr/bliss
    def initialize_axis(self, axis):
        log.debug("initialize_axis() called")
        axis.channel = axis.config.get("address")
        print self.GetId(axis.channel)
        
        axis.kf = axis.config.get("Kf", int, default=0)
        axis.kp = axis.config.get("Kp", int, default=10)
        axis.ks = axis.config.get("Ks", int, default=0)
        axis.kv = axis.config.get("Kv", int, default=0)
        axis.kx = axis.config.get("Kx", int)
        axis.slewrate = axis.config.get("velocity", int, default=1000)
        axis.accel = axis.config.get("acceleration", int, default=2000)
        axis.decel = axis.config.get("deceleration", int, default=3000)
        axis.creep_speed = axis.config.get("creep_speed", int, default=800)
        axis.creep_steps = axis.config.get("creep_steps", int, default=0)
        axis.limit_decel = axis.config.get("limit_decel", int, default=2000000)
        axis.settling_time = axis.config.get("settling_time", int, default=100)
#        axis.backoff_steps = axis.config.get("backoff_steps", int, default=0)
        axis.window = axis.config.get("window", int, default=4)
        axis.threshold = axis.config.get("threshold", int, default=50)
        axis.tracking = axis.config.get("tracking", int, default=4000)
        axis.timeout = axis.config.get("timeout", int, default=8000)
        axis.soft_limit_enable = axis.config.get("soft_limit_enable", int, default=1)
        axis.low_limit = axis.config.get("low_limit", int, default=-2000000000)
        axis.high_limit = axis.config.get("high_limit", int, default=2000000000)
        axis.gearbox_ratio_numerator = axis.config.get("gearbox_ratio_numerator", int, default=1)
        axis.gearbox_ratio_denominator = axis.config.get("gearbox_ratio_denominator", int, default=1)
        axis.encoder_ratio_numerator = axis.config.get("encoder_ratio_numerator", int, default=1)
        axis.encoder_ratio_denominator = axis.config.get("encoder_ratio_denominator", int, default=1)
        """
        # Set velocity feedforward on axis
        self.io_command("KF", axis.channel, axis.kf)
        # Set the proportional gain on axis
        self.io_command("KP", axis.channel, axis.kp)
        # Set the Sum gain on axis
        self.io_command("KS", axis.channel, axis.ks)
        # Set the Velocity feedback on axis
        self.io_command("KV", axis.channel, axis.kv)
        # Set the Extra Velocity feedback on axis
        self.io_command("KX", axis.channel, axis.kx)
        """
        # Set slew rate of axis (steps/sec)
        self.io_command("SV", axis.channel, axis.slewrate)
        # Set acceleration of axis (steps/sec/sec)
        self.io_command("SA", axis.channel, axis.accel)
         # Set deceleration of axis (steps/sec/sec)
        self.io_command("SD", axis.channel, axis.decel)
        # Set creep speed of axis (steps/sec/sec)
        self.io_command("SC", axis.channel, axis.creep_speed)
        # Set number of creep steps at the end of a move (steps)
        self.io_command("CR", axis.channel, axis.creep_steps)
        # Set the deceleration rate for stopping when hitting a Hard Limit or a Soft Limit
        self.io_command("LD", axis.channel, axis.limit_decel)
        # Set settling time (milliseconds)
        self.io_command("SE", axis.channel, axis.settling_time)
        # Set the Set the Window for axis (steps)
        self.io_command("WI", axis.channel, axis.window)
        # Set the threshold before motor stalled condition (%)
        self.io_command("TH", axis.channel, axis.threshold)
        # Set the tracking window of the axis (steps)
        self.io_command("TR", axis.channel, axis.tracking)
        # Set the axis time out (millisecond)
        self.io_command("TO", axis.channel, axis.timeout)
        #Sets the soft limits (enable = 1, disable = 0)
        self.io_command("SL", axis.channel, axis.soft_limit_enable)
        if axis.soft_limit_enable == 1:
            # Set the axis upper soft limit position (steps)
            self.io_command("UL", axis.channel, axis.high_limit)
            # Set the axis lower soft limit position (steps)
            self.io_command("LL", axis.channel, axis.low_limit)
        # Set encoder ratio
        cmd = "ER%d/%d" % (axis.encoder_ratio_numerator, axis.encoder_ratio_denominator)
        self.io_command(cmd, axis.channel)
        # Set gearbox ratio numerator
        self.io_command("GN", axis.channel, axis.gearbox_ratio_numerator)
        # Set gearbox ratio denominator
        self.io_command("GD", axis.channel, axis.gearbox_ratio_denominator)
        
        add_axis_method(axis, self.GetId, types_info=("int","str"))
        add_axis_method(axis, self.Reset, types_info=("int", "None"))
        add_axis_method(axis, self.GetDeceleration,types_info=("None","float"))
        add_axis_method(axis, self.SetDeceleration,types_info=("float","None"))