Adding real elements¶
For the sake of demonstration, let’s suppose you want to integrate a slit with IcePAP-based motors into Sardana.
The controller is a Sardana object that handles the communication with the hardware (physical controller) or provides an abstraction layer (pseudo controller).
Before creating the controller instance you need to load the controller
plugin class into the Sardana. To check if it is already loaded use the
lsctrl macro. If it is not, you will
need to configure the controller plugin discovery path
PoolPath property) and either restart the Sardana server or call the
addctrllib macro. After that
check again with the list macro if the controller class is present and if
yes let’s continue...
To create a controller instance you can use
defctrl <class> <name> <roles/properties>
<class> parameter is a class name for your controller to use and
<name> is the name of the new controller instance. Roles and properties are
used to configure the controller.
For our IcePAP controller we will use two properties:
our IcePAP system:
defctrl IcepapController ipap01 Host 10.0.0.30 Port 5000
You can use the
sar_info macro to
see the roles and properties available for a controller class.
To learn more about controllers see Controller overview.
Since single motor controller can have multiple axes corresponding to multiple motors, we will need to create the elements for these axes. This way the controller will know which motor to move.
defelem macro you can
create any type of controller axis, not only motors:
defelem <name> <controller> <axis>
<name> is the element name,
<controller> is the controller instance on
which the element should be created and
<axis> is the controller axis number.
Let’s add an axis to our IcePAP controller:
defelem mot01 ipap01 1
defm mot02 ipap01 2
To use our slit with more abstract interface we can use the
controller. To use it, just add the
Slit controller with the
defctrl Slit s0ctrl sl2t=mot01 sl2b=mot02 Gap=s0gap Offset=s0off
Slit controller we use roles. There are two types of roles:
- physical roles - real motors, elements that already exist in Sardana
- pseudo roles - abstract motors that will be created by pseudo controller
Slit controller defines two physical roles:
two pseudo roles:
Offset. Note the difference in syntax for passing
roles and properties to the
By this point your slit should be accesible from Sardana using real motors as well as abstract pseudomotor interface.
To create a measurement group use
defmeas <name> <channel_list>
This macro takes the name for the new meaasurement group and the list of experimetal channels as its arguments. The first channel must be a Sardana internal channel and at least one of the channels must be a Counter/Timer.
defmeas mntgrp01 ct01 ct02 ct03 ct04
To learn more about measurement groups see Measurement group overview.
Each of these macros takes the list of element names as the argument.
Remember that you cannot remove controllers with elements, so you must remove the elements prior to removing the controller.
To create a controller it’s useful to know which controller classes are available.
To do this use
To see the created controllers use
For lists of motors and experimental channels use
You can display all measurement groups with
Each of these macros accepts regexp filter as the optional argument.
The path Sardana uses for loading controller classes can be configured. See the Configuration section for details.