Something updated

This commit is contained in:
gac-x06da 2025-03-14 14:17:25 +01:00 committed by mohacsi_i
parent 59103f16c6
commit 5b60842eda
2 changed files with 25 additions and 14 deletions

View File

@ -5,3 +5,4 @@ from ophyd.sim import SynAxis, SynPeriodicSignal, SynSignal
from .epics_motor_ex import EpicsMotorEx from .epics_motor_ex import EpicsMotorEx
from .sls_devices import SLSInfo, SLSOperatorMessages from .sls_devices import SLSInfo, SLSOperatorMessages
from .SpmBase import SpmBase from .SpmBase import SpmBase
from .psi_motor import EpicsMotorMR, EpicsMotorEC

View File

@ -1,12 +1,10 @@
""" Extension class for EpicsMotor """Extension class for EpicsMotor
This module extends the basic EpicsMotor with additional functionality. It This module extends the basic EpicsMotor with additional functionality. It
exposes additional parameters of the EPICS MotorRecord and provides a more exposes additional parameters of the EPICS MotorRecord and provides a more
detailed interface for motors using the new ECMC-based motion systems at PSI. detailed interface for motors using the new ECMC-based motion systems at PSI.
""" """
import warnings
from ophyd import Component, EpicsMotor, EpicsSignal, EpicsSignalRO, Kind from ophyd import Component, EpicsMotor, EpicsSignal, EpicsSignalRO, Kind
from ophyd.status import DeviceStatus, MoveStatus from ophyd.status import DeviceStatus, MoveStatus
from ophyd.utils.errors import UnknownStatusFailure from ophyd.utils.errors import UnknownStatusFailure
@ -47,22 +45,23 @@ class EpicsMotorMR(EpicsMotor):
This could get it deadlock if it was previously explicitly stopped. This could get it deadlock if it was previously explicitly stopped.
""" """
# Reset SPMG before move # Reset SPMG before move
spmg = self.motor_mode.get() if self.motor_mode.get() != SpmgStates.GO:
if spmg != SpmgStates.GO:
self.motor_mode.set(SpmgStates.GO).wait() self.motor_mode.set(SpmgStates.GO).wait()
# Warn if EPIC motorRecord claims an error (it's not easy to reset) # Warn if EPIC motorRecord claims an error (it's not easy to reset)
status = self.motor_status.get() status = self.motor_status.get()
if status: if status:
warnings.warn( self.log.warning(
f"EPICS MotorRecord is in alarm state {status}, ophyd will raise", RuntimeWarning f"EPICS MotorRecord is in alarm state {status}, ophyd will raise"
) )
# Warni if trying to move beyond an active limit # Warn if trying to move beyond an active limit
# if self.high_limit_switch and position > self.position: # NOTE: VME limit switches active only in the direction of travel (or disconnected)
# warnings.warn("Attempting to move above active HLS", RuntimeWarning) # NOTE: SoftMotor limits are not propagated at all
# if self.low_limit_switch and position < self.position: if self.high_limit_switch.get(use_monitor=False) and position > self.position:
# warnings.warn("Attempting to move below active LLS", RuntimeWarning) self.log.warning("Attempting to move above active HLS")
if self.low_limit_switch.get(use_monitor=False) and position < self.position:
self.log.warning("Attempting to move below active LLS")
# EpicsMotor might raise # EpicsMotor might raise if MR is in alarm
try: try:
status = super().move(position, wait, **kwargs) status = super().move(position, wait, **kwargs)
return status return status
@ -84,7 +83,12 @@ class EpicsMotorEC(EpicsMotorMR):
USER_ACCESS = ["reset"] USER_ACCESS = ["reset"]
motor_enable_readback = Component(EpicsSignalRO, "-EnaAct", auto_monitor=True, kind=Kind.normal) motor_enable_readback = Component(EpicsSignalRO, "-EnaAct", auto_monitor=True, kind=Kind.normal)
motor_enable = Component( motor_enable = Component(
EpicsSignal, "-EnaCmd-RB", write_pv="-EnaCmd", auto_monitor=True, kind=Kind.normal EpicsSignalRO,
"-EnaCmd-RB",
write_pv="-EnaCmd",
put_complete=True,
auto_monitor=True,
kind=Kind.normal,
) )
homed = Component(EpicsSignalRO, "-Homed", auto_monitor=True, kind=Kind.normal) homed = Component(EpicsSignalRO, "-Homed", auto_monitor=True, kind=Kind.normal)
velocity_readback = Component(EpicsSignalRO, "-VelAct", auto_monitor=True, kind=Kind.normal) velocity_readback = Component(EpicsSignalRO, "-VelAct", auto_monitor=True, kind=Kind.normal)
@ -112,6 +116,12 @@ class EpicsMotorEC(EpicsMotorMR):
if error: if error:
raise RuntimeError(f"Motor is in error state with message: '{self.error_msg.get()}'") raise RuntimeError(f"Motor is in error state with message: '{self.error_msg.get()}'")
# Warn if trying to move beyond an active limit
if self.high_interlock.get(use_monitor=False) and position > self.position:
self.log.warning("Attempting to move above active HLS or Ilock")
if self.high_interlock.get(use_monitor=False) and position < self.position:
self.log.warning("Attempting to move below active LLS or Ilock")
return super().move(position, wait, **kwargs) return super().move(position, wait, **kwargs)
def reset(self): def reset(self):