Commit 5edce1ac authored by Cyril Guilloud's avatar Cyril Guilloud Committed by Sebastien Petitdemange
Browse files

improve messages when opening/closing a tango shutter

parent abf5baaa
......@@ -29,7 +29,7 @@ from gevent import Timeout, sleep
from bliss import global_map
from bliss.common.shutter import BaseShutter, BaseShutterState
from bliss.common.tango import DeviceProxy, DevFailed
from bliss.common.logtools import log_warning
from bliss.common.logtools import log_warning, lprint
TangoShutterState = Enum(
......@@ -136,16 +136,19 @@ class TangoShutter(BaseShutter):
"""
state = self.state
if state.name in ("OPEN", "RUNNING"):
log_warning(self, "Already open, command ignored")
log_warning(self, f"{self.name} already open, command ignored")
elif state == TangoShutterState.CLOSED:
try:
self.__control.open()
self._wait(TangoShutterState.OPEN, timeout)
lprint(f"{self.name} was {state.name} and is now {self.state.name}")
except RuntimeError as err:
print(err)
raise
else:
raise RuntimeError(f"Cannot open: {state.value}")
raise RuntimeError(
f"Cannot open {self.name}, current state is: {state.value}"
)
def close(self, timeout=60):
"""Close
......@@ -156,16 +159,19 @@ class TangoShutter(BaseShutter):
"""
state = self.state
if state == TangoShutterState.CLOSED:
log_warning(self, "Already closed, command ignored")
log_warning(self, f"{self.name} already closed, command ignored")
elif state.name in ("OPEN", "RUNNING"):
try:
self.__control.close()
self._wait(TangoShutterState.CLOSED, timeout)
lprint(f"{self.name} was {state.name} and is now {self.state.name}")
except RuntimeError as err:
print(err)
raise
else:
raise RuntimeError(f"Cannot close: {state.value}")
raise RuntimeError(
f"Cannot close {self.name}, current state is: {state.value}"
)
@property
def mode(self):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment