Commit e1c63d65 authored by Antonia Beteva's avatar Antonia Beteva
Browse files

Event sent when state changes.

parent 27db1cdf
Pipeline #29949 failed with stages
in 63 minutes and 47 seconds
......@@ -30,6 +30,8 @@ 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, lprint
from bliss.config.channels import Channel
from bliss.common import event
TangoShutterState = Enum(
......@@ -59,6 +61,10 @@ class TangoShutter(BaseShutter):
self._mode = None
self._state_channel = Channel(
f"{name}:state", default_value="UNKNOWN", callback=self.__state_changed
def _init_type(self):
self._frontend = "FrontEnd" in
......@@ -116,6 +122,10 @@ class TangoShutter(BaseShutter):
except DevFailed:
raise RuntimeError(f"Communication error with {self.__control.dev_name()}")
def __state_changed(self, stat):
"""Send a signal when state changes"""
event.send(self, "state", stat)
def state_string(self):
"""Return state as combined string
......@@ -135,6 +145,7 @@ class TangoShutter(BaseShutter):
RuntimeError: Cannot execute if device in wrong state
state = self.state
if in ("OPEN", "RUNNING"):
log_warning(self, f"{} already open, command ignored")
elif state == TangoShutterState.CLOSED:
......@@ -212,7 +223,7 @@ class TangoShutter(BaseShutter):
RuntimeError: Cannot execute
RuntimeError: Cannot execute
......@@ -227,6 +238,7 @@ class TangoShutter(BaseShutter):
with Timeout(timeout, RuntimeError("Execution timeout")):
while self.state != state:
def _wait_mode(self, mode, timeout=3):
with Timeout(timeout, RuntimeError(f"Cannot set {mode} opening")):
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