Skip to content

Commit

Permalink
Merge pull request #98 from ZLLentz/scan_fix_changes
Browse files Browse the repository at this point in the history
MNT: Macro Motor Scan Fixes
  • Loading branch information
ZLLentz authored Jul 6, 2020
2 parents e83f171 + 0e99619 commit 8f566f9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
7 changes: 4 additions & 3 deletions hxrsnd/aerotech.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ def move(self, position, wait=False, check_status=True, timeout=None, *args,
return super().move(position, wait=wait, timeout=timeout, *args,
**kwargs)

def mv(self, position, wait=True, print_move=True, *args, **kwargs):
def mv(self, position, wait=True, print_move=True,
*args, **kwargs):
"""
Move to a specified position, optionally waiting for motion to
complete. mv() is different from move() by catching all the common
Expand Down Expand Up @@ -275,7 +276,7 @@ def mv(self, position, wait=True, print_move=True, *args, **kwargs):
Status object for the move.
"""
try:
status = super().mv(position, wait=wait, *args, **kwargs)
status = self.move(position, wait=wait, *args, **kwargs)

# Notify the user that a motor has completed or the command is sent
if print_move:
Expand Down Expand Up @@ -763,7 +764,7 @@ def mv(self, position, *args, **kwargs):
Status object for the move.
"""
try:
return super().mv(position, *args, **kwargs)
return self.move(position, *args, **kwargs)
# Catch a bad pressure setting.
except BadN2Pressure:
logger.warning("Cannot move - pressure in tower {0} is bad.".format(
Expand Down
7 changes: 4 additions & 3 deletions hxrsnd/attocube.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from .sndmotor import SndMotor
from .snddevice import SndDevice
from .exceptions import MotorDisabled, MotorError
from .exceptions import MotorDisabled, MotorError, MotorFaulted
from .utils import absolute_submodule_path, as_list

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -306,7 +306,8 @@ def move(self, position, check_status=True, timeout=None, *args, **kwargs):
# Begin the move process
return self.user_setpoint.set(position, timeout=timeout)

def mv(self, position, print_move=True, *args, **kwargs):
def mv(self, position, print_move=True, wait=None,
*args, **kwargs):
"""
Move to a specified position, optionally waiting for motion to
complete. mv() is different from move() by catching all the common
Expand Down Expand Up @@ -340,7 +341,7 @@ def mv(self, position, print_move=True, *args, **kwargs):
Status object for the move.
"""
try:
status = super().mv(position, *args, **kwargs)
status = self.move(position, *args, **kwargs)

# Notify the user that a motor has completed or the command is sent
if print_move:
Expand Down
15 changes: 9 additions & 6 deletions hxrsnd/macromotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import numpy as np
from ophyd.signal import AttributeSignal
from ophyd.sim import NullStatus
from ophyd.device import Component as Cmp
from ophyd.utils import LimitError
from ophyd.status import wait as status_wait
Expand Down Expand Up @@ -40,6 +41,7 @@ def __init__(self, prefix, name=None, read_attrs=None, *args, **kwargs):
read_attrs = read_attrs or ["readback"]
super().__init__(prefix, name=name, read_attrs=read_attrs, *args,
**kwargs)
self._status = NullStatus()

# Make sure this is used
if not self.parent:
Expand Down Expand Up @@ -123,8 +125,7 @@ def wait(self, status=None):
"""
status = status or self._status
logger.info("Waiting for the motors to finish moving...")
for s in list(status):
status_wait(s)
status_wait(status)
logger.info("Move completed.")

def set(self, position, wait=True, verify_move=True, ret_status=True,
Expand Down Expand Up @@ -165,7 +166,8 @@ def set(self, position, wait=True, verify_move=True, ret_status=True,
ret_status=ret_status, use_diag=use_diag,
use_calib=use_calib)

def move(self, position, wait=True, verify_move=True, use_diag=True):
def move(self, position, wait=True, verify_move=True, use_diag=True,
*args, **kwargs):
"""
Moves the macro-motor to the inputted position, optionally waiting for
the motors to complete their moves. Alias for set().
Expand Down Expand Up @@ -212,15 +214,16 @@ def move(self, position, wait=True, verify_move=True, use_diag=True):

# Aggregate the status objects
status = reduce(lambda x, y: x & y, status_list)
self._status = status

# Wait for all the motors to finish moving
if wait:
self.wait(status)

return status

def mv(self, position, wait=True, verify_move=True, use_diag=True, *args,
**kwargs):
def mv(self, position, wait=True, verify_move=True, use_diag=True,
*args, **kwargs):
"""
Moves the macro parameters to the inputted positions. For energy, this
moves the energies of both lines, energy1 moves just the delay line,
Expand Down Expand Up @@ -276,7 +279,7 @@ def mv(self, position, wait=True, verify_move=True, use_diag=True, *args,
List of status objects for each motor that was involved in the move.
"""
try:
return super().mv(position, wait=wait, verify_move=verify_move,
return self.move(position, wait=wait, verify_move=verify_move,
use_diag=use_diag, *args, **kwargs)
# Catch all the common motor exceptions
except LimitError:
Expand Down
1 change: 1 addition & 0 deletions hxrsnd/sndmotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class SndEpicsMotor(PCDSMotorBase, SndMotor):
signals
"""
direction_of_travel = Cmp(Signal)
motor_spg = Cmp(Signal, value=2)


class SamMotor(SndMotor):
Expand Down

0 comments on commit 8f566f9

Please sign in to comment.