Skip to content

Commit

Permalink
Do not close dome during daytime if already closed
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Dec 25, 2024
1 parent 8f5c912 commit 2e1aa6a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion python/lvmecp/actor/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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.",
Expand Down
15 changes: 15 additions & 0 deletions tests/test_command_dome.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2e1aa6a

Please sign in to comment.