Exemple #1
0
    # if the target is reached (within precision), use it as the base for
    # the relative movement to avoid accumulating small errors
    curpos = dev.target if dev.isAtTarget(curpos) else curpos
    if isinstance(curpos, string_types):
        raise UsageError('Device %s cannot be used with relative movement' %
                         dev)
    try:
        return curpos + delta
    except Exception:
        raise UsageError('Device %s cannot be used with relative movement or '
                         'wrong delta type %r' % (dev, delta))


@usercommand
@helparglist('dev1, pos1, ...')
@spmsyntax(Multi(Dev(Moveable), Bare))
@parallel_safe
def move(*dev_pos_list):
    """Start moving one or more devices to a new position.

    This command will return immediately without waiting for the movement to
    finish.  For "move and wait", see `maw()`.

    The command can be used multiple times to move devices in parallel.
    Examples:

    >>> move(dev1, 10)    # start device1
    >>> move(dev2, -3)    # start device2

    However, in this case a shorter version is available:
Exemple #2
0
        if isinstance(args[0], (list, tuple)):
            values = list(zip(args[0]))
            restargs = args[1:]
        else:
            if len(args) < 3:
                raise UsageError('at least four arguments are required in '
                                 'start-step-end scan command')
            values = mkpos([args[0]], [args[1]], [args[2]])
            restargs = args[3:]
    devs = [session.getDevice(d, Moveable) for d in devs]
    return devs, values, restargs


@usercommand
@helparglist('dev, [start, step, end | listofpoints], t=seconds, ...')
@spmsyntax(Dev(Moveable), Bare, Bare, Bare)
def rscan(dev, *args, **kwargs):
    """Scan ranges over device(s) and count detector(s).

    The general syntax is either to give start, step and end:

    >>> rscan(dev, 0, 1, 10)   # scans from 0 to 10 in steps of 1.

    or a list of positions to scan:

    >>> rscan(dev, [0, 1, 2, 3, 7, 8, 9, 10])  # scans at the given positions.

    For floating point arguments, the length of the result is
    ``int(round((end - start) / step + 1)``. Because of floating point
    overflow, this rule may result in the last element being greater than
    ``end``, e.g.
Exemple #3
0
        elif isinstance(x, float):
            if abs(x) < 0.01:
                return '%.4g' % x
            return '%.4f' % x
        return repr(x)

    argsrepr = ', '.join(devrepr(a) for a in args if not isinstance(a, str))
    if kwargs:
        kwargsrepr = ', '.join('%s=%r' % kv for kv in kwargs.items())
        return '%s(%s, %s)' % (fn, argsrepr, kwargsrepr)
    return '%s(%s)' % (fn, argsrepr)


@usercommand
@helparglist('dev, [start, step, numpoints | listofpoints], ...')
@spmsyntax(Dev(Moveable), Bare, Bare, Bare)
def scan(dev, *args, **kwargs):
    """Scan over device(s) and count detector(s).

    A scan is used to collect data during the experiment depending on the
    position of one or more devices:

    - Move the devices to a new position, called a **point**, and wait until
      all devices have reached their position.
    - Start the detectors and wait until the requested time and/or monitor
      counts, called a **preset**, are reached.

    The output is a sequence of detector data corresponding to the device
    positions.

    The command has two basic modes: