This module contains the definition of the Controller base classes
Constants
Constant data type (to be used as a key in the definition of axis_attributes or ctrl_attributes)
Constant data access (to be used as a key in the definition of axis_attributes or ctrl_attributes)
Constant description (to be used as a key in the definition of axis_attributes or ctrl_attributes)
Constant default value (to be used as a key in the definition of axis_attributes or ctrl_attributes)
Constant for getter function (to be used as a key in the definition of axis_attributes or ctrl_attributes)
Constant for setter function (to be used as a key in the definition of axis_attributes or ctrl_attributes)
Constant memorize (to be used as a key in the definition of axis_attributes or ctrl_attributes) Possible values for this key are Memorized, MemorizedNoInit and NotMemorized
Constant memorized (to be used as a value in the Memorize field definition in axis_attributes or ctrl_attributes)
Constant memorize but not write at initialization (to be used as a value in the Memorize field definition in axis_attributes or ctrl_attributes)
Constant not memorize (to be used as a value in the Memorize field definition in axis_attributes or ctrl_attributes)
Constant MaxDimSize (to be used as a key in the definition of axis_attributes or ctrl_attributes)
Interfaces
Classes
Bases: object
A Readable interface. A controller for which it’s axis are ‘readable’ (like a motor, counter or 1D for example) should implement this interface
Controller API. Override if necessary. Called to prepare a read of the value of all axis. Default implementation does nothing.
Controller API. Override if necessary. Called to prepare a read of the value of a single axis. Default implementation does nothing.
Parameters: | axis (int) – axis number |
---|
Bases: object
A Startable interface. A controller for which it’s axis are ‘startable’ (like a motor, for example) should implement this interface
Controller API. Override if necessary. Called to prepare a start of all axis (whatever pre-start means). Default implementation does nothing.
Controller API. Override if necessary. Called to prepare a start of the given axis (whatever pre-start means). Default implementation returns True.
Parameters: |
|
---|---|
Returns: | True means a successfull pre-start or False for a failure |
Return type: | bool |
Bases: object
A Stopable interface. A controller for which it’s axis are ‘stoppable’ (like a motor, for example) should implement this interface
Controller API. Override is MANDATORY! Default implementation raises NotImplementedError. Aborts one of the axis
Parameters: | axis (int) – axis number |
---|
Controller API. Override if necessary. Aborts all active axis of this controller. Default implementation calls AbortOne() on each active axis.
New in version 1.0.
Bases: object
A Loadable interface. A controller for which it’s axis are ‘loadable’ (like a counter, 1D or 2D for example) should implement this interface
Controller API. Override if necessary. Called to prepare loading the integration time / monitor value. Default implementation does nothing.
Controller API. Override if necessary. Called to prepare loading the master channel axis with the integration time / monitor value. Default implementation returns True.
Parameters: |
|
---|---|
Returns: | True means a successfull PreLoadOne or False for a failure |
Return type: | bool |
Bases: object
Base controller class. Do NOT inherit from this class directly
Parameters: |
|
---|
Deprecated since version 1.0: use ctrl_properties instead
A sequence of str representing the controller features
Deprecated since version 1.0: use axis_attributes instead
A dict containing controller properties where:
key : (str) controller property name
value : dict with with three str keys (“type”, “description” and “defaultvalue” case insensitive):
- for Type, value is one of the values described in Data Type definition
- for Description, value is a str description of the property. if is not given it defaults to empty string.
- for DefaultValue, value is a python object or None if no default value exists for the property.
Example:
from sardana.pool.controller import MotorController, \
Type, Description, DefaultValue
class MyCtrl(MotorController):
ctrl_properties = \
{
'host' : { Type : str,
Description : "host name" },
'port' : { Type : int,
Description : "port number",
DefaultValue: 5000 }
}
A dict containning controller extra attributes where:
key : (str) controller attribute name
value : dict with str possible keys: “type”, “r/w type”, “description”, “fget”, “fset” and “maxdimsize” (case insensitive):
for Type, value is one of the values described in Data Type definition
for Access, value is one of DataAccess (“read” or “read_write” (case insensitive) strings are also accepted) [default: ReadWrite]
for Description, value is a str description of the attribute [default: “” (empty string)]
for FGet, value is a str with the method name for the attribute getter [default: “get”<controller attribute name>]
for FSet, value is a str with the method name for the attribute setter. [default, if Access = “read_write”: “set”<controller attribute name>]
for DefaultValue, value is a python object or None if no default value exists for the attribute. If given, the attribute is set when the controller is first created.
for Memorize, value is a str with possible values: Memorized, MemorizedNoInit and NotMemorized [default: Memorized]
New in version 1.1.
- for MaxDimSize, value is a tuple with possible values:
- for scalar must be an empty tuple ( () or [] ) [default: ()]
- for 1D arrays a sequence with one value (example: (1024,)) [default: (2048,)]
- for 1D arrays a sequence with two values (example: (1024, 1024)) [default: (2048, 2048)]
New in version 1.1.
New in version 1.0.
Example:
from sardana.pool.controller import PseudoMotorController, \
Type, Description, DefaultValue, DataAccess
class HKLCtrl(PseudoMotorController):
ctrl_attributes = \
{
'ReflectionMatrix' : { Type : ( (float,), ),
Description : "The reflection matrix",
Access : DataAccess.ReadOnly,
FGet : 'getReflectionMatrix', },
}
def getReflectionMatrix(self):
return ( (1.0, 0.0), (0.0, 1.0) )
A dict containning controller extra attributes for each axis where:
key : (str) axis attribute name
value : dict with three str keys (“type”, “r/w type”, “description” case insensitive):
for Type, value is one of the values described in Data Type definition
for Access, value is one of DataAccess (“read” or “read_write” (case insensitive) strings are also accepted)
for Description, value is a str description of the attribute
for DefaultValue, value is a python object or None if no default value exists for the attribute. If given, the attribute is set when the axis is first created.
for Memorize, value is a str with possible values: Memorized, MemorizedNoInit and NotMemorized [default: Memorized]
New in version 1.1.
- for MaxDimSize, value is a tuple with possible values:
- for scalar must be an empty tuple ( () or [] ) [default: ()]
- for 1D arrays a sequence with one value (example: (1024,)) [default: (2048,)]
- for 1D arrays a sequence with two values (example: (1024, 1024)) [default: (2048, 2048)]
New in version 1.1.
New in version 1.0.
Example:
from sardana.pool.controller import MotorController, \
Type, Description, DefaultValue, DataAccess
class MyMCtrl(MotorController):
axis_attributes = \
{
'EncoderSource' : { Type : str,
Description : 'motor encoder source', },
}
def getAxisPar(self, axis, name):
name = name.lower()
if name == 'encodersource':
return self._encodersource[axis]
def setAxisPar(self, axis, name, value):
name = name.lower()
if name == 'encodersource':
self._encodersource[axis] = value
A dict containing the standard attributes present on each axis device
A str representing the controller gender
A str representing the controller model name
A str representing the controller organization
A str containning the path to the image file
A str containning the path to the image logo file
Internal. By default return the Pool Controller API version of the pool where the controller is running
Controller API. Override if necessary. Default implementation does nothing.
Parameters: | axis (int) – axis number |
---|
Controller API. Override if necessary. Default implementation does nothing.
Parameters: | axis (int) – axis number |
---|
Controller API. The controller instance name.
Deprecated since version 1.0: use GetName() instead
Controller API. The controller instance name.
Returns: | the controller instance name |
---|---|
Return type: | str |
New in version 1.0.
Controller API. The axis name.
Returns: | the axis name |
---|---|
Return type: | str |
New in version 1.0.
Controller API. Override if necessary. Called to prepare a read of the state of all axis. Default implementation does nothing.
Controller API. Override if necessary. Called to prepare a read of the state of a single axis. Default implementation does nothing.
Parameters: | axis (int) – axis number |
---|
Controller API. Override if necessary. Called to read the state of all selected axis. Default implementation does nothing.
Controller API. Override is MANDATORY. Called to read the state of one axis. Default implementation raises NotImplementedError.
Controller API. Override if necessary. Called to set a parameter with a value. Default implementation sets this object member named ‘_’+parameter with the given value.
New in version 1.0.
Controller API. Override if necessary. Called to set a parameter with a value. Default implementation returns the value contained in this object’s member named ‘_’+parameter.
New in version 1.0.
Controller API. Override is MANDATORY. Called to set a parameter with a value on the given axis. Default implementation calls deprecated SetPar() which, by default, raises NotImplementedError.
New in version 1.0.
Controller API. Override is MANDATORY. Called to get a parameter value on the given axis. Default implementation calls deprecated GetPar() which, by default, raises NotImplementedError.
New in version 1.0.
Controller API. Override if necessary. Called to set a parameter with a value on the given axis. Default implementation calls deprecated SetExtraAttributePar() which, by default, raises NotImplementedError.
New in version 1.0.
Controller API. Override if necessary. Called to get a parameter value on the given axis. Default implementation calls deprecated GetExtraAttributePar() which, by default, raises NotImplementedError.
New in version 1.0.
Controller API. Called to set a parameter with a value on the given axis. Default implementation raises NotImplementedError.
Deprecated since version 1.0: use SetAxisPar() instead
Controller API. Called to get a parameter value on the given axis. Default implementation raises NotImplementedError.
Deprecated since version 1.0: use GetAxisPar() instead
Controller API. Called to set a parameter with a value on the given axis. Default implementation raises NotImplementedError.
Deprecated since version 1.0: use SetAxisExtraPar() instead
Controller API. Called to get a parameter value on the given axis. Default implementation raises NotImplementedError.
Deprecated since version 1.0: use GetAxisExtraPar() instead
Controller API. Override if necessary. Returns a dictionary of all attributes per axis. Default implementation returns a new dict with the standard attributes plus the axis_attributes
Parameters: | axis (int) – axis number |
---|---|
Returns: | a dict containing attribute information as defined in axis_attributes |
New in version 1.0.
Bases: sardana.pool.controller.Controller
Base class for all pseudo controllers.
Bases: sardana.pool.controller.Controller, sardana.pool.controller.Startable, sardana.pool.controller.Stopable, sardana.pool.controller.Readable
Base class for a motor controller. Inherit from this class to implement your own motor controller for the device pool.
A motor controller should support these axis parameters:
- acceleration
- deceleration
- velocity
- base_rate
- step_per_unit
These parameters are configured through the GetAxisPar()/SetAxisPar() API (in version <1.0 the methods were called GetPar()/SetPar(). Default GetAxisPar() and SetAxisPar() still call GetPar() and SetPar() respectively in order to maintain backward compatibility).
A constant representing no active switch.
A constant representing an active home switch. You can OR two or more switches together. For example, to say both upper and lower limit switches are active:
limit_switches = self.HomeLimitSwitch | self.LowerLimitSwitch
A constant representing an active upper limit switch. You can OR two or more switches together. For example, to say both upper and lower limit switches are active:
limit_switches = self.UpperLimitSwitch | self.LowerLimitSwitch
A constant representing an active lower limit switch. You can OR two or more switches together. For example, to say both upper and lower limit switches are active:
limit_switches = self.UpperLimitSwitch | self.LowerLimitSwitch
A dict containing the standard attributes present on each axis device
A str representing the controller gender
Motor Controller API. Override if necessary. Returns a sequence of all attributes per axis. Default implementation returns a dict containning:
plus all attributes contained in axis_attributes
Note
Normally you don’t need to Override this method. You just implement the class member axis_attributes. Typically, you will need to Override this method in two cases:
- certain axes contain a different set of extra attributes which cannot be simply defined in axis_attributes
- some axes (or all) don’t implement a set of standard moveable parameters (ex.: if a motor controller is created to control a power supply, it may have a position (current) and a velocity (ramp speed) but it may not have acceleration)
Parameters: | axis (int) – axis number |
---|---|
Returns: | a dict containing attribute information as defined in axis_attributes |
New in version 1.0.
Bases: sardana.pool.controller.PseudoController
Base class for a pseudo motor controller. Inherit from this class to implement your own pseudo motor controller for the device pool.
Every Pseudo Motor implementation must be a subclass of this class. Current procedure for a correct implementation of a Pseudo Motor class:
a sequence of strings describing the role of each pseudo motor axis in this controller
a sequence of strings describing the role of each motor in this controller
A dict containing the standard attributes present on each axis device
A str representing the controller gender
Pseudo Motor Controller API. Override if necessary. Calculates the positions of all pseudo motors that belong to the pseudo motor system from the positions of the physical motors. Default implementation does a loop calling PseudoMotorController.calc_pseudo() for each pseudo motor role.
Parameters: |
|
---|---|
Returns: | a sequece of pseudo motor positions (one for each pseudo motor role) |
Return type: | sequence<float> |
New in version 1.0.
Pseudo Motor Controller API. Override if necessary. Calculates the positions of all motors that belong to the pseudo motor system from the positions of the pseudo motors. Default implementation does a loop calling PseudoMotorController.calc_physical() for each motor role.
Parameters: |
|
---|---|
Returns: | a sequece of motor positions (one for each motor role) |
Return type: | sequence<float> |
New in version 1.0.
Pseudo Motor Controller API. Override is MANDATORY. Calculate pseudo motor position given the physical motor positions
Parameters: |
|
---|---|
Returns: | a pseudo motor position corresponding to the given axis pseudo motor role |
Return type: | float |
New in version 1.0.
Pseudo Motor Controller API. Override is MANDATORY. Calculate physical motor position given the pseudo motor positions.
Parameters: |
|
---|---|
Returns: | a motor position corresponding to the given axis motor role |
Return type: | float |
New in version 1.0.
Pseudo Motor Controller API. Override if necessary. Calculates the positions of all pseudo motors that belong to the pseudo motor system from the positions of the physical motors. Default implementation does a loop calling PseudoMotorController.calc_pseudo() for each pseudo motor role.
Parameters: | physical_pos (sequence<float>) – a sequence of physical motor positions |
---|---|
Returns: | a sequece of pseudo motor positions (one for each pseudo motor role) |
Return type: | sequence<float> |
Deprecated since version 1.0: implement CalcAllPseudo() instead
Pseudo Motor Controller API. Override if necessary. Calculates the positions of all motors that belong to the pseudo motor system from the positions of the pseudo motors. Default implementation does a loop calling PseudoMotorController.calc_physical() for each motor role.
Parameters: | pseudo_pos (sequence<float>) – a sequence of pseudo motor positions |
---|---|
Returns: | a sequece of motor positions (one for each motor role) |
Return type: | sequence<float> |
Deprecated since version 1.0: implement CalcAllPhysical() instead
Pseudo Motor Controller API. Override is MANDATORY. Calculate pseudo motor position given the physical motor positions
Parameters: |
|
---|---|
Returns: | a pseudo motor position corresponding to the given axis pseudo motor role |
Return type: | float |
Deprecated since version 1.0: implement CalcPseudo() instead
Pseudo Motor Controller API. Override is MANDATORY. Calculate physical motor position given the pseudo motor positions.
Parameters: |
|
---|---|
Returns: | a motor position corresponding to the given axis motor role |
Return type: | float |
Deprecated since version 1.0: implement CalcPhysical() instead
Returns the motor for a given role/index.
Warning
Parameters: | index_or_role (int or str) – index number or role name |
---|---|
Returns: | Motor object for the given role/index |
Return type: | PoolMotor |
Returns the pseudo motor for a given role/index.
Warning
Parameters: | index_or_role (int or str) – index number or role name |
---|---|
Returns: | PseudoMotor object for the given role/index |
Return type: | PoolPseudoMotor |
Bases: sardana.pool.controller.Controller, sardana.pool.controller.Readable, sardana.pool.controller.Startable, sardana.pool.controller.Stopable, sardana.pool.controller.Loadable
Base class for a counter/timer controller. Inherit from this class to implement your own counter/timer controller for the device pool.
A counter timer controller should support these controller parameters:
- timer
- monitor
- trigger_type
A dict containing the standard attributes present on each axis device
A str representing the controller gender
Counter/Timer Controller API. Override if necessary. Called to prepare an acquisition of all selected axis. Default implementation does nothing.
Deprecated since version 1.0: use PreStartAll() instead
Counter/Timer Controller API. Override if necessary. Called to prepare an acquisition a single axis. Default implementation returns True.
Parameters: | axis (int) – axis number |
---|---|
Returns: | True means a successfull PreStartOneCT or False for a failure |
Return type: | bool |
Deprecated since version 1.0: use PreStartOne() instead
Counter/Timer Controller API. Override if necessary. Called to start an acquisition of a selected axis. Default implementation does nothing.
Parameters: | axis (int) – axis number |
---|
Deprecated since version 1.0: use StartOne() instead
Counter/Timer Controller API. Override is MANDATORY! Called to start an acquisition of a selected axis. Default implementation raises NotImplementedError.
Deprecated since version 1.0: use StartAll() instead
Controller API. Override if necessary. Called to prepare a write of the position of all axis. Default implementation calls deprecated PreStartAllCT() which, by default, does nothing.
New in version 1.0.
Controller API. Override if necessary. Called to prepare a write of the position of a single axis. Default implementation calls deprecated PreStartOneCT() which, by default, returns True.
Parameters: |
|
---|---|
Returns: | True means a successfull pre-start or False for a failure |
Return type: | bool |
New in version 1.0.
Controller API. Override if necessary. Called to write the position of a selected axis. Default implementation calls deprecated StartOneCT() which, by default, does nothing.
Parameters: |
|
---|
Controller API. Override is MANDATORY! Default implementation calls deprecated StartAllCT() which, by default, raises NotImplementedError.
Bases: sardana.pool.controller.Controller, sardana.pool.controller.Readable, sardana.pool.controller.Stopable
Base class for a 0D controller. Inherit from this class to implement your own 0D controller for the device pool.
A dict containing the standard attributes present on each axis device
A str representing the controller gender
Bases: sardana.pool.controller.Controller, sardana.pool.controller.Readable, sardana.pool.controller.Startable, sardana.pool.controller.Stopable, sardana.pool.controller.Loadable
Base class for a 1D controller. Inherit from this class to implement your own 1D controller for the device pool.
New in version 1.2.
A str representing the controller gender
Controller API. Override is MANDATORY. Called to get a parameter value on the given axis. If parameter == ‘data_source’, default implementation returns None, meaning let sardana decide the proper URI for accessing the axis value. Otherwise, default implementation calls deprecated GetPar() which, by default, raises NotImplementedError.
New in version 1.2.
Bases: sardana.pool.controller.Controller, sardana.pool.controller.Readable, sardana.pool.controller.Startable, sardana.pool.controller.Stopable, sardana.pool.controller.Loadable
Base class for a 2D controller. Inherit from this class to implement your own 2D controller for the device pool.
A str representing the controller gender
Controller API. Override is MANDATORY. Called to get a parameter value on the given axis. If parameter == ‘data_source’, default implementation returns None, meaning let sardana decide the proper URI for accessing the axis value. Otherwise, default implementation calls deprecated GetPar() which, by default, raises NotImplementedError.
New in version 1.2.
Bases: sardana.pool.controller.Controller
Base class for a pseudo counter controller. Inherit from this class to implement your own pseudo counter controller for the device pool.
Every Pseudo Counter implementation must be a subclass of this class. Current procedure for a correct implementation of a Pseudo Counter class:
a sequence of strings describing the role of each pseudo counter axis in this controller
a sequence of strings describing the role of each counter in this controller
A dict containing the standard attributes present on each axis device
A str representing the controller gender
Pseudo Counter Controller API. Override is MANDATORY. Calculate pseudo counter position given the counter values.
Parameters: |
|
---|---|
Returns: | a pseudo counter value corresponding to the given axis pseudo counter role |
Return type: | float |
New in version 1.0.
Pseudo Counter Controller API. Override is MANDATORY. Calculate pseudo counter value given the counter values.
Parameters: |
|
---|---|
Returns: | a pseudo counter value corresponding to the given axis pseudo counter role |
Return type: | float |
Deprecated since version 1.0: implement Calc() instead
Pseudo Counter Controller API. Override if necessary. Calculates all pseudo counter values from the values of counters. Default implementation does a loop calling PseudoCounterController.Calc() for each pseudo counter role.
Parameters: | values (sequence<float>) – a sequence containing current values of underlying elements |
---|---|
Returns: | a sequece of pseudo counter values (one for each pseudo counter role) |
Return type: | sequence<float> |
New in version 1.2.
Bases: sardana.pool.controller.Controller, sardana.pool.controller.Readable
Base class for a IORegister controller. Inherit from this class to implement your own IORegister controller for the device pool.
Deprecated since version 1.0: use axis_attributes instead
A dict containing the standard attributes present on each axis device
A str representing the controller gender