Taco base class

class nicos.taco.core.TacoDevice

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:

  • doVersion (returns TACO device version)
  • doPreinit (creates the TACO device from the tacodevice parameter)
  • doRead (reads the TACO device)
  • doStatus (returns status.OK for ON and DEVICE_NORMAL, ERROR otherwise)
  • doReset (resets the TACO device)
  • doReadUnit (reads the unit parameter from the TACO device if not configured in setup)

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:

  • taco_class – the Python class to use for the TACO client
  • taco_resetok – a boolean value indicating if the device can be reset during connection if it is in error state
  • taco_errorcodes – a dictionary mapping TACO error codes to NICOS exception classes

The following utility methods are provided:

_taco_guard(function, *args)

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.

_taco_multitry(what, tries, func, *args)

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.

_taco_update_resource(resname, value)

Update the TACO resource resname to value (both must be strings), switching the device off and on.

_create_client(devname=None, class_=None, resetok=None, timeout=None)

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

tacodelay (float, settable at runtime)

Delay between retries. Default value: 0.10000000000000001. Unit: s.

tacodevice (a valid taco device, mandatory in setup, initialized for preinit)

TACO device name.

tacotimeout (float, settable at runtime, initialized for preinit)

TACO client network timeout. Default value: 3. Unit: s.

tacotries (an integer in the range [1, 10), settable at runtime)

Number of tries per TACO call. Default value: 1.

Previous topic

Taco classes

Next topic

Taco FRM-II detector classes