Commit eed6d803 authored by Cyril Guilloud's avatar Cyril Guilloud
Browse files

* add 2s delay before to check mode to bypass tango server issue

* comments
parent 028e3d7f
...@@ -18,13 +18,13 @@ Example yml file: ...@@ -18,13 +18,13 @@ Example yml file:
# front end shutter # front end shutter
class: TangoShutter class: TangoShutter
name: frontend name: frontend
uri: //orion:10000/fe/master/id30 uri: //orion:10000/fe/master/id42
- -
# safety shutter # safety shutter
class: TangoShutter class: TangoShutter
name: safshut name: safshut
uri: id30/bsh/1 uri: id42/bsh/1
""" """
from enum import Enum from enum import Enum
...@@ -196,7 +196,14 @@ class TangoShutter(BaseShutter): ...@@ -196,7 +196,14 @@ class TangoShutter(BaseShutter):
@property @property
def mode(self): def mode(self):
""" Get the opening mode. (only for FrontEnd). """
Get or set the opening mode of the FrontEnd.
state is read from tango attribute: `automatic_mode`.
Only available for FrontEnd shutters.
Parameters:
mode: (str): 'MANUAL' or 'AUTOMATIC'
Raises: Raises:
NotImplementedError: Not a Frontend shutter NotImplementedError: Not a Frontend shutter
""" """
...@@ -212,11 +219,6 @@ class TangoShutter(BaseShutter): ...@@ -212,11 +219,6 @@ class TangoShutter(BaseShutter):
@mode.setter @mode.setter
def mode(self, mode): def mode(self, mode):
"""Set the opening mode (only for FrontEnd).
Args:
mode (str): MANUAL or AUTOMATIC
Raises: NotImplementedError: Not a Fronend shutter.
"""
if not self.frontend: if not self.frontend:
raise NotImplementedError("Not a Frontend shutter") raise NotImplementedError("Not a Frontend shutter")
...@@ -225,9 +227,12 @@ class TangoShutter(BaseShutter): ...@@ -225,9 +227,12 @@ class TangoShutter(BaseShutter):
self.__control.manual() self.__control.manual()
elif mode == "AUTOMATIC": elif mode == "AUTOMATIC":
self.__control.automatic() self.__control.automatic()
else:
raise RuntimeError(f"Unknown mode: {mode}")
self._wait_mode(mode=mode) self._wait_mode(mode=mode)
except DevFailed: except DevFailed as df_err:
raise RuntimeError(f"Cannot set {mode} opening") raise RuntimeError(f"Cannot set {mode} opening") from df_err
def reset(self): def reset(self):
"""Reset """Reset
...@@ -251,9 +256,25 @@ class TangoShutter(BaseShutter): ...@@ -251,9 +256,25 @@ class TangoShutter(BaseShutter):
self._state_changed(self.state) self._state_changed(self.state)
def _wait_mode(self, mode, timeout=3): def _wait_mode(self, mode, timeout=3):
with Timeout(timeout, RuntimeError(f"Cannot set {mode} opening")): """
Wait until set mode is equal to read mode.
"""
with Timeout(timeout, RuntimeError(f"Cannot set {mode} opening mode")):
# FE tango server feature: 'automatic_mode' goes True even
# if it's not allowed (ex: MDT)
# It switches back to False after ~1 second.
# So this method can return without error even if AUTOMATIC
# mode is not set properly.
sleep(2) # to be removed when FE tango server will be fixed.
while self.mode != mode: while self.mode != mode:
sleep(1) # print(f"{self.mode} != {mode}") # to be removed when FE tango server will be fixed.
sleep(0.2)
# for i in range(100): # to be removed when FE tango server will be fixed.
# print(f"{self.mode} =? {mode}") # to be removed when FE tango server will be fixed.
# sleep(0.05) # to be removed when FE tango server will be fixed.
def __enter__(self): def __enter__(self):
self.open() self.open()
......
...@@ -178,12 +178,6 @@ Some commands/attributes (like `automatic`/`manual`) are only implemented in the ...@@ -178,12 +178,6 @@ Some commands/attributes (like `automatic`/`manual`) are only implemented in the
front end device server, set by the `_frontend` variable. front end device server, set by the `_frontend` variable.
### FrontEnd mode
If a `TangoShutter` is a FrontEnd, a special attribute `mode` is usable.
It can be : `MANUAL` `AUTOMATIC` or `UNKNOWN`
### Usage examples ### Usage examples
Example with a safety shutter: Example with a safety shutter:
...@@ -215,38 +209,11 @@ DEMO [12]: rv9.open() ...@@ -215,38 +209,11 @@ DEMO [12]: rv9.open()
WARNING 2020-03-19 00:13:23,937 global.controllers.rv9: rv9 already open, command ignored WARNING 2020-03-19 00:13:23,937 global.controllers.rv9: rv9 already open, command ignored
``` ```
Example with a FrontEnd shutter:
```python
DEMO [3]: fe
Out [3]: State : Fault on Front End
Mode : No mode is validated!
Automatic : Automatic opening off
Type : UHV
Module 1 Gate Valve 1: Open
Module 2 Gate Valve 1: Close
Fault, pending interlocks are:
Beam permission loop was opened!
Cooling fault on module1 fixed absorber
Interlock from personal safety system
```
To change the opening mode of a `FrontEnd` shutter:
```python
DEMO [3]: fe.mode = fe.MANUAL
fe mode was AUTOMATIC and is now MANUAL
```
Example (during a shutdown):
```python
DEMO [7]: fe.mode = fe.AUTOMATIC
!!! === RuntimeError: Cannot set AUTOMATIC opening === !!!
```
### Configuration examples ### Configuration examples
Safety shutter and FrontEnd:
```yaml ```yaml
- -
name: safshut name: safshut
...@@ -261,6 +228,7 @@ DEMO [7]: fe.mode = fe.AUTOMATIC ...@@ -261,6 +228,7 @@ DEMO [7]: fe.mode = fe.AUTOMATIC
``` ```
Remote valves:
```yaml ```yaml
- -
name: rv0 name: rv0
...@@ -275,3 +243,40 @@ DEMO [7]: fe.mode = fe.AUTOMATIC ...@@ -275,3 +243,40 @@ DEMO [7]: fe.mode = fe.AUTOMATIC
class: TangoShutter class: TangoShutter
uri: id42/v-rv/2 uri: id42/v-rv/2
``` ```
### FrontEnd mode
If a `TangoShutter` is a FrontEnd, a special attribute `mode` is usable to
activate or deactivate the automatic openning mode.
It can be : `MANUAL` `AUTOMATIC` or `UNKNOWN`
Example:
```python
DEMO [3]: fe
Out [3]: State : Fault on Front End
Mode : No mode is validated!
Automatic : Automatic opening off
Type : UHV
Module 1 Gate Valve 1: Open
Module 2 Gate Valve 1: Close
Fault, pending interlocks are:
Beam permission loop was opened!
Cooling fault on module1 fixed absorber
Interlock from personal safety system
```
To change the opening mode of a `FrontEnd` shutter:
```python
DEMO [3]: fe.mode = "MANUAL"
fe mode was AUTOMATIC and is now MANUAL
```
Example (during a shutdown):
```python
DEMO [7]: fe.mode = "AUTOMATIC"
!!! === RuntimeError: Cannot set AUTOMATIC 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