Commit 5d3efa3c authored by Matias Guijarro's avatar Matias Guijarro
Browse files

fix issue #2360

parent 09c6a849
Pipeline #38197 passed with stages
in 123 minutes and 45 seconds
......@@ -68,6 +68,10 @@ class TangoShutter(BaseShutter):
def _init_type(self):
self._frontend = "FrontEnd" in self.__control.info().dev_class
@property
def proxy(self):
return self.__control
@property
def frontend(self):
""" Check if the device is a front end type
......@@ -148,13 +152,14 @@ class TangoShutter(BaseShutter):
if state.name in ("OPEN", "RUNNING"):
log_warning(self, f"{self.name} already open, command ignored")
elif state == TangoShutterState.DISABLE:
log_warning(self, f"{self.name} disabled, command ignored")
elif state == TangoShutterState.CLOSED:
try:
self.__control.open()
self._wait(TangoShutterState.OPEN, timeout)
user_print(f"{self.name} was {state.name} and is now {self.state.name}")
except RuntimeError as err:
print(err)
raise
else:
raise RuntimeError(
......@@ -171,13 +176,14 @@ class TangoShutter(BaseShutter):
state = self.state
if state == TangoShutterState.CLOSED:
log_warning(self, f"{self.name} already closed, command ignored")
elif state == TangoShutterState.DISABLE:
log_warning(self, f"{self.name} disabled, command ignored")
elif state.name in ("OPEN", "RUNNING"):
try:
self.__control.close()
self._wait(TangoShutterState.CLOSED, timeout)
user_print(f"{self.name} was {state.name} and is now {self.state.name}")
except RuntimeError as err:
print(err)
raise
else:
raise RuntimeError(
......
......@@ -6,10 +6,11 @@
# Distributed under the GNU LGPLv3. See LICENSE for more info.
import pytest
import logging
from bliss.controllers.tango_shutter import TangoShutterState
def test_tango_shutter(beacon, dummy_tango_server):
def test_tango_shutter(beacon, dummy_tango_server, caplog):
sh = beacon.get("safshut")
assert sh.name == "safshut"
......@@ -18,9 +19,27 @@ def test_tango_shutter(beacon, dummy_tango_server):
sh.open(timeout=3)
assert sh.state == TangoShutterState.OPEN
assert sh.state_string[0] == TangoShutterState.OPEN.value
with caplog.at_level(logging.DEBUG, logger=f"global.controllers.{sh.name}"):
sh.open()
assert sh.state == TangoShutterState.OPEN
assert "ignored" in caplog.messages[-1]
sh.close(timeout=3)
assert sh.state == TangoShutterState.CLOSED
assert sh.state_string[0] == TangoShutterState.CLOSED.value
with caplog.at_level(logging.DEBUG, logger=f"global.controllers.{sh.name}"):
sh.close()
assert sh.state == TangoShutterState.CLOSED
assert "ignored" in caplog.messages[-1]
assert isinstance(sh.state_string, tuple)
sh.proxy.setDisabled(True)
with caplog.at_level(logging.DEBUG, logger=f"global.controllers.{sh.name}"):
sh.open()
assert sh.state == TangoShutterState.DISABLE
assert "ignored" in caplog.messages[-1]
with caplog.at_level(logging.DEBUG, logger=f"global.controllers.{sh.name}"):
sh.close()
assert sh.state == TangoShutterState.DISABLE
assert "ignored" in caplog.messages[-1]
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