This chapter describes how to migrate different sardana components between the different API versions.
This chapter describes the necessary steps to fully migrate your macros from API v0 ( sardana 0.x ) to API v1 ( sardana 1.x )
The following are the 2 necessary changes to make your macros work in sardana API v1:
from:
from macro import Macro, Type, Table, List
to:
from sardana.macroserver.macro import Macro, Type, Table, List
Parameter type Type.Motor should be changed Type.Moveable. In v0 the Motor meant any motor (including physical motor, pseudo motor). In v1, for consistency, Motor means only physical motor and Moveable means all moveable elements (including physical motor, pseudo motor).
This chapter is a summary of all new features in API v1.
This chapter describes the necessary steps to fully migrate your controller from API v0 ( sardana 0.x ) to API v1 ( sardana 1.x )
The following are the 2 necessary changes to make your controller work in sardana API v1:
from:
import pool
from pool import <ControllerClass>/PoolUtil
to:
from sardana import pool
from sardana.pool import PoolUtil
from sardana.pool.controller import <ControllerClass>
change contructor from:
def __init__(self, inst, props):
code
to:
def __init__(self, inst, props, *args, **kwargs):
MotorController.__init__(self, inst, props, *args, **kwargs)
code
(and don’t forget to call the super class constructor also with args and kwargs).
The following change is not mandatory but is necessary in order for your controller to be recognized by the pool to be a API v1 controller:
_log member changed from logging.Logger to taurus.core.util.Logger. This means that you need to change code from:
self._log.setLevel(logging.INFO)
to:
self._log.setLogLevel(logging.INFO)
or:
self._log.setLogLevel(taurus.Info)
since taurus.Info == logging.INFO.
The following changes are not necessary to make your controller work. The API v1 supports the API v0 on these matters.
- from: class_prop to: ctrl_properties
- from: ctrl_extra_attributes to: axis_attributes
- new feature in API v1: ctrl_attributes
data types:
- StateOne() return type: Previously StateOne() had to return a member of PyTango.DevState. Now it can instead return a member of State. This eliminates the need to import PyTango.
- In API v0 class member (like ctrl_extra_attributes) value for key type had to be a string (like ‘PyTango.DevString’ or ‘PyTango.DevDouble’). Now they can be a python type (like str or float). Please check Data Type definition for more information.
generic controller method names:
- from: GetPar() to: GetAxisPar()
- from: SetPar() to: SetAxisPar()
- from: GetExtraAttributePar() to: GetAxisExtraPar()
- from: SetExtraAttributePar() to: SetAxisExtraPar()
- new feature in API v1: GetCtrlPar(), SetCtrlPar()
- new feature in API v1: AbortAll() (has default implementation which calls AbortOne() for each axis)
pseudo motor controller method names:
- from: calc_pseudo() to: CalcPseudo()
- from: calc_physical() to: CalcPhysical()
- from: calc_all_pseudo() to: CalcAllPseudo()
- from: calc_all_physical() to: CalcAllPhysical()
- new feature in API v1: GetMotor()
- new feature in API v1: GetPseudoMotor()
This chapter is a summary of all new features in API v1.
New controller features:
All Controllers now have a ctrl_attributes class member to define extra controller attributes (and new methods: GetCtrlPar(), SetCtrlPar())
For ctrl_properties, axis_attributes and ctrl_extra_attributes:
no need to import PyTango (StateOne() can return sardana.State.On instead of PyTango.DevState.ON)
PseudoMotorController has new GetMotor() and GetPseudoMotor()
new AbortAll() (with default implementation which calls AbortOne() for each axis)
new StopOne() (with default implementation which calls AbortOne())
new StopAll() (with default implementation which calls StoptOne() for each axis)
New acquisition features:
New Tango API features:
Others: