示例#1
0
def delete_unused_bliss_axes():
    """
    Removes BlissAxisManager axes that are not running.
    """
    # get BlissAxis (only from current instance).
    bliss_axis_device_names = get_devices_from_server().get('BlissAxis')
    elog.info("Axes: %r" % bliss_axis_device_names)
示例#2
0
    def _set_closed_loop(self, axis, onoff = True):
        """
        Sets Closed loop status (Servo state) (SVO command)
        """

        axis.closed_loop = onoff
        self.command("SVO %s %d" % (axis.channel, onoff))
        elog.debug("Piezo Servo %r" % onoff)


        # Only when closing loop: waits to be ON-Target.
        if onoff:
            _t0 = time.time()
            cl_timeout = .5

            _ont_state = self._get_on_target_status(axis)
            elog.info(u'axis {0:s} waiting to be ONTARGET'.format(axis.name))
            while (not _ont_state) and (time.time() - _t0) < cl_timeout:
                time.sleep(0.01)
                print ".",
                _ont_state = self._get_on_target_status(axis)
            if not _ont_state:
                elog.error('axis {0:s} NOT on-target'.format(axis.name))
                raise RuntimeError("Unable to close the loop : "
                                   "not ON-TARGET after %gs :( " % cl_timeout)
            else:
                elog.info('axis {0:s} ONT ok after {1:g} s'.format(axis.name, time.time() - _t0))

        # Updates bliss setting (internal cached) position.
        axis._position()  # "POS?"
示例#3
0
    def __init__(self, name, config, axes, encoders):
        Controller.__init__(self, name, config, axes, encoders)

        self._axis_moves = {}

        self.factor = 1

        # config
        _target_attribute_name = self.config.get("target_attribute")
        _gating_ds = self.config.get("gating_ds")

        try:
            self.target_attribute = AttributeProxy(_target_attribute_name)
        except:
            elog.error("Unable to connect to attrtribute %s " % _target_attribute_name)

        # External DS to use for gating.
        # ex: PI-E517 for zap of HPZ.
        if _gating_ds is not None:
            self.gating_ds = DeviceProxy(_gating_ds)
            self.external_gating = True
            elog.info("external gating True ; gating ds= %s " % _gating_ds)
        else:
            # No external gating by default.
            self.external_gating = False

        # _pos0 must be in controller unit.
        self._pos0 = self.target_attribute.read().value * self.factor
        elog.info("initial position : %g (in ctrl units)" % self._pos0)
示例#4
0
文件: PI_E51X.py 项目: mguijarr/bliss
 def enable_auto_gate(self, axis, value):
     if value:
         # auto gating
         self.auto_gate_enabled = True
         elog.info("PI_E51X.py : enable_gate %s for axis.channel %s " %(str(value) , axis.channel) )
     else:
         self.auto_gate_enabled = False
示例#5
0
文件: PI_E51X.py 项目: mguijarr/bliss
    def send(self, axis, cmd):
        """
        - Adds the 'newline' terminator character : "\\\\n"
        - Sends command <cmd> to the PI E51X controller.
        - Channel is defined in <cmd>.
        - <axis> is passed for debugging purposes.
        - Returns answer from controller.

        Args:
            - <axis> : passed for debugging purposes.
            - <cmd> : GCS command to send to controller (Channel is already mentionned  in <cmd>).

        Returns:
            - 1-line answer received from the controller (without "\\\\n" terminator).

        """
        _cmd = cmd + "\n"
        _t0 = time.time()

        # PC
        _ans = "toto"
        _ans = self.sock.write_readline(_cmd)
        _duration = time.time() - _t0
        if _duration > 0.005:
            elog.info("PI_E51X.py : Received %r from Send %s (duration : %g ms) " % (_ans, _cmd, _duration * 1000))

        # Check error code
        _err = self.sock.write_readline("ERR?\n")
        if _err != "0":
            print ":( error read: %s on send(%r)" % (_err, _cmd)

        return _ans
示例#6
0
    def read_velocity(self, axis):
        """
        Args:
            - <axis> : Bliss axis object.
        Returns:
            - <velocity> : float
        """
        _ans = self.send(axis, "?VEL")
        # _ans should looks like '0.2 0.1' (yes with single quotes arround...)
        # First field is velocity (in V/ms)
        # Second field is "line waiting" (hummmm second field is not always present ???)
        _ans = _ans[1:][:-1]

        # (_vel, _line_waiting) = map(float, _ans.split())
        _float_ans = map(float, _ans.split())
        if len(_float_ans) == 1:
            _vel = _float_ans[0]
        elif len(_float_ans) == 2:
            (_vel, _line_waiting) = _float_ans
        else:
            elog.info("WHAT THE F.... ?VEL answer is there ???")

        #     V/s = V/ms * 1000
        _velocity = _vel * 1000

        elog.debug("read_velocity : %g " % _velocity)
        return _velocity
示例#7
0
 def stop(self, motion):
     elog.debug("stop() called")
     error, reply = self.__xps.GroupMoveAbort(motion.axis.group + '.' + motion.axis.name)
     if error == -22:
         elog.info("NewportXPS: All positioners idle")
     elif error != 0 and error != -22:
         elog.error("NewportXPS Error: ", reply)
示例#8
0
 def stop_all(self, *motion_list):
     elog.debug("stop_all() called")
     error, reply = self.__xps.GroupMoveAbort(motion_list[0].axis.group)
     if error == -22:
         elog.info("NewportXPS: All positioners idle")
     elif error != 0:
         elog.error("NewportXPS Error: ", reply)
示例#9
0
 def stop_all(self, *motion_list):
     elog.debug("stop_all() called")
     error, reply = self.__xps.GroupMoveAbort(motion_list[0].axis.group)
     if error == -22:
         elog.info("NewportXPS: All positioners idle")
     elif error != 0:
         elog.error("NewportXPS Error: ", reply)
示例#10
0
 def test_info(self):
     log.level(log.INFO)
     with wrapped_stdout() as stdout:
         log.info("test")
     output = stdout.getvalue()
     self.assertEquals(
         output,
         "INFO: test\n")
示例#11
0
    def initialize(self):
        """Controller initialization"""
        tacomaxe_info("initialize() called")

        # Get controller from bliss config
        self.taconame = self.config.get("tacodevice")
        log.info("my taconame is %r"%self.taconame)
	self.device = MyTacoDevice.TacoDevice(self.taconame)
示例#12
0
 def stop(self, motion):
     elog.debug("stop() called")
     error, reply = self.__xps.GroupMoveAbort(motion.axis.group + '.' +
                                              motion.axis.name)
     if error == -22:
         elog.info("NewportXPS: All positioners idle")
     elif error != 0 and error != -22:
         elog.error("NewportXPS Error: ", reply)
示例#13
0
def __recreate_axes(server_name, manager_dev_name, axis_names,
                    dev_map, db=None):
    db = db or tango.Database()

    curr_axes = {}
 
    for dev_class, dev_names in dev_map.items():
        if not dev_class.startswith('BlissAxis_'):
            continue
        for dev_name in dev_names:
            curr_axis_name = dev_name.rsplit("/", 1)[-1]

            try:
                get_axis(curr_axis_name)
            except:
                elog.info("Error instantiating %s (%s):" % (curr_axis_name, dev_name))
                traceback.print_exc()
            curr_axes[curr_axis_name] = dev_name, dev_class

    axis_names_set = set(axis_names)
    curr_axis_names_set = set(curr_axes)
    new_axis_names = axis_names_set.difference(curr_axis_names_set)
    old_axis_names = curr_axis_names_set.difference(axis_names_set)

    domain, family, member = manager_dev_name.split('/', 2)

    # remove old axes
    for axis_name in old_axis_names:
        dev_name, klass_name = curr_axes[axis_name]
        elog.debug('removing old axis %s (%s)' % (dev_name, axis_name))
        db.delete_device(dev_name)

    # add new axes
    for axis_name in new_axis_names:
        dev_name = "%s/%s_%s/%s" % (domain, family, member, axis_name)
        info = tango.DbDevInfo()
        info.server = server_name
        info._class = 'BlissAxis_' + axis_name
        info.name = dev_name
        elog.debug('adding new axis %s (%s)' % (dev_name, axis_name))
        db.add_device(info)
        # try to create alias if it doesn't exist yet
        try:
            db.get_device_alias(axis_name)
        except tango.DevFailed:
            elog.debug('registering alias for %s (%s)' % (dev_name, axis_name))
            db.put_device_alias(dev_name, axis_name)

    axes, tango_classes = [], []
    for axis_name in axis_names_set:
        axis = get_axis(axis_name)
        axes.append(axis)
        tango_class = __create_tango_axis_class(axis)
        tango_classes.append(tango_class)

    return axes, tango_classes
示例#14
0
    def off(self,tloop):
        """
        Stops the regulation on the loop
           Raises NotImplementedError if not defined by inheriting class

        Args: 
           tloop:  Loop class type object
        """
        log.info("Controller:on:" )
        raise NotImplementedError
示例#15
0
    def setpoint_abort(self,toutput):
        """
	Aborts the setpoint (emergency stop)
           Raises NotImplementedError if not defined by inheriting class

        Args:
           toutput:  Output class type object
        """
        log.info("Controller:setpoint_stop")
        raise NotImplementedError
示例#16
0
    def Wraw(self, str):
        """
        A string to write to the controller
           Raises NotImplementedError if not defined by inheriting class

        Args:
           str:  the string to write
        """
        log.info("Controller:Wraw:" )
        raise NotImplementedError
示例#17
0
    def Rraw(self):
        """
        Reading the controller
           Raises NotImplementedError if not defined by inheriting class

        returns:
           response from the controller
        """
        log.info("Controller:Rraw:" )
        raise NotImplementedError
示例#18
0
    def set_step(self, toutput, step):
        """
        Sets the step value (for ramp stepping mode)
           Raises NotImplementedError if not defined by inheriting class

        Args:
           toutput:  Output class type object 
           step
       """
        log.info("Controller:set_step: %s" % (toutput))
        raise NotImplementedError
示例#19
0
 def home_search(self, axis, switch):
     elog.debug("home_search() called")
     # Moves the motor to a repeatable starting location allows
     # homing only once after a power cycle.
     error, reply = self.__xps.GroupHomeSearch(axis.group)
     if error == 0:
         elog.info("NewportXPS: homing successful")
     elif error == -22:
         elog.info("NewportXPS: Controller already homed")
     else:
         elog.error("NewportXPS: Controller homing failed: ", error)
示例#20
0
    def set_ramprate(self, toutput, rate):
        """
        Sets the ramp rate
           Raises NotImplementedError if not defined by inheriting class

        Args:
           toutput:  Output class type object 
           rate:     ramp rate
       """
        log.info("Controller:set_ramprate: %s" % (toutput))
        raise NotImplementedError
示例#21
0
    def set_kd(self, tloop, kd):
        """
        Sets the PID D value
           Raises NotImplementedError if not defined by inheriting class

        Args:
           tloop:  Loop class type object 
           kd
       """
        log.info("Controller:set_kd: %s" % (toutput))
        raise NotImplementedError
示例#22
0
    def set(self, toutput, sp, **kwargs):
        """
        Send the command to go to a setpoint as quickly as possible
           Raises NotImplementedError if not defined by inheriting class

        Args:
           toutput:  Output class type object 
           sp:       setpoint
           **kwargs: auxilliary arguments
        """
        log.info("Controller:set: %s" % (toutput))
        raise NotImplementedError
示例#23
0
    def WRraw(self, str):
        """
        Write then Reading the controller
           Raises NotImplementedError if not defined by inheriting class

        Args:
           str:  the string to write
        returns:
           response from the controller
        """
        log.info("Controller:WRraw:" )
        raise NotImplementedError
示例#24
0
    def init_device(self):
        self.debug_stream("In init_device() of axis")
        self.get_device_properties(self.get_device_class())

        # -v1
        self.info_stream("INFO STREAM ON ++++++++++++++++++++++++++")
        self.warn_stream("WARN STREAM ON ++++++++++++++++++++++++++")
        self.error_stream("ERROR STREAM ON ++++++++++++++++++++++++++")
        self.fatal_stream("FATAL STREAM ON ++++++++++++++++++++++++++")

        # -v3 (-v == -v4)
        self.debug_stream("DEBUG STREAM ON ++++++++++++++++++++++++++")

        try:
            self.axis = TgGevent.get_proxy(bliss.get_axis, self._axis_name)
            self.kontroler = TgGevent.get_proxy(self.axis.controller)
        except:
            elog.error("unable to get kontroller or axis")
            self.set_status(traceback.format_exc())

        self.debug_stream("axis found : %s" % self._axis_name)

        self.once = False

        self._init_time = time.time()
        self._t = time.time()

        self.attr_Home_position_read = 0.0
        self.attr_StepSize_read = 0.0
        self.attr_Steps_per_unit_read = 0.0
        self.attr_Acceleration_read = 1.0
        self.attr_HardLimitLow_read = False
        self.attr_HardLimitHigh_read = False
        self.attr_Backlash_read = 0.0
        self.attr_Offset_read = 0.0
        self.attr_Tolerance_read = 0.0
        self.attr_PresetPosition_read = 0.0
        self.attr_FirstVelocity_read = 0.0

        """
        self.attr_Steps_read = 0
        self.attr_Position_read = 0.0
        self.attr_Measured_Position_read = 0.0
        self.attr_Home_side_read = False
        """

        self.attr_trajpar_read = [[0.0]]

        # To force update of state and status.
        self.dev_state()

        # elog.info("    %s" % self.axis.get_info())
        elog.info(" BlissAxisManager.py Axis " + bcolors.PINK + self._ds_name + bcolors.ENDC + " initialized")
示例#25
0
    def get_setpoint(self, toutput):
        """Get the setpoint value on a Output object

        Returned value is None if not setpoint is set
        """
        channel = toutput.config.get("channel",str)
        log.debug("mockup: get_setpoint %s" % (channel))
        try:
            log.info("mockup: get_setpoint: returns %s" % (self.setpoints[channel]["target"]))
            return self.setpoints[channel]["target"]
        except KeyError:
            pass
示例#26
0
    def start_ramp(self, toutput, sp, **kwargs):
        """
        Send the command to start ramping to a setpoint
           Raises NotImplementedError if not defined by inheriting class

        Args:
           toutput:  Output class type object 
           sp:       setpoint
           **kwargs: auxilliary arguments
        """
        log.info("Controller:start_ramp: %s" % (toutput))
        raise NotImplementedError
示例#27
0
def delete_bliss_axes():
    """
    Removes BlissAxisManager axis devices from the database.
    """
    db = PyTango.Database()

    bliss_axis_device_names = get_devices_from_server().get('BlissAxis')

    for _axis_device_name in bliss_axis_device_names:
        elog.info("Deleting existing BlissAxisManager axis: %s" %
                  _axis_device_name)
        db.delete_device(_axis_device_name)
示例#28
0
    def state_output(self,toutput):
        """
        Return a string representing state of an 'outputs' object.
           Raises NotImplementedError if not defined by inheriting class

        Args:
           toutput:  Output class type object

        Returns:
           object state string. This is one of READY/RUNNING/ALARM/FAULT
        """
        log.info("Controller:state_output:" )
        raise NotImplementedError
示例#29
0
    def read_ramprate(self, toutput):
        """
        Reads the ramp rate
           Raises NotImplementedError if not defined by inheriting class

        Args:
           toutput:  Output class type object 
        
        Returns:
           ramp rate
        """
        log.info("Controller:read_ramprate: %s" % (toutput))
        raise NotImplementedError
示例#30
0
    def get_setpoint(self, toutput):
        """
        Return current setpoint
           Raises NotImplementedError if not defined by inheriting class

        Args:
           toutput:  Output class type object 

        Returns:
           (float) setpoint value. Must be None if not setpoint is set
        """
        log.info("Controller:get_setpoint: %s" % (toutput))
        raise NotImplementedError
示例#31
0
    def read_step(self, toutput):
        """
        Reads the dwell value (for ramp stepping mode)
           Raises NotImplementedError if not defined by inheriting class

        Args:
           toutput:  Output class type object 
        
        Returns:
           step value
        """
        log.info("Controller:read_step: %s" % (toutput))
        raise NotImplementedError
示例#32
0
    def read_kd(self, tloop):
        """
        Reads the PID D value
           Raises NotImplementedError if not defined by inheriting class

        Args:
           tloop:  Output class type object 
        
        Returns:
           kd value
        """
        log.info("Controller:read_kd: %s" % (toutput))
        raise NotImplementedError