pytac.device#

The device class used to represent a particular function of an accelerator element.

A physical element in an accelerator may have multiple devices: an example at DLS is a sextupole magnet that contains also horizontal and vertical corrector magnets and a skew quadrupole.

Members

Device

A representation of a property of an element associated with a field.

EpicsDevice

An EPICS-aware device.

PvEnabler

A PvEnabler class to check whether a device is enabled.

SimpleDevice

A basic implementation of the device class.

class pytac.device.Device[source]#

A representation of a property of an element associated with a field.

Typically a control system will be used to set and get values on a device.

Methods:

is_enabled() bool[source]#

Whether the device is enabled.

Returns:

whether the device is enabled.

get_value(handle: str, throw: bool) float[source]#

Read the value from the device.

Parameters:
  • handle – pytac.SP or pytac.RB.

  • throw – On failure: if True, raise ControlSystemException; if False, return None and log a warning.

Returns:

the value of the PV.

set_value(value: float, throw: bool) None[source]#

Set the value on the device.

Parameters:
  • value (float) – the value to set.

  • throw (bool) – On failure: if True, raise ControlSystemException: if False, log a warning.

class pytac.device.SimpleDevice(value: float | list[float], enabled: bool = True, readonly: bool = True)[source]#

A basic implementation of the device class.

This device does not have a PV associated with it, nor does it interact with a simulator. In short this device acts as simple storage for data that rarely changes, as it is not affected by changes to other aspects of the accelerator.

Parameters:
  • value – can be a number or a list of numbers.

  • enabled – whether the device is enabled. May be a PvEnabler object.

  • readonly – whether the value may be changed.

is_enabled()[source]#

Whether the device is enabled.

Returns:

whether the device is enabled.

Return type:

bool

get_value(handle=None, throw=None)[source]#

Read the value from the device.

Parameters:
  • handle (str) – Irrelevant in this case as a control system is not used, only supported to conform with the base class.

  • throw (bool) – Irrelevant in this case as a control system is not used, only supported to conform with the base class.

Returns:

the value of the device.

Return type:

numeric

set_value(value, throw=None)[source]#

Set the value on the device.

Parameters:
  • value (numeric) – the value to set.

  • throw (bool) – Irrelevant in this case as a control system is not used, only supported to conform with the base class.

class pytac.device.EpicsDevice(name, cs, enabled=True, rb_pv=None, sp_pv=None)[source]#

An EPICS-aware device.

Contains a control system, readback and setpoint PVs. A readback or setpoint PV is required when creating an epics device otherwise a DataSourceException is raised. The device is enabled by default.

Attributes:

name#

The prefix of EPICS PVs for this device.

Type:

str

rb_pv#

The EPICS readback PV.

Type:

str

sp_pv#

The EPICS setpoint PV.

Type:

str

Parameters:
  • name (str) – The prefix of EPICS PV for this device.

  • cs (ControlSystem) – The control system object used to get and set the value of a PV.

  • enabled (bool-like) – Whether the device is enabled. May be a PvEnabler object.

  • rb_pv (str) – The EPICS readback PV.

  • sp_pv (str) – The EPICS setpoint PV.

Raises:

DataSourceException – if no PVs are provided.

Methods:

is_enabled()[source]#

Whether the device is enabled.

Returns:

whether the device is enabled.

Return type:

bool

get_value(handle, throw=True)[source]#

Read the value of a readback or setpoint PV.

Parameters:
  • handle (str) – pytac.SP or pytac.RB.

  • throw (bool) – On failure: if True, raise ControlSystemException; if False, return None and log a warning.

Returns:

The value of the PV.

Return type:

float

Raises:

HandleException – if the requested PV doesn’t exist.

set_value(value, throw=True)[source]#

Set the device value.

Parameters:
  • value (float) – The value to set.

  • throw (bool) – On failure: if True, raise ControlSystemException: if False, log a warning.

Raises:

HandleException – if no setpoint PV exists.

get_pv_name(handle)[source]#

Get the PV name for the specified handle.

Parameters:

handle (str) – The readback or setpoint handle to be returned.

Returns:

A readback or setpoint PV.

Return type:

str

Raises:

HandleException – if the PV doesn’t exist.

class pytac.device.PvEnabler(pv, enabled_value, cs)[source]#

A PvEnabler class to check whether a device is enabled.

The class will behave like True if the PV value equals enabled_value, and False otherwise.

Parameters:
  • pv (str) – The PV name.

  • enabled_value (str) – The value for PV for which the device should be considered enabled.

  • cs (ControlSystem) – The control system object.

Methods: