From 2e1aa6a0c4b6e8e2fb4d1c5c86557084e2dcd988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20S=C3=A1nchez-Gallego?= Date: Wed, 25 Dec 2024 10:54:05 -0800 Subject: [PATCH] Do not close dome during daytime if already closed --- CHANGELOG.md | 4 ++++ python/lvmecp/actor/actor.py | 6 +++++- tests/test_command_dome.py | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1058b1..61fbecb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ * Bump `CLU` to 2.4.3. +### 🔧 Fixed + +* Do not command the dome to close during daytime if it is already closed. + ## 1.0.0 - December 25, 2024 diff --git a/python/lvmecp/actor/actor.py b/python/lvmecp/actor/actor.py index 71d0c16..efbd4c3 100644 --- a/python/lvmecp/actor/actor.py +++ b/python/lvmecp/actor/actor.py @@ -21,6 +21,7 @@ from lvmecp import __version__, log from lvmecp.actor.commands import parser from lvmecp.exceptions import ECPWarning +from lvmecp.maskbits import DomeStatus from lvmecp.plc import PLC @@ -113,9 +114,12 @@ async def monitor_dome(self, delay: float = 30.0): while True: await asyncio.sleep(delay) + closing_flags = DomeStatus.MOTOR_CLOSING | DomeStatus.CLOSED + is_closing = self.plc.dome.status and (self.plc.dome.status & closing_flags) + if self._engineering_mode: pass - elif self.plc.dome.is_daytime(): + elif self.plc.dome.is_daytime() and not is_closing: self.write("w", text="Dome found open during daytime. Closing.") await send_notification( "Dome found open during daytime. Closing.", diff --git a/tests/test_command_dome.py b/tests/test_command_dome.py index 2a785f7..7d74211 100644 --- a/tests/test_command_dome.py +++ b/tests/test_command_dome.py @@ -108,6 +108,21 @@ async def test_actor_daytime_task(actor: ECPActor, mocker: MockerFixture): task.cancel() +async def test_actor_daytime_task_closed(actor: ECPActor, mocker: MockerFixture): + mocker.patch.object(actor.plc.dome, "is_daytime", return_value=True) + mocker.patch.object(actor.plc.dome, "status", return_value=DomeStatus.CLOSED) + mocker.patch.object(lvmecp.actor.actor, "send_notification") + + dome_close_mock = mocker.patch.object(actor.plc.dome, "close") + + task = asyncio.create_task(actor.monitor_dome(delay=0.1)) + await asyncio.sleep(0.2) + + dome_close_mock.assert_not_called() + + task.cancel() + + async def test_actor_daytime_task_eng_mode(actor: ECPActor, mocker: MockerFixture): mocker.patch.object(actor.plc.dome, "is_daytime", return_value=True) mocker.patch.object(actor, "_engineering_mode", return_value=True)