pytac package¶
Submodules¶
pytac.cs module¶
Template module to define control systems.
-
class
pytac.cs.
ControlSystem
[source]¶ Bases:
object
Define a control system to be used with a device.
It uses channel access to comunicate over the network with the hardware.
pytac.device module¶
-
class
pytac.device.
Device
(cs, rb_pv=None, sp_pv=None)[source]¶ Bases:
object
-
get_pv_name
(handle='*')[source]¶ Get a pv name on a specified handle.
If no handle is specified, then both pvs are returned.
- Args:
- handle(string): The readback or setpoint handle to be returned.
- Returns:
- string: A readback or setpoint pv.
-
get_value
(handle)[source]¶ Read the value of a readback or setpoint pv.
If neither readback or setpoint pvs exist then a PvException is raised.
- Args:
- handle(string): Handle used to get the value off a readback or setpoint
- pv.
- Returns:
- Number: The value off the pv.
- Raises:
- PvException: In case the requested pv doesn’t exist.
-
is_enabled
()[source]¶ Check whether an device is enabled or disabled.
- Returns:
- boolean: Represents whether an device is enabled or disabled.
-
pytac.element module¶
-
class
pytac.element.
Element
(name, length, element_type)[source]¶ Bases:
object
-
add_device
(field, device, uc)[source]¶ Add device and unit conversion objects to a given field.
- Args:
- field (string): The key to store the unit conversion and device
- objects.
device (Device): Represents a device stored on an element. uc (PolyUnitConv/PchipUnitConv): Represents a unit conversion object stored for a
device.
-
add_to_family
(family)[source]¶ Add the element to the specified family.
- Args:
- family (string): Represents the name of the family
-
get_device
(field)[source]¶ Get the device for the given field.
- Args:
- field (string): The lookup key to find the device on an element.
- Returns:
- Device: The device on the given field.
-
get_fields
()[source]¶ Get the fields defined on an element.
- Returns:
- list: A sequence of all the fields defined on an element.
-
get_length
()[source]¶ Gets the length of an element.
- Returns:
- float: A floating point number that represents the length of the element.
-
get_pv_name
(field, handle='*')[source]¶ Get a pv name on a device.
Can return the readback and setpoint pvs if no handle is specified.
- Args:
field (string): Uniquely identifies a device. handle(string): Can be ‘readback’ or ‘setpoint’ to return each pv.
If neither is specified then both pvs are returned.- Returns:
- string: A readback or setpoint pv associated with the identified device.
- Raises:
- PvException: An exception occured accessing a field with no associated device.
-
get_pv_value
(field, handle, unit='engineering', sim=False)[source]¶ Get the value of a pv.
Returns the value of a pv 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 sim flag returns either real or simulated values.
- Args:
field (string): Choose which device to use. handle (string): Can take as value either ‘setpoint’ or ‘readback’. unit (string): Specify either engineering or physics units to be
returned.sim (boolean): Set whether real or simulated values to be returned.
- Returns:
- Number: A number that corresponds to the pv value of the identified device.
- Raises:
- PvException: When there is no associated device on the given field.
-
put_pv_value
(field, value, unit='engineering', sim=False)[source]¶ Set the pv value on a uniquely identified device.
This value can be set on the machine or the simulation. A field is required to identify a device. Returned value can be engineering or physics.
- Args:
- field (string): The key used to identify a device. value (float): The value set on the device. unit (string): Can be engineering or physics units. sim (boolean): To set whether the simulation is on or off.
- Raises:
- PvException: An exception occured accessing a field with no associated device.
-
pytac.epics module¶
pytac.exceptions module¶
Module to represent existant exceptions in Pytac.
pytac.lattice module¶
-
class
pytac.lattice.
Lattice
(name, control_system, energy)[source]¶ Bases:
object
-
add_element
(element)[source]¶ Add an element to the lattice.
- Args:
- element (Element): The element to be inserted into the lattice.
-
get_all_families
()[source]¶ Get all available families of the lattice.
- Returns:
- set(string): Contains all available families in the lattice.
-
get_elements
(family=None)[source]¶ Get the elements of a family from the lattice.
If no family is specified it returns the whole lattice.
- Args:
- family (string): A specific family to return the elements of.
- Returns:
- list(Element): A list that contains all elements of the specified family.
-
get_energy
()[source]¶ Function to get the total energy of the lattice.
- Returns:
- Number: The total energy of the lattice.
-
get_family_pvs
(family, field, handle)[source]¶ Get all pv names for a specific family, field and handle.
- Args:
- family (string): A specific family to requests elements of. field (string): The field to uniquely identify a device. handle (string): It is used to identify a readback or setpoint pv.
- Returns:
- list(string): A list of readback or setpoint pvs from the device.
-
get_family_s
(family)[source]¶ Get the positions for a set of elements from the same family.
- Args:
- family(string): The family the positions are being asked for.
- Returns:
- list(float): A list of floating point numbers that represent the positions for each element.
-
get_family_values
(family, field, handle='setpoint')[source]¶ Get all pv values for a set of pvs.
- Args:
- family(string): A specific family to requests the values of. field(string): The field to uniquely identify a device. handle(string): It is used to identify a readback or setpoint pv.
- Returns:
- list(float): A list of readback or setpoint pv values from the device.
-
get_s
(given_element)[source]¶ Find the position of a given element in the lattice.
Note that the given element must exist in the lattice.
- Args:
- given_element: The element that the position is being asked for.
- Returns:
- float: the position of the given element.
- Raises
- ElementNotFoundException: An exception is raised in case the element doesn’t exist inside the lattice.
-
set_family_values
(family, field, values)[source]¶ Set the pv value of a given family of pvs.
The pvs are determined by family and device. Note that only setpoint pvs ca be modified.
- Args:
- family(string): A specific family to set the value of. field(string): The field to uniquely identify a device. values(list(float)): A list of values to assign to the pvs.
- Raises:
- PvException: An exception raised in case the given list of values doesn’t match the number of found pvs.
-