From e7262af6286351ea20745ac99e46bcf2252a10df Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Wed, 26 Apr 2023 14:48:39 +0200 Subject: [PATCH] added warning when moving status PV name does not have an expected suffix --- slic/core/adjustable/pvadjustable.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/slic/core/adjustable/pvadjustable.py b/slic/core/adjustable/pvadjustable.py index c99a3407..c984a6eb 100644 --- a/slic/core/adjustable/pvadjustable.py +++ b/slic/core/adjustable/pvadjustable.py @@ -1,5 +1,6 @@ from time import sleep, time from types import SimpleNamespace +from warnings import warn from slic.utils import typename from slic.utils.hastyepics import get_pv as PV @@ -144,6 +145,8 @@ class PVAdjustable(Adjustable): +SUFFICES_MOVING = ["MOVING"] +SUFFICES_DONE_MOVING = ["DMOV", "WAITING"] def make_pcm(pvname_done_moving, pvname_moving): @@ -151,14 +154,23 @@ def make_pcm(pvname_done_moving, pvname_moving): raise ValueError("please provide only pvname_done_moving or pvname_moving, but not both") if pvname_moving: + validate_suffix(pvname_moving, SUFFICES_MOVING) return PVChangeMonitor(pvname_moving, inverted=False) if pvname_done_moving: + validate_suffix(pvname_done_moving, SUFFICES_DONE_MOVING) return PVChangeMonitor(pvname_done_moving, inverted=True) return None +def validate_suffix(name, expected): + suffix = name.split(":")[-1] + if suffix not in expected: + warn(f'suffix "{suffix}" of "{name}" is not from: {expected}', stacklevel=2) + + + def handle_put_return_value(ret): if ret == 1: # success return None