pytac.element
#
Module containing the element class.
Members
Class representing one physical element in an accelerator lattice. |
|
EPICS-aware element. |
- class pytac.element.Element(length, element_type, name=None, lattice=None)[source]#
Class representing one physical element in an accelerator lattice.
An element has zero or more devices (e.g. quadrupole magnet) associated with each of its fields (e.g. ‘b1’ for a quadrupole).
Attributes:
- name#
The name identifying the element. The user is free to define this for their own purposes.
- Type:
- Parameters:
Methods:
- property cell#
The lattice cell this element is within.
N.B. If the element spans multiple cells then the cell it begins in is returned (lowest cell number).
- Type:
- set_default_data_source(data_source_type: str) None [source]#
Set the default data source for this element.
- Parameters:
data_source_type – the type of the data source being set: pytac.LIVE or pytac.SIM.
- set_default_units(units: str) None [source]#
Set the default units type for this element.
- Parameters:
units – pytac.PHYS or pytac.ENG
- set_data_source(data_source: DataSource, data_source_type: str) None [source]#
Add a data source to the element.
- Parameters:
data_source – the data source to be set.
data_source – the type of the data source being set: pytac.LIVE or pytac.SIM.
- get_fields()[source]#
Get the all fields defined on an element.
Includes all fields defined by all data sources.
- Returns:
- A dictionary of all the fields defined on an element,
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 an element.
- 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.
- add_to_family(family)[source]#
Add the element to the specified family.
- Parameters:
family (str) – Represents the name of the family.
- is_in_family(family)[source]#
Return true if the element is in the specified family.
- Parameters:
family (str) – Family to check.
- Returns:
true if element is in the specified family.
- get_value(field, handle='readback', units='default', data_source='default', throw=True)[source]#
Get the value for a field.
Returns the value of a field on the element. 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.
- Parameters:
- Returns:
The value of the requested field
- Return type:
- Raises:
DataSourceException – if there is no data source on the given field.
FieldException – if the element does not have the specified field.
- set_value(field, value, units='default', data_source='default', throw=True)[source]#
Set the value for a field.
This value can be set on the machine or the simulation.
- Parameters:
- Raises:
DataSourceException – if arguments are incorrect.
FieldException – if the element does not have the specified field.
- class pytac.element.EpicsElement(length, element_type, name=None, lattice=None)[source]#
EPICS-aware element.
Adds get_pv_name() method.
Methods:
- Parameters:
Methods:
- get_pv_name(field, handle)[source]#
Get PV name for the specified field and handle.
- Parameters:
- Returns:
The readback or setpoint PV for the specified field.
- Return type:
- Raises:
DataSourceException – if there is no data source for this field.
FieldException – if the specified field doesn’t exist.