| |
Epics Motor Class, using EpicsCA, and automatic callbacks
This module provides a class library for the EPICS motor record.
It uses the EpicsCA.PV class, and emulates
Virtual attributes:
These attributes do not appear in the dictionary for this class, but
are implemented with the __getattr__ and __setattr__ methods. They
simply get or putthe appropriate motor record fields. All attributes
can be both read and written unless otherwise noted.
Attribute Description Field
--------- ----------------------- -----
drive Motor Drive Value .VAL
readback Motor Readback Value .RBV (read-only)
slew_speed Slew speed or velocity .VELO
base_speed Base or starting speed .VBAS
acceleration Acceleration time (sec) .ACCL
description Description of motor .DESC
resolution Resolution (units/step) .MRES
high_limit High soft limit (user) .HLM
low_limit Low soft limit (user) .LLM
dial_high_limit High soft limit (dial) .DHLM
dial_low_limit Low soft limit (dial) .DLLM
backlash Backlash distance .BDST
offset Offset from dial to user .OFF
done_moving 1=Done, 0=Moving, read-only .DMOV
Exceptions:
The check_limits() method raises an 'MotorLimitException' if a soft limit
or hard limit is detected. The move() method calls
check_limits() unless they are called with the
ignore_limits=True keyword set.
Example use:
from EpicsCA import Motor
m = Motor('13BMD:m38')
m.move(10) # Move to position 10 in user coordinates
m.move(100, dial=True) # Move to position 100 in dial coordinates
m.move(1, raw=True, relative=True) # Move 1 step relative to current position
m.stop() # Stop moving immediately
high = m.high_limit # Get the high soft limit in user coordinates
m.dial_high_limit = 100 # Set the high limit to 100 in dial coodinates
speed = m.slew_speed # Get the slew speed
m.acceleration = 0.1 # Set the acceleration to 0.1 seconds
p=m.get_position() # Get the desired motor position in user coordinates
p=m.get_position(dial=1) # Get the desired motor position in dial coordinates
p=m.get_position(readback=1) # Get the actual position in user coordinates
p=m.get_position(readback=1, step=1) Get the actual motor position in steps
p=m.set_position(100) # Set the current position to 100 in user coordinates
# Puts motor in Set mode, writes value, puts back in Use mode.
p=m.set_position(10000, step=1) # Set the current position to 10000 steps |
| |
Methods defined here:
- __getattr__(self, attr)
- internal method
- __init__(self, name=None, timeout=1.0)
- __repr__(self)
- __setattr__(self, attr, val)
- __str__(self)
- check_limits(self)
- check motor limits:
returns None if no limits are violated
raises expection if a limit is violated
- clear_field_callback(self, attr)
- connect_all(self)
- get_field(self, attr, use_char=False)
- get_position(self, dial=False, readback=False, step=False, raw=False)
- Returns the target or readback motor position in user, dial or step
coordinates.
Keywords:
readback:
Set readback=True to return the readback position in the
desired coordinate system. The default is to return the
drive position of the motor.
dial:
Set dial=True to return the position in dial coordinates.
The default is user coordinates.
raw (or step):
Set raw=True to return the raw position in steps.
The default is user coordinates.
Notes:
The "raw" or "step" and "dial" keywords are mutually exclusive.
The "readback" keyword can be used in user, dial or step
coordinates.
Examples:
m=epicsMotor('13BMD:m38')
m.move(10) # Move to position 10 in user coordinates
p=m.get_position(dial=True) # Read the target position in dial coordinates
p=m.get_position(readback=True, step=True) # Read the actual position in steps
- get_pv(self, attr)
- return full PV for a field
- has_attr(self, attr)
- lookup_attribute(self, suffix)
- Reverse look-up of an attribute name given the PV suffix
- move(self, val=None, relative=None, wait=False, timeout=3600.0, dial=False, step=False, raw=False, ignore_limits=False)
- moves motor drive to position
arguments:
value value to move to (float) [Must be provided]
relative move relative to current position (T/F) [F]
wait whether to wait for move to complete (T/F) [F]
dial use dial coordinates (T/F) [F]
raw use raw coordinates (T/F) [F]
step use raw coordinates (backward compat)(T/F) [F]
ignore_limits try move without regard to limits (T/F) [F]
timeout max time for move to complete (in seconds) [3600]
returns:
None : unable to move, invalid value given
-1 : target value outside limits -- no move attempted
-2 : with wait=True, wait time exceeded timeout
0 : move executed successfully
will raise an exception if a motor limit is met.
- put_field(self, attr, val, wait=False)
- set a Motor attribute (field) to a value
example:
>>> motor = Motor('XX:m1')
>>> motor.put_field('slew_speed', 2)
which would be equivalent to
>>> motor.slew_speed = 2
setting the optional 'wait' keyword to True will
cause this routine to wait to return until the
put is complete. This is most useful when setting
the field may take time to complete, as when moving
the motor position. That is,
>>> motor.put_field('drive', 2, wait=True)
will wait until the motor has moved to drive position 2.
- refresh(self)
- refresh all motor parameters currently in use:
make sure all used attributes are up-to-date.
- set_field_callback(self, attr, callback, kw={})
- set_position(self, position, dial=False, step=False, raw=False)
- Sets the motor position in user, dial or step coordinates.
Inputs:
position:
The new motor position
Keywords:
dial:
Set dial=True to set the position in dial coordinates.
The default is user coordinates.
raw:
Set raw=True to set the position in raw steps.
The default is user coordinates.
Notes:
The 'raw' and 'dial' keywords are mutually exclusive.
Examples:
m=epicsMotor('13BMD:m38')
m.set_position(10, dial=True) # Set the motor position to 10 in
# dial coordinates
m.set_position(1000, raw=True) # Set the motor position to 1000 steps
- show_all(self)
- show all motor attributes
- show_info(self)
- show basic motor settings
- stop(self)
- stop motor right now
- store_attr(self, attr)
- tweak(self, dir='forward', wait=False, timeout=3600.0)
- move the motor by the tweak_val
takes optional args:
dir direction of motion (forward/reverse) [forward]
must start with 'rev' or 'back' for a reverse tweak.
wait wait for move to complete before returning (T/F) [F]
timeout max time for move to complete (in seconds) [3600]
- wait(self, **kw)
- deprecated: use move(val, wait=True)
- wait_for_put(self, field, timeout=3600.0)
- wait for put on a field to complete:
returns True if put completed before timeout
returns False if put timed out
- within_limits(self, val, lims)
- returns whether a value for a motor is within drive limits,
|