contrast.motors package¶
Module contents¶
Provides the Motor
base class and derived motor classes.
Does not automatically load hardware-specific submodules or classes as these might have special dependencies that aren’t available everywhere.
Submodules¶
contrast.motors.Motor module¶
-
class
contrast.motors.Motor.
Motor
(scaling=1.0, offset=0.0, dial_limits=(None, None), user_format='%.2f', dial_format='%.2f', **kwargs)[source]¶ Bases:
contrast.Gadget.Gadget
General base class for motors.
Motors have dial and user positions, which are related by an offset and a scaling factor. The user position is supposed to be used in all macros and movements. The dial position is hard coded in the Motor subclass to closely reflect what the underlying device quotes.
user = dial * scaling + offset, dial = (user - offset) / scaling
The user position can be changed, which updates the offset but not the scaling. In the same way, limits on the user position are internally converted to dial limits, such that setting the user position leaves the dial limits unchanged.
Parameters: - scaling – Scaling factor from dial to user position
- offset – Offset from scaled dial to user position
- dial_limits – Motor limits in dial positions
- user_format – Format string for presenting user positions
- dial_format – Format string for presenting dial positions
- **kwargs – Passed on to base class constructor
-
dial_position
¶ Override this property, which sets or gets the dial position.
Return type: float
-
class
contrast.motors.Motor.
DummyMotor
(velocity=None, dial_position=None, *args, **kwargs)[source]¶ Bases:
contrast.motors.Motor.Motor
Dummy motor which can be harmlessly moved with a velocity of 1 / s.
-
class
contrast.motors.Motor.
MotorBookmark
(name, motors, positions=None)[source]¶ Bases:
object
A bookmark is a set of motor dial positions which together have some significance, for example a sample position or an attenuetor combination.
Parameters: - name – Name given to the MotorBookmark
- motors (list, tuple) – The motor instances to bookmark.
- positions (list, tuple) – List of positions to bookmark.
-
class
contrast.motors.Motor.
MotorMemorizer
(filepath=None, **kwargs)[source]¶ Bases:
contrast.Gadget.Gadget
Saves or loads motor scaling, offsets, and limits, as well as any defined bookmarks to or from file.
Parameters: - filepath (str) – Path to file where motor information will be dumped
- **kwargs – Passed on to the base class
-
class
contrast.motors.Motor.
Mv
(*args)[source]¶ Bases:
object
This class generates the macro `mv`
Move one or more motors.
mvr <motor1> <position1> <motor2> <position2> ...
-
class
contrast.motors.Motor.
Mvd
[source]¶ Bases:
object
This class generates the macro `mvd`
Move one or more motors to an abolute dial position. Not implemented.
-
class
contrast.motors.Motor.
Mvr
(*args)[source]¶ Bases:
contrast.motors.Motor.Mv
This class generates the macro `mvr`
Move one or more motors relative to their current positions.
mvr <motor1> <position1> <motor2> <position2> ...
-
class
contrast.motors.Motor.
Umv
(*args)[source]¶ Bases:
contrast.motors.Motor.Mv
This class generates the macro `umv`
Like mv, but prints the current position while moving, and returns when the move is complete.
-
class
contrast.motors.Motor.
Umvr
(*args)[source]¶ Bases:
contrast.motors.Motor.Mvr
,contrast.motors.Motor.Umv
This class generates the macro `umvr`
Like umv, but in positions relative to the current ones.
-
class
contrast.motors.Motor.
Wm
(*args)[source]¶ Bases:
object
This class generates the macro `wm`
Print the positions of one or more motors.
wm <motor1> <motor2> ...
-
class
contrast.motors.Motor.
WmS
(*args)[source]¶ Bases:
contrast.motors.Motor.Wm
This class generates the macro `wms`
Silent ‘where motor’. Print the positions of one or more motors but do not print any output.
wms <motor1> <motor2> ...
-
class
contrast.motors.Motor.
Wa
[source]¶ Bases:
contrast.motors.Motor.Wm
This class generates the macro `wa`
Print the positions of all motors available at the current user level.
-
class
contrast.motors.Motor.
LsM
[source]¶ Bases:
object
This class generates the macro `lsm`
List available motors.
-
class
contrast.motors.Motor.
SetLim
(*args)[source]¶ Bases:
object
This class generates the macro `setlim`
Set limits on motors.
setlim <motor1> <lower 1> <upper 1> ...
Also saves new limits to all available
MotorMemorizer
objects.
-
class
contrast.motors.Motor.
SetPos
(*args)[source]¶ Bases:
object
This class generates the macro `setpos`
Sets user position on motors.
setpos <motor1> <pos1> ...
Also saves new user positions to all available
MotorMemorizer
objects.
-
class
contrast.motors.Motor.
BookmarkMacroBase
(*args)[source]¶ Bases:
object
Base class for bookmark macros, which parses arguments into a list of MotorBookmark objects. If none are given, all bookmarks are included.
-
class
contrast.motors.Motor.
LsBook
(*args)[source]¶ Bases:
contrast.motors.Motor.BookmarkMacroBase
This class generates the macro `lsbook`
Lists the currently defined bookmarks or the contents of a specific bookmark.
lsbook [<bookmark name>]
-
class
contrast.motors.Motor.
Bookmark
(name, *args)[source]¶ Bases:
object
This class generates the macro `bookmark`
Bookmarks the specified motors at their current dial positions.
bookmark <'bookmark name'> <motor 1> <motor 2> ...
Also saves existing bookmarks to all available
MotorMemorizer
objects.
-
class
contrast.motors.Motor.
Restore
(*args)[source]¶ Bases:
contrast.motors.Motor.BookmarkMacroBase
This class generates the macro `restore`
Restore a bookmarked position by moving all motors there.
-
class
contrast.motors.Motor.
RmBook
(*args)[source]¶ Bases:
contrast.motors.Motor.BookmarkMacroBase
This class generates the macro `rmbook`
Delete one or all bookmarks defined with the bookmark command.
rmbook [<bookmark 1> <bookmark 2> ...]
Also updates all available
MotorMemorizer
instances.
contrast.motors.PseudoMotor module¶
Provides base and example classes for pseudo motors, which are combinations of other motors.
-
class
contrast.motors.PseudoMotor.
PseudoMotor
(motors, dry_run=False, *args, **kwargs)[source]¶ Bases:
contrast.motors.Motor.Motor
Pseudo motor base class.
Abstract base class for pseudo motors. The logic of pseudo motors needs some attention.
Parameters: - motors – The underlying physical motors.
- dry_run (bool) – Don’t move any physical motors, just print calculated positions.
-
class
contrast.motors.PseudoMotor.
ExamplePseudoMotor
(motors, dry_run=False, *args, **kwargs)[source]¶ Bases:
contrast.motors.PseudoMotor.PseudoMotor
Example pseudo motor which implements the difference between two motors.
Abstract base class for pseudo motors. The logic of pseudo motors needs some attention.
Parameters: - motors – The underlying physical motors.
- dry_run (bool) – Don’t move any physical motors, just print calculated positions.
contrast.motors.E727 module¶
Provides a Motor subclass for the PI E727 piezo driver.
-
class
contrast.motors.E727.
E727Motor
(device, axis, **kwargs)[source]¶ Bases:
contrast.motors.Motor.Motor
Single axis on the E727.
Parameters: - device (str) – Path to the Tango device
- axis (int) – Axis number of the E727 controller
- **kwargs – Passed to the
Motor
base class
contrast.motors.KukaMotor module¶
Provides a Motor interface to the MAX IV Kuka robot Tango device.
-
class
contrast.motors.KukaMotor.
KukaRobot
(tango_path, names=['gamma', 'delta', 'radius'])[source]¶ Bases:
object
Managing class which coordinates movements of the robot in polar coordinates. The manager’s role is to avoid trying to move more than one robot motor at a time, which would not be compatible with the controller.
This class owns three
KukaMotor
instances, which are returned on iteration:gamma, delta, radius = KukaRobot('path/to/device', names=['gamma, 'delta', 'radius'])
Parameters: - tango_path (str) – Path to the underlying Tango device
- names (list, tuple) – Names to assign to the three polar motors
-
move_me
(motor, pos)[source]¶ Method which makes sure that only one polar axis is moved at a time. For now, this is done by blocking until the device is standing still. Should perhaps be threaded or so, but works like this for scanning for example the two polar angles in a mesh.
Parameters: - motor – Motor instance to move, typically
self
for the callingKukaMotor
. - pos (float) – Target position
- motor – Motor instance to move, typically
-
class
contrast.motors.KukaMotor.
KukaMotor
(manager, **kwargs)[source]¶ Bases:
contrast.motors.Motor.Motor
Single motor as exposed by the
KukaRobot
class.Parameters: - manager – Managing
KukaRobot
instance - **kwargs – Passed on to the base class constructor
- manager – Managing
contrast.motors.LC400 module¶
Provides a Motor subclass for the Npoint LC400 piezo driver, and a helper class for generating waveforms. Relies on the Tango server developed at MAX IV (available on request!):
- https://gitlab.maxiv.lu.se/kits-maxiv/lib-maxiv-npoint-lc400
- https://gitlab.maxiv.lu.se/kits-maxiv/dev-maxiv-npoint-lc400
-
class
contrast.motors.LC400.
LC400Motor
(device, axis, **kwargs)[source]¶ Bases:
contrast.motors.Motor.Motor
Single axis on the LC400.
Parameters: - device (str) – Path to the underlying Tango device.
- axis – Axis number on the Tango controller
- **kwargs – Passed on to the base class constructor
-
class
contrast.motors.LC400.
LC400Waveform
(axis, startpoint, endpoint, scanpoints, exposuretime, latencytime, accelerationtime, decelerationtime=None, startvelocity=None, endvelocity=None)[source]¶ Bases:
object
Class to generate waveform configs for the LC400 piezo controller. It generates a JSON string, that can be send to the LC400 Tango Server to configure the waveform.
contrast.motors.SmaractMotor module¶
Provides a Motor
subclass for Smaract positioners. All numbers in
micrometers.
Controls these via a MAX IV Tango device, https://gitlab.maxiv.lu.se/kits-maxiv/dev-maxiv-mcs
-
class
contrast.motors.SmaractMotor.
SmaractLinearMotor
(device, axis, velocity=None, **kwargs)[source]¶ Bases:
contrast.motors.Motor.Motor
Single Smaract motor axis.
Parameters: - device (str) – Path to the MCS Tango device
- axis (int) – Axis number on the controller
- velocity (float) – Initialize velocity, defaults to None
- **kwargs – Passed on to the
Motor
base class
contrast.motors.TangoAttributeMotor module¶
Provides a general Motor interface to any Tango attribute.
-
class
contrast.motors.TangoAttributeMotor.
TangoAttributeMotor
(device, attribute, force_read=True, **kwargs)[source]¶ Bases:
contrast.motors.Motor.Motor
Motor interface to any Tango attribute, so that anything can be scanned. These motors cannot be stopped and are never considered busy.
Parameters: - device (str) – Path to the Tango device
- attribute (str) – Name of the Tango attribute
- **kwargs – Passed to the
Motor
base class
contrast.motors.TangoMotor module¶
Provides a Motor interface to standard Tango motors.
-
class
contrast.motors.TangoMotor.
TangoMotor
(device, **kwargs)[source]¶ Bases:
contrast.motors.Motor.Motor
Single Tango motor.
Parameters: - device (str) – Path to the Tango device
- **kwargs – Passed to the
Motor
base class
-
dial_limits
¶ Overridden to expose the limits on the Pool motor.