pytac.data_source
#
Module containing pytac data source classes.
Members
Abstract base class for element or lattice data sources. |
|
Class that manages all the data sources and UnitConv objects associated with a lattice or element. |
|
Data source containing control system devices. |
- class pytac.data_source.DataSource[source]#
Abstract base class for element or lattice data sources.
Typically an instance would represent hardware via a control system, or a simulation.
Attributes:
Methods:
- get_fields()[source]#
Get all the fields represented by this data source.
- Returns:
all fields.
- Return type:
iterable
- class pytac.data_source.DataSourceManager[source]#
Class that manages all the data sources and UnitConv objects associated with a lattice or element.
It receives requests from a lattice or element object and directs them to the correct data source. The unit conversion objects for all fields are also held here.
- default_units#
Holds the current default unit type, pytac.PHYS or pytac.ENG, for an element or lattice.
- Type:
- default_data_source#
Holds the current default data source, pytac.LIVE or pytac.SIM, for an element or lattice.
- Type:
Methods:
- set_data_source(data_source, data_source_type)[source]#
Add a data source to the manager.
- Parameters:
data_source (DataSource) – the data source to be set.
data_source_type (str) – the type of the data source being set pytac.LIVE or pytac.SIM.
- get_data_source(data_source_type)[source]#
Get a data source.
- Parameters:
data_source_type (str) – the type of the data source being set pytac.LIVE or pytac.SIM.
- Raises:
DataSourceException – if there is no data source on the given field.
- get_fields()[source]#
Get all the fields defined on the manager.
Includes all fields defined by all data sources.
- Returns:
- A dictionary of all the fields defined on the manager,
separated by data source(key).
- Return type:
- add_device(field, device, uc)[source]#
Add device and unit conversion objects to a given field.
A DeviceDataSource must be set before calling this method, this defaults to pytac.LIVE as that is the only data source that currently uses devices.
- Parameters:
- Raises:
DataSourceException – if no DeviceDataSource is set.
- get_device(field)[source]#
Get the device for the given field.
A DeviceDataSource must be set before calling this method, this defaults to pytac.LIVE as that is the only data source that currently uses devices.
- Parameters:
field (str) – The lookup key to find the device on the manager.
- Returns:
The device on the given field.
- Return type:
- Raises:
DataSourceException – if no DeviceDataSource is set.
- get_unitconv(field)[source]#
Get the unit conversion option for the specified field.
- Parameters:
field (str) – The field associated with this conversion.
- Returns:
The object associated with the specified field.
- Return type:
- Raises:
FieldException – if no unit conversion object is present.
- get_value(field: str, handle: str = 'readback', units: str = 'default', data_source_type: str = 'default', throw: bool = True) float [source]#
Get the value for a field.
Returns the value of a field on the manager. This value is uniquely identified by a field and a handle. The returned value is either in engineering or physics units. The data_source flag returns either real or simulated values. If handle, units or data_source are not given then the lattice default values are used.
- Parameters:
field – The requested field.
handle – pytac.SP or pytac.RB.
units – pytac.ENG or pytac.PHYS returned.
data_source – pytac.LIVE or pytac.SIM.
throw – On failure: if True, raise ControlSystemException; if False, return None and log a warning.
- Returns:
The value of the requested field
- Raises:
DataSourceException – if there is no data source on the given field.
FieldException – if the manager does not have the specified field.
- set_value(field: str, value: float, units: str = 'default', data_source_type: str = 'default', throw: bool = True) None [source]#
Set the value for a field.
This sets a value on the machine or the simulation. If handle,units or data_source are not given then the lattice default values are used.
- Parameters:
field – The requested field.
value – The value to set.
units – pytac.ENG or pytac.PHYS.
data_source_type – pytac.LIVE or pytac.SIM.
throw – On failure: if True, raise ControlSystemException: if False, log a warning.
- Raises:
HandleException – if the specified handle is not pytac.SP.
DataSourceException – if arguments are incorrect.
FieldException – if the manager does not have the specified field.
- class pytac.data_source.DeviceDataSource[source]#
Data source containing control system devices.
Attributes:
Methods:
- get_device(field)[source]#
Get device from the data_source.
- Parameters:
field (str) – field of the requested device.
- Returns:
The device of the specified field.
- Return type:
- Raises:
FieldException – if the specified field doesn’t exist on this data source.
- get_fields()[source]#
Get all the fields from the data_source.
- Returns:
list of strings of all the fields of the data_source.
- Return type:
- get_value(field, handle, throw=True)[source]#
Get the value of a readback or setpoint PV for a field from the data_source.
- Parameters:
- Returns:
The value of the PV.
- Return type:
- Raises:
FieldException – if the device does not have the specified field.
- set_value(field, value, throw=True)[source]#
Set the value of a readback or setpoint PV for a field from the data_source.
- Parameters:
- Raises:
FieldException – if the device does not have the specified field.