NICOS core APIs and classes.
Base device classes for usage in NICOS.
Bases: object
Abstract mixin for devices that are created automatically as dependent devices of other devices.
Bases: object
An object that has a list of parameters that are read from the configuration and have default values.
Subclasses can implement:
User methods
Return a list of versions for this device.
Parameters
A description of the device. Default value: ''.
The logging level of the device. Default value: 'info'.
Whether the device is not interesting to users. Default value: False.
Bases: type
Bases: type
A metaclass that automatically adds properties for the class’ parameters, and determines a list of user methods (“commands”).
It also merges attached_devices, parameters and parameter_overrides defined in the class with those defined in all base classes.
Bases: nicos.core.device.Moveable
Bases: Moveable
Mixin for “simple” continuously moveable devices that have limits.
Parameters
Absolute limits of device value. Unit: same as device value.
User defined limits of device value. Default value: (0.0, 0.0). Unit: same as device value.
Parameters inherited from the base classes: description, fixed, fmtstr, loglevel, lowlevel, maxage, pollinterval, target, unit
Bases: object
Mixin class for Readable or Moveable devices that want to provide an ‘offset’ parameter and that can be adjusted via adjust().
This is not directly a feature of Moveable, because providing this transparently this would mean that doRead() returns the un-adjusted value while read() returns the adjusted value. It would also mean that the un-adjusted value is stored in the cache, which is wrong for monitoring purposes.
Instead, each class that provides an offset must inherit this mixin, and subtract/add self.offset in doRead()/doStart().
Parameters
Offset of device zero to hardware zero. Default value: 0.0. Unit: same as device value.
Bases: object
Mixin class for Readable and Moveable devices that want to provide a ‘precision’ parameter.
This is mainly useful for user info, and for high-level devices that have to work with limited-precision subordinate devices.
Parameters
Precision of the device value. Default value: 0.0. Unit: same as device value.
Bases: nicos.core.device.Readable
Bases: Readable
Base class for devices used for data acquisition.
Subclasses need to implement:
Subclasses can implement:
User methods
Return true if measurement is complete.
Pause the measurement, if possible.
Return a tuple with the result(s) of the last measurement.
Resume paused measurement.
Set the new standard preset for this detector.
Start measurement, with either the given preset or the standard
Stop measurement now.
Wait for completion of the measurement.
Parameters inherited from the base classes: description, fmtstr, loglevel, lowlevel, maxage, pollinterval, unit
Bases: nicos.core.device.Readable
Bases: Readable
Base class for moveable devices.
Subclasses need to implement:
Subclasses can implement:
User methods
Fix the device: don’t allow movement anymore.
Check if the given position can be moved to.
Move to target and wait for completion.
Start movement of the device to a new position.
Release the device, i.e. undo the effect of fix().
Start movement of the device to a new position.
Stop any movement of the device.
Wait until movement of device is completed.
Parameters
None if the device is not fixed, else a string describing why. Default value: ''.
Last target position of a start() action. Default value: 'unknown'. Unit: same as device value.
Parameters inherited from the base classes: description, fmtstr, loglevel, lowlevel, maxage, pollinterval, unit
Bases: nicos.core.device.Device
Bases: Device
Base class for all readable devices.
Subclasses need to implement:
Subclasses can implement:
User methods
Read the (possibly cached) main value of the device.
Reset the device hardware. Returns the new status afterwards.
Return the (possibly cached) status of the device.
Parameters
Format string for the device value. Default value: '%.3f'.
Maximum age of cached value and status (zero to never use cached values, or None to cache them indefinitely). Default value: 6. Unit: s.
Polling interval for value and status (or None to disable polling). Default value: 5. Unit: s.
Unit of the device main value.
Parameters inherited from the base classes: description, loglevel, lowlevel
Decorator to implement user access control.
The access is checked based on the keywords given. Currently, the keywords with meaning are:
The wrapper function calls Session.checkAccess to verify the requirements. If the check fails, AccessError is raised.
Decorator that marks a method as a user-visible method.
The method will be shown to the user in the help for a device.
Exception classes for usage in NICOS.
Bases: nicos.core.errors.NicosError
Bases: NicosError
Exception to be raised when an action is forbidden to the current user.
Used by the requires decorator.
Bases: nicos.core.errors.NicosError
Bases: NicosError
Exception to be raised when a cache lock cannot be acquired.
Bases: nicos.core.errors.NicosError
Bases: NicosError
Exception to be raised when some hardware communication fails.
Bases: nicos.core.errors.NicosError
Bases: NicosError
Exception to be raised when a computation fails.
Examples are the conversion of physical values to logical values.
Bases: nicos.core.errors.NicosError
Bases: NicosError
Exception to be raised when an error in the setup is detected, or a device is supplied with invalid configuration data.
Bases: nicos.core.errors.NicosError
Bases: NicosError
Exception to be raised on fatal hardware errors.
Bases: nicos.core.errors.NicosError
Bases: NicosError
Exception to be raised when the user gives an invalid value to a device (as a move target or parameter value).
Bases: nicos.core.errors.NicosError
Bases: NicosError
Exception to be raised when a requested move target is out of limits.
Bases: nicos.core.errors.NicosError
Bases: NicosError
Exception to be raised when an action is not allowed in the current execution mode.
Bases: nicos.core.errors.NicosError
Bases: NicosError
Exception to be raised when errors occur while moving a device.
Bases: exceptions.Exception
Bases: Exception
The basic exception class for exceptions raised by NICOS.
Every NicosError subclass has a “category” attribute, a string that is shown to the user instead of the exception class.
The constructor also accepts a Device instance as its first argument, which is then used to display the error to the user as coming from this device. For example:
def doRead(self):
if not self._ready:
raise NicosError(self, 'device is not ready')
The constructor accepts a the keyword wikicode with an integer argument to create a link to a wiki page
where more information can be given. The integer should be the Unix timestamp (e.g from date +%%s, to get a uniqe id) of the first use of this specific error. To create the wiki page, log in to trac and enter ‘wiki:NicosError/<integer>’ in the search box on the upper right.
Bases: nicos.core.errors.NicosError
Bases: NicosError
Exception to be raised when a device detects an undefined position.
For example, this should be raised when several coders do not agree.
Bases: nicos.core.errors.NicosError
Bases: NicosError
Exception to be raised when an error in the code is detected.
This should not occur during normal operation.
Bases: nicos.core.errors.NicosError
Bases: NicosError
Exception to be raised when a timeout waiting for hardware occurs.
This is not a communication timeout; for that purpose CommunicationError should be used.
Bases: nicos.core.errors.NicosError
Bases: NicosError
Exception to be raised when user commands are used wrongly.
When this exception is caught by the user command handler, the help for the command that was executed is shown.
Parameter definition helpers and typechecking combinators.
Bases: object
This class defines the overridden properties of a base class parameter.
The Device.parameter_overrides attribute contains a mapping of parameter names to instances of this class.
Overriding parameters allows to share parameters with the base class, but still have slightly different behavior for the parameters. For example, for a general Moveable device the unit parameter is mandatory. However, for some subclasses this will not be necessary, since the unit can either be automatically determined from the device, or the value never has any unit. Instead of redefining the unit parameter in subclasses, you only need to override its mandatory property in the subclass like this:
parameter_overrides = {'unit': Override(mandatory=False)}
The constructor takes all keywords that the Param constructor accepts. These properties of the parameter are then overridden compared to the base class.
Bases: object
This class defines the properties of a device parameter.
The Device.parameters attribute contains a mapping of parameter names to instances of this class.
Attributes (equivalent to constructor arguments):
Bases: object
This class defines the properties of the “value” read from Readable and Measurable classes. Their valueInfo method must return a tuple of instances of this class.
any value
a valid taco device
a 3-vector
Status code definitions.
NICOS core utility functions.
Combine the status of multiple devices to form a single status value.
This is typically called in the doStatus method of “superdevices” that control several attached devices.
The resulting state value is the highest value of all devices’ values (i.e. if all devices are OK, it will be OK, if one is BUSY, it will be BUSY, but if one is ERROR, it will be ERROR).
The resulting state text is a combination of the status texts of all devices.
Wait for the device status to return exit the busy state.
delay is the delay between status inquiries, and busystates gives the state values that are considered as “busy” states; by default only status.BUSY.