From e4529f3f23916706b02ea03fffd9e49a924f6fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20S=C3=A1nchez-Gallego?= Date: Sun, 23 Jul 2023 17:53:01 +0000 Subject: [PATCH] Park telescopes before operating the enclosure --- CHANGELOG.md | 1 + src/gort/devices/enclosure.py | 42 +++++++++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11a8127..b0c7cf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Prevent multiple devices reconnecting to RabbitMQ at the same time. * Set the `OBJECT` header keyword in spectrograph exposures. * Telescopes keep track of whether they have been homed. +* Telescopes will move to park automatically when trying to open or close the dome. ### 🔧 Fixed diff --git a/src/gort/devices/enclosure.py b/src/gort/devices/enclosure.py index b3e8fac..0cde8e9 100644 --- a/src/gort/devices/enclosure.py +++ b/src/gort/devices/enclosure.py @@ -35,15 +35,49 @@ async def status(self): return reply.flatten() - async def open(self): - """Open the enclosure dome.""" + async def _prepare_telescopes(self): + """Moves telescopes to park position before opening/closing the enclosure.""" + + self.write_to_log( + "Moving telescopes to park before operating the dome.", + "warning", + ) + await self.gort.telescopes.goto_named_position("park") + + async def open(self, park_telescopes: bool = True): + """Open the enclosure dome. + + Parameters + ---------- + park_telescopes + Move the telescopes to the park position before opening the + enclosure to prevent dust or other debris falling on them. + + """ + + if park_telescopes: + await self._prepare_telescopes() self.write_to_log("Opening the enclosure ...", level="info") await self.actor.commands.dome.commands.open() self.write_to_log("Enclosure is now open.", level="info") - async def close(self, force: bool = False): - """Close the enclosure dome.""" + async def close(self, park_telescopes: bool = True, force: bool = False): + """Close the enclosure dome. + + Parameters + ---------- + park_telescopes + Move the telescopes to the park position before closing the + enclosure to prevent dust or other debris falling on them. + force + Tries to closes the dome even if the system believes it is + already closed. + + """ + + if park_telescopes: + await self._prepare_telescopes() self.write_to_log("Closing the enclosure ...", level="info") await self.actor.commands.dome.commands.close(force=force)