Skip to content

Commit

Permalink
Merge branch 'master' into enh-rfdevice
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandohds564 committed Oct 24, 2024
2 parents 4641573 + 6b4c5b2 commit ac988dc
Show file tree
Hide file tree
Showing 2 changed files with 219 additions and 29 deletions.
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
FOFBPSLamp, FOFBPSSysId
from .ict import ICT, TranspEff
from .idff import IDFF
from .ids import APU, DELTA, EPU, ID, IDBase, PAPU, WIG
from .ids import APU, DELTA, EPU, ID, IDBase, PAPU, WIG, IVU
from .injctrl import InjCtrl
from .injsys import BOPSRampStandbyHandler, BORFRampStandbyHandler, \
InjSysPUModeHandler, InjSysStandbyHandler, LinacStandbyHandler, \
Expand Down
246 changes: 218 additions & 28 deletions siriuspy/siriuspy/devices/ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class _ParamPVs:
BLCTRL_ENBL_SEL = 'BeamLineCtrlEnbl-Sel'
BLCTRL_ENBL_STS = 'BeamLineCtrlEnbl-Sts'
MOVE_ABORT = None
RESET = None

# --- PPARAM ---
PPARAM_SP = None
Expand Down Expand Up @@ -62,6 +63,21 @@ class _ParamPVs:
POL_MON = None
POL_CHANGE_CMD = None

# --- POSITION ADJUSTS ---
CENTER_MODE_SEL = None
CENTER_MODE_STS = None
CENTER_OFFSET_SP = None
CENTER_OFFSET_RB = None
CENTER_OFFSET_MON = None
PITCH_MODE_SEL = None
PITCH_MODE_STS = None
PITCH_OFFSET_SP = None
PITCH_OFFSET_RB = None
PITCH_OFFSET_MON = None
KPARAM_TAPER_SP = None
KPARAM_TAPER_RB = None
KPARAM_TAPER_MON = None

def __str__(self):
"""Print parameters."""
str_ = ''
Expand Down Expand Up @@ -340,7 +356,7 @@ def kparameter_speed_max_lims(self):
@property
def kparameter_speed(self):
"""Return kparameter speed readback [mm/s]."""
return self[self.PARAM_PVS.KPARAM_VELO_SP]
return self[self.PARAM_PVS.KPARAM_VELO_RB]

@property
def kparameter_speed_mon(self):
Expand Down Expand Up @@ -900,11 +916,11 @@ class DEVICES:
'EnblAndReleasePhase-Sel', 'EnblAndReleasePhase-Sts',
'AllowedToChangePhase-Mon',
'StopPhase-Cmd', 'Log-Mon',
)
)
_properties_papu = (
'Home-Cmd', 'EnblPwrPhase-Cmd', 'ClearErr-Cmd',
'BeamLineCtrl-Mon',
)
)

PROPERTIES_DEFAULT = \
tuple(set(
Expand Down Expand Up @@ -1051,9 +1067,9 @@ def cmd_move_phase_start(self, timeout=None):
"""Command to start phase movement."""
return self.cmd_move_kparameter_start(timeout=timeout)

# --- cmd_reset
# --- cmd_enable

def cmd_device_reset(self, timeout=None):
def cmd_enable_movement(self, timeout=None):
"""Command to reset ID to a standard movement state."""
success = True
success &= self.cmd_beamline_ctrl_disable(timeout=timeout)
Expand Down Expand Up @@ -1358,7 +1374,7 @@ class DEVICES:
'ConsistentSetPoints-Mon', 'PLCState-Mon',
'Energy-SP', 'Energy-RB', 'Energy-Mon',
'KValue-SP', 'KValue-RB', 'KValue-Mon',
)
)

def __init__(self, devname=None, props2init='all', auto_monitor_mon=True):
"""."""
Expand Down Expand Up @@ -1473,24 +1489,10 @@ class DEVICES:
# --- PARAM_PVS ---
PARAM_PVS = _ParamPVs()
# PARAM_PVS.PERIOD_LEN_CTE = 'PeriodLength-Cte'
# PARAM_PVS.IS_MOVING = 'Moving-Mon'
PARAM_PVS.IS_MOVING = 'Moving-Mon'
# PARAM_PVS.START_PARKING_CMD = 'StartParking-Cmd'
# PARAM_PVS.MOVE_ABORT = 'Abort-Cmd'
# PARAM_PVS.PPARAM_SP = 'PParam-SP'
# PARAM_PVS.PPARAM_RB = 'PParam-RB'
# PARAM_PVS.PPARAM_MON = 'PParam-Mon'
# PARAM_PVS.PPARAM_PARKED_CTE = 'PParamParked-Cte'
# PARAM_PVS.PPARAM_MAXACC_SP = 'MaxAcc-SP'
# PARAM_PVS.PPARAM_MAXACC_RB = 'MaxAcc-RB'
# PARAM_PVS.PPARAM_MAXVELO_SP = 'MaxVelo-SP'
# PARAM_PVS.PPARAM_MAXVELO_RB = 'MaxVelo-RB'
# PARAM_PVS.PPARAM_VELO_SP = 'PParamVelo-SP'
# PARAM_PVS.PPARAM_VELO_RB = 'PParamVelo-RB'
# PARAM_PVS.PPARAM_ACC_SP = 'PParamAcc-SP'
# PARAM_PVS.PPARAM_ACC_RB = 'PParamAcc-RB'
# PARAM_PVS.PPARAM_TOL_SP = 'PolTol-SP'
# PARAM_PVS.PPARAM_TOL_RB = 'PolTol-RB'
# PARAM_PVS.PPARAM_CHANGE_CMD = 'PParamChange-Cmd'
PARAM_PVS.MOVE_ABORT = 'Abort-Cmd'
PARAM_PVS.RESET = 'Reset-Cmd'
PARAM_PVS.KPARAM_SP = 'KParam-SP'
PARAM_PVS.KPARAM_RB = 'KParam-RB'
PARAM_PVS.KPARAM_MON = 'KParam-Mon'
Expand All @@ -1503,13 +1505,25 @@ class DEVICES:
PARAM_PVS.KPARAM_VELO_RB = 'KParamVelo-RB'
PARAM_PVS.KPARAM_ACC_SP = 'KParamAcc-SP'
PARAM_PVS.KPARAM_ACC_RB = 'KParamAcc-RB'

PARAM_PVS.CENTER_MODE_STS = 'CenterMode-Sts'
PARAM_PVS.CENTER_MODE_SEL = 'CenterMode-Sel'
PARAM_PVS.PITCH_MODE_STS = 'PitchMode-Sts'
PARAM_PVS.PITCH_MODE_SEL = 'PitchMode-Sel'

PARAM_PVS.CENTER_OFFSET_SP = 'CenterOffset-SP'
PARAM_PVS.CENTER_OFFSET_RB = 'CenterOffset-RB'
PARAM_PVS.CENTER_OFFSET_MON = 'CenterOffset-Mon'
PARAM_PVS.PITCH_OFFSET_SP = 'PitchOffset-SP'
PARAM_PVS.PITCH_OFFSET_RB = 'PitchOffset-RB'
PARAM_PVS.PITCH_OFFSET_MON = 'PitchOffset-Mon'
PARAM_PVS.KPARAM_TAPER_SP = 'KParamTaper-SP'
PARAM_PVS.KPARAM_TAPER_RB = 'KParamTaper-RB'
PARAM_PVS.KPARAM_TAPER_MON = 'KParamTaper-Mon'

# PARAM_PVS.KPARAM_TOL_SP = 'PosTol-SP'
# PARAM_PVS.KPARAM_TOL_RB = 'PosTol-RB'
# PARAM_PVS.KPARAM_CHANGE_CMD = 'KParamChange-Cmd'
# PARAM_PVS.POL_SEL = 'Pol-Sel'
# PARAM_PVS.POL_STS = 'Pol-Sts'
# PARAM_PVS.POL_MON = 'Pol-Mon'
# PARAM_PVS.POL_CHANGE_CMD = 'PolChange-Cmd'
PARAM_PVS.KPARAM_CHANGE_CMD = 'KParamChange-Cmd'

PROPERTIES_DEFAULT = tuple(set(
value for key, value in _inspect.getmembers(PARAM_PVS)
Expand All @@ -1525,6 +1539,182 @@ def __init__(self, devname, props2init='all', auto_monitor_mon=True):
super().__init__(
devname, props2init=props2init, auto_monitor_mon=auto_monitor_mon)

# --- gap speeds ----

@property
def gap_speed(self):
"""Return gap speed readback [mm/s]."""
return self.kparameter_speed

@property
def gap_speed_mon(self):
"""Return gap speed monitor [mm/s]."""
return self.kparameter_speed_mon

@property
def gap_speed_max(self):
"""Return max gap speed readback [mm/s]."""
return self.kparameter_speed_max

@property
def gap_speed_max_lims(self):
"""Return max gap speed limits."""
return self.kparameter_speed_max_lims

# --- gap ---

@property
def gap_parked(self):
"""Return ID parked gap value [mm]."""
return self.kparameter_parked

@property
def gap(self):
"""Return ID gap readback [mm]."""
return self.kparameter

@property
def gap_lims(self):
"""Return ID gap control limits [mm]."""
return self.kparameter_lims

@property
def gap_mon(self):
"""Return ID gap monitor [mm]."""
return self.kparameter_mon

# --- taper ---

@property
def taper(self):
"""Return ID taper readback [mm]."""
return self[self.PARAM_PVS.KPARAM_TAPER_RB]

@property
def taper_mon(self):
"""Return ID taper monitor [mm]."""
return self[self.PARAM_PVS.KPARAM_TAPER_MON]

# --- pitch ---

@property
def pitch_mode_status(self):
"""Return ID pitch mode status."""
return self[self.PARAM_PVS.PITCH_MODE_STS]

@property
def pitch(self):
"""Return ID pitch readback [mm]."""
return self[self.PARAM_PVS.PITCH_OFFSET_RB]

@property
def pitch_mon(self):
"""Return ID pitch monitor [mm]."""
return self[self.PARAM_PVS.PITCH_OFFSET_MON]

# --- center ---

@property
def center_mode_status(self):
"""Return ID center mode status."""
return self[self.PARAM_PVS.CENTER_MODE_STS]

@property
def center_offset(self):
"""Return ID center offset readback [mm]."""
return self[self.PARAM_PVS.CENTER_OFFSET_RB]

@property
def center_offset_mon(self):
"""Return ID center offset monitor [mm]."""
return self[self.PARAM_PVS.CENTER_OFFSET_MON]

# --- set methods ---

def set_gap(self, gap, timeout=None):
"""Set ID target gap for movement [mm]."""
return self.set_kparameter(gap, timeout)

def set_gap_speed(self, gap_speed, timeout=None):
"""Set ID cruise gap speed for movement [mm/s]."""
return self.set_kparameter_speed(gap_speed, timeout)

def set_gap_speed_max(self, gap_speed_max, timeout=None):
"""Set ID max cruise gap speed for movement [mm/s]."""
return self.set_kparameter_speed_max(gap_speed_max, timeout)

def set_taper(self, taper, timeout=None):
"""Set ID target taper for movement [mm]."""
return self._write_sp(self.PARAM_PVS.KPARAM_TAPER_SP, taper, timeout)

def set_pitch(self, pitch, timeout=None):
"""Set ID pitch for movement [mm]."""
return self._write_sp(self.PARAM_PVS.PITCH_OFFSET_SP, pitch, timeout)

def set_center_offset(self, center_offset, timeout=None):
"""Set ID center offset for movement [mm]."""
return self._write_sp(self.PARAM_PVS.CENTER_OFFSET_SP, center_offset, timeout)

def set_center_mode(self, mode, timeout=None):
"""Set ID center mode True or False."""
if type(mode) != bool:
raise ValueError('Center mode must be boolean.')
if not mode:
self.set_taper(0, timeout)
return self._write_sp(self.PARAM_PVS.CENTER_MODE_SEL, mode, timeout)

def set_pitch_mode(self, mode, timeout=None):
"""Set ID pitch mode True or False."""
if type(mode) != bool:
raise ValueError('Pitch mode must be boolean.')
if not mode:
self.set_center_offset(0, timeout)
return self._write_sp(self.PARAM_PVS.PITCH_MODE_SEL, mode, timeout)

# --- cmd_move

def cmd_move_gap_start(self, timeout=None):
"""Command to start gap movement."""
if self.center_mode_status:
raise ValueError('Center offset mode must be disabled.')
if self.pitch_mode_status:
raise ValueError('Pitch mode must be disabled.')
if not _np.isclose(self.taper_mon, 0, atol=1e-4):
raise ValueError('Taper must be zero.')
return self.cmd_move_kparameter_start(timeout)

def cmd_move_taper_start(self, timeout=None):
"""Command to start taper movement.""" # Need to change PV for taper mov in IOC
if self.center_mode_status:
raise ValueError('Center offset mode must be disabled.')
if self.pitch_mode_status:
raise ValueError('Pitch mode must be disabled.')
return self._move_start(
self.PARAM_PVS.KPARAM_CHANGE_CMD, timeout=timeout)

def cmd_move_pitch_start(self, timeout=None):
"""Command to start pitch movement.""" # Need to change PV for pitch mov in IOC
if self.center_mode_status:
raise ValueError('Center offset mode must be disabled.')
if not _np.isclose(self.taper_mon, 0, atol=1e-4):
raise ValueError('Taper must be zero.')
return self._move_start(
self.PARAM_PVS.KPARAM_CHANGE_CMD, timeout=timeout)

def cmd_move_center_start(self, timeout=None):
"""Command to start center movement.""" # Need to change PV for center mov in IOC
if self.pitch_mode_status:
raise ValueError('Pitch mode must be disabled.')
if not _np.isclose(self.taper_mon, 0, atol=1e-4):
raise ValueError('Taper must be zero.')
return self._move_start(
self.PARAM_PVS.KPARAM_CHANGE_CMD, timeout=timeout)

# --- cmd_reset
def cmd_reset(self, timeout=None):
"""Command to reset undulator."""
return self._write_sp(
self.PARAM_PVS.RESET, timeout=timeout)

class ID(IDBase):
"""Insertion Device."""
Expand Down

0 comments on commit ac988dc

Please sign in to comment.