Mixin class for TACO devices.
Use it in concrete device classes like this:
class Counter(TacoDevice, Measurable):
taco_class = IO.Counter
# more overwritten methods
i.e., put TacoDevice first in the base class list.
TacoDevice provides the following methods already:
You can however override them and provide your own specialized implementation.
TacoDevice subclasses will automatically log all calls to TACO if their loglevel is DEBUG.
TacoDevice also has the following class attributes, which can be overridden in derived classes:
The following utility methods are provided:
Try running the TACO function, and raise a NicosError on exception.
A more specific NicosError subclass is chosen if appropriate. For example, database-related errors are converted to CommunicationError. A TacoDevice subclass can add custom error code to exception class mappings by using the taco_errorcodes class attribute.
If the tacotries parameter is > 1, the call is retried accordingly.
Try the TACO method func with given args for the number of times given by tries. On each failure, a warning log message is emitted. If the device is in error state after a try, it is reset. If the number of tries is exceeded, the error from the call is re-raised.
what is a string that explains the call; it is used in the warning messages.
Update the TACO resource resname to value (both must be strings), switching the device off and on.
Create a new TACO client to the device given by devname, using the Python class class_. Initialize the device in a consistent state, handling eventual errors.
If no arguments are given, the values of devname, class_, resetok and timeout are taken from the class attributes taco_class and taco_resetok as well as the device parameters tacodevice and tacotimeout. This is done during doPreinit, so that you usually don’t have to call this method in TacoDevice subclasses.
You can use this method to create additional TACO clients in a device implementation that uses more than one TACO device.
Parameters
Delay between retries. Default value: 0.10000000000000001. Unit: s.
TACO device name.
TACO client network timeout. Default value: 3. Unit: s.
Number of tries per TACO call. Default value: 1.