Exemplo n.º 1
0
def status(*devlist):
    """Read the status of one or more devices.

    If no device is given, read the status of all readable devices.

    Examples:

    >>> status()        # display status of all devices
    >>> status(T)       # status of the T device
    >>> status(T, B)    # status of the T and B devices
    """
    if not devlist:
        devlist = [
            session.devices[devname] for devname in session.explicit_devices
            if isinstance(session.devices[devname], Readable)
        ]
        devlist.sort(key=lambda dev: dev.name.lower())
    for dev in devlist:
        dev = session.getDevice(dev, Readable)
        try:
            status = dev.status()
        except Exception:
            dev.log.exception('error reading status')
        else:
            if status[0] in (OK, BUSY):
                dev.log.info('status is %s', formatStatus(status))
            else:
                dev.log.warning('status is %s', formatStatus(status))
Exemplo n.º 2
0
def reset(*devlist):
    """Reset the given device(s).

    This can restore communication with the device, re-set a positioning fault
    or make a reference drive (only for devices where this cannot lead to
    crashes, such as slits).

    Examples:

    >>> reset(ss1)        # reset a single device
    >>> reset(ss1, ss2)   # reset multiple devices
    """
    for dev in devlist:
        dev = session.getDevice(dev, Readable)
        status = dev.reset()
        dev.log.info('reset done, status is now %s', formatStatus(status))
Exemplo n.º 3
0
    def doPrepare(self):
        """Prepare measurement sequence.

        This method will raise a `NicosError` when a sequence is already in
        progress. Otherwise the internal sequence state is set to `status.OK`
        which also helps starting a new sequence when a previous sequence ended
        up in fault state.

        Derived implementations should first call this method and might call
        `doPrepare` on attached devices.

        """
        if self._seq_is_running():
            if self._mode == SIMULATION:
                self._seq_thread.join()
                self._seq_thread = None
            else:
                raise NicosError(self, 'Cannot start device, it is still busy')

        if self._seq_status[0] > status.OK and not self._seq_was_stopped:
            self.log.warning('resetting internal state %s',
                             formatStatus(self._seq_status))
        self._set_seq_status(status.OK, 'preparing measurement')