diff --git a/slic/devices/general/motor.py b/slic/devices/general/motor.py index a1cf06758..095e29bcb 100644 --- a/slic/devices/general/motor.py +++ b/slic/devices/general/motor.py @@ -2,6 +2,7 @@ import subprocess from types import SimpleNamespace from contextlib import contextmanager import colorama +import numpy as np from slic.core.adjustable import Adjustable, AdjustableError from slic.core.adjustable.convenience import SpecConvenienceProgress @@ -81,7 +82,7 @@ class Motor(Adjustable, SpecConvenienceProgress): def set_target_value(self, value, check_limits=True, show_progress=False): ignore_limits = not check_limits - low, high = self.get_limits() + low, high = self.get_epics_limits() if low == high == 0: ignore_limits = True @@ -117,14 +118,21 @@ class Motor(Adjustable, SpecConvenienceProgress): self._motor.stop() - def get_limits(self, pos_type="user"): + def get_epics_limits(self, pos_type="user"): check_pos_type(pos_type) low_name, high_name = POS_TYPE_LIMIT_NAMES[pos_type] low = self._motor.get(low_name) high = self._motor.get(high_name) return low, high - def set_limits(self, low, high, relative_to_current=False, pos_type="user"): + def set_epics_limits(self, low, high, relative_to_current=False, pos_type="user"): + if low is None and high is None: + low = high = 0 + self._motor.put(low_name, low) + self._motor.put(high_name, high) + return + low = -np.inf if low is None else low + high = +np.inf if high is None else high check_pos_type(pos_type) low_name, high_name = POS_TYPE_LIMIT_NAMES[pos_type] if relative_to_current: @@ -134,8 +142,8 @@ class Motor(Adjustable, SpecConvenienceProgress): self._motor.put(low_name, low) self._motor.put(high_name, high) - def print_limits(self): - low, high = self.get_limits() + def print_epics_limits(self): + low, high = self.get_epics_limits() val = self.get_current_value() res = RangeBar(low, high).get(val) print(res) diff --git a/slic/devices/general/smaract.py b/slic/devices/general/smaract.py index bfd561d4a..ed2cbd7d3 100644 --- a/slic/devices/general/smaract.py +++ b/slic/devices/general/smaract.py @@ -132,16 +132,18 @@ class SmarActAxis(Adjustable): return self.pvs.status.get() - def within_limits(self, val): - low, high = self.get_limits() + def within_epics_limits(self, val): + low, high = self.get_epics_limits() return low <= val <= high - def get_limits(self): + def get_epics_limits(self): low = self.pvs.llm.get() high = self.pvs.hlm.get() return low, high - def set_limits(self, low, high, relative_to_current=False): + def set_epics_limits(self, low, high, relative_to_current=False): + low = -np.inf if low is None else low + high = +np.inf if high is None else high if relative_to_current: val = self.get_current_value() low += val @@ -201,7 +203,7 @@ class SmarActAxis(Adjustable): val += self.pvs.drive.get() if not ignore_limits: - if not self.within_limits(val): + if not self.within_epics_limits(val): return OUTSIDE_LIMITS put_stat = self.pvs.drive.put(val, wait=wait, timeout=timeout) diff --git a/slic/devices/loptics/bernina_experiment.py b/slic/devices/loptics/bernina_experiment.py index 9f335646d..3ec9c9cdc 100755 --- a/slic/devices/loptics/bernina_experiment.py +++ b/slic/devices/loptics/bernina_experiment.py @@ -56,10 +56,10 @@ class DelayTime(AdjustableVirtual): def get_limits(self): return [self._mm_to_s(tl) for tl in self._stage.get_limits()] - def set_limits(self, low_limit, high_limit): + def set_epics_limits(self, low_limit, high_limit): lims_stage = [self._s_to_mm(tl) for tl in [low_limit, high_limit]] lims_stage.sort() - self._stage.set_limits(*lims_stage) + self._stage.set_epics_limits(*lims_stage) return [self._mm_to_s(tl) for tl in self._stage.get_limits()] diff --git a/slic/devices/xdiagnostics/intensity_monitors_new.py b/slic/devices/xdiagnostics/intensity_monitors_new.py index ebd496b24..7050ee952 100755 --- a/slic/devices/xdiagnostics/intensity_monitors_new.py +++ b/slic/devices/xdiagnostics/intensity_monitors_new.py @@ -66,8 +66,8 @@ class SolidTargetDetectorPBPS_new: PV(tc).put(bytes(str(tv), "utf8")) def get_calibration_values_position(self, calib_intensities, seconds=5, motion_range=0.2): - self.x_diodes.set_limits(-motion_range / 2 - 0.1, +motion_range / 2 + 0.1) - self.y_diodes.set_limits(-motion_range / 2 - 0.1, +motion_range / 2 + 0.1) + self.x_diodes.set_epics_limits(-motion_range / 2 - 0.1, +motion_range / 2 + 0.1) + self.y_diodes.set_epics_limits(-motion_range / 2 - 0.1, +motion_range / 2 + 0.1) self.x_diodes.set_target_value(0).wait() self.y_diodes.set_target_value(0).wait() raw = [] diff --git a/slic/devices/xoptics/attenuator_aramis_new.py b/slic/devices/xoptics/attenuator_aramis_new.py index 9f9644f7d..2de45c553 100755 --- a/slic/devices/xoptics/attenuator_aramis_new.py +++ b/slic/devices/xoptics/attenuator_aramis_new.py @@ -7,7 +7,7 @@ from slic.utils.hastyepics import get_pv as PV class AttenuatorAramis: - def __init__(self, ID, E_min=1500, sleeptime=1, name=None, set_limits=[-52, 2], pulse_picker=None): + def __init__(self, ID, E_min=1500, sleeptime=1, name=None, limits=[-52, 2], pulse_picker=None): self.ID = ID self._pv_status_str = PV(ID + ":MOT2TRANS.VALD") self._pv_status_int = PV(ID + ":IDX_RB") @@ -21,8 +21,8 @@ class AttenuatorAramis: for n, mot in enumerate(self.motors): self.__dict__[f"motor_{n+1}"] = mot self.alias.append(mot.alias) - if set_limits: - mot.set_limits(*set_limits) + if limits: + mot.set_epics_limits(*limits) def updateE(self, energy=None):