sardana.pool.controller
Controller
- Base API for all controller typesMotorController
- Motor controller APICounterTimerController
- Counter/Timer controller APIZeroDController
- 0D controller APIPseudoMotorController
- PseudoMotor controller APIPseudoCounterController
- PseudoCounter controller APITriggerGateController
- Trigger/Gate controller APIIORegisterController
- IORegister controller API
When writing a new controller you may need to specify extra attributes (per controller or/and per axis) as well as extra properties. This chapter describes how to describe the data type for each of this additional members. Controller data type definition has the following equivalences. This means you can use any of the given possibilities to describe a field data type. The possibilities are ordered by preference (example: usage of int
is preferred to "int" or "PyTango.DevLong"):
- for 0D data types:
- integer:
int
|DataType.Integer <sardana.sardanadefs.DataType>
| "int" | "integer" | "long" |long
| [ "PyTango." ] "DevLong" - double:
float
|DataType.Double <sardana.sardanadefs.DataType>
| "double" | "float" | [ "PyTango." ] "DevDouble" - string:
str
|DataType.String <sardana.sardanadefs.DataType>
| "str" | "string" | [ "PyTango." ] "DevString" - boolean:
bool
|DataType.Boolean <sardana.sardanadefs.DataType>
| "bool" | "boolean" | [ "PyTango." ] "DevBoolean"
- integer:
- for 1D data types:
- integer: (
int
,) | (DataType.Integer <sardana.sardanadefs.DataType>
,) | ("int",) | ("integer",) | (long
,) | ("long",) | [ "PyTango." ] "DevVarLongArray" | ([ "PyTango." ] "DevLong",) - double: (
float
,) | (DataType.Double <sardana.sardanadefs.DataType>
,) | ("double",) | ("float",) | [ "PyTango." ] "DevVarDoubleArray" | ([ "PyTango." ] "DevDouble",) - string: (
str
,) | (DataType.String <sardana.sardanadefs.DataType>
,) | ("str",) | ("string",) | [ "PyTango." ] "DevVarStringArray" | ([ "PyTango." ] "DevString",) - boolean: (
bool
,) | (DataType.Boolean <sardana.sardanadefs.DataType>
,) | ("bool",) | ("boolean",) | [ "PyTango." ] "DevVarBooleanArray" | ([ "PyTango." ] "DevBoolean",)
- integer: (
1.0 [ "PyTango." ] "Dev"<concrete type string> types are considered deprecated.
Note
when string, types are case insensitive. This means "long" is the same as "LONG"
Here is an example on how to define extra attributes per axis:
- EncoderSource: a scalar r/w string
- ReflectionMatrix: a 2D readable float with customized getter method
from sardana import State, DataAccess
from sardana.pool.controller import MotorController, \
Type, Description, DefaultValue, Access, FGet, FSet
class MyMotorCtrl(MotorController):
axis_attributes = \
{
'EncoderSource' : { Type : str,
Description : 'motor encoder source', },
'ReflectionMatrix' : { Type : ( (float,), ),
Access : DataAccess.ReadOnly,
FGet : 'getReflectionMatrix', },
}
def getAxisExtraPar(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
def getReflectionMatrix(self, axis):
return ( (1.0, 0.0), (0.0, 1.0) )