pml package¶
Submodules¶
pml.cs module¶
Template module to define control systems.
-
class
pml.cs.ControlSystem[source]¶ Bases:
objectDefine a control system to be used with a device.
It uses channel access to comunicate over the network with the hardware.
-
class
pml.cs.NullControlSystem[source]¶ Bases:
pml.cs.ControlSystemDummy control system to set the value of a pv.
pml.device module¶
-
class
pml.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.
-
pml.element module¶
-
class
pml.element.Element(name, length, element_type, physics=None)[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 (UcPoly/UcPchip): 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.
-
is_enabled()[source]¶ Check whether an element is enabled or disabled.
- Returns:
- boolean: Represents whether an element is enabled or disabled.
-
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.
-
pml.exceptions module¶
Template module to represent existant exceptions.
pml.lattice module¶
-
class
pml.lattice.Lattice(name, control_system)[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_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.
-
pml.load_csv module¶
pml.physics module¶
List of available physics objects: RF AP DRIFT BPM BEND QUAD SEXT DIPOLE HSTR VSTR HCHICA VTRIM HTRIM MPW12 MPW15 BPM10 source
-
class
pml.physics.Ap(length)[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Aperture(limits)[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Bend(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)[source]¶ Bases:
pml.physics.Magnet
-
class
pml.physics.Bpm(length, x=None, y=None)[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Bpm10(length, x=0, y=0)[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Corrector(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)[source]¶ Bases:
pml.physics.Magnet
-
class
pml.physics.Dipole(bending_angle, entrance_angle, exit_angle, full_gap, fringe_int1, fringe_int2)[source]¶ Bases:
pml.physics.Magnet
-
class
pml.physics.Drift(length)[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Hchica(length)[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Hstr(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)[source]¶ Bases:
pml.physics.Corrector
-
class
pml.physics.Htrim(length)[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Magnet(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Marker[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Monitor[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Mpw10(length)[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Mpw12(length)[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Mpw15(length)[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Physics(length)[source]¶ Bases:
objectTemplate class to represent an object for the simulation.
-
class
pml.physics.Quad(length)[source]¶ Bases:
pml.physics.Magnet
-
class
pml.physics.RF(voltage, frequency, harmonic_number, time_lag=0)[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Rf(length, voltage=0, frequency=0, harmonic_no=0, time_lag=0)[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Sext(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)[source]¶ Bases:
pml.physics.Magnet
-
class
pml.physics.Source(length)[source]¶ Bases:
pml.physics.Physics
-
class
pml.physics.Vstr(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)[source]¶ Bases:
pml.physics.Corrector
-
class
pml.physics.Vtrim(length)[source]¶ Bases:
pml.physics.Physics
pml.units module¶
-
class
pml.units.UcPchip(x, y)[source]¶ Bases:
object-
machine_to_physics(machine_value)[source]¶ Convert between machine and engineering units.
- Args:
- machine_value(float): The machine value to be converted to the engineering unit.
- Returns:
- float: The converted engineering value from the given machine value.
-
physics_to_machine(physics_value)[source]¶ Convert between engineering and machine units.
- Args:
- physics_value(float): The engineering value to be converted to the
- machine value.
- Returns:
- float: The converted engineering value from the given physics value.
- Raises:
- ValueError: An error occured when there exist no or more than one roots.
-
-
class
pml.units.UcPoly(coef)[source]¶ Bases:
object-
machine_to_physics(machine_value)[source]¶ Convert between machine and engineering units.
- Args:
- machine_value(float): The machine value to be converted to the engineering unit.
- Returns:
- float: The engineering value determined using the machine value.
-
physics_to_machine(physics_value)[source]¶ Convert between engineering and machine units.
- Args:
- physics_value(float): The engineering value to be converted to the
- machine value.
- Returns:
- float: The converted machine value from the given engineering value.
- Raises:
- ValueError: An error occured when there exist no or more than one roots.
-