Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tickets/dm 47890: Support Summit Observing Weeks 49-50 of 2024 #187

Merged
merged 5 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/news/DM-47890.feature.2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In maintel/mtcs.py, remove settling time after clearing slew flag (currently refered to as close booster valve in the code).
1 change: 1 addition & 0 deletions doc/news/DM-47890.feature.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In maintel/mtcs.py, add a context manager to ensure m1m3 is in engineering mode before/after some operation and add unit tests.
17 changes: 16 additions & 1 deletion python/lsst/ts/observatory/control/maintel/mtcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,22 @@ async def exit_m1m3_engineering_mode(self) -> None:
else:
self.log.warning("M1M3 not in engineering mode.")

@contextlib.asynccontextmanager
async def m1m3_in_engineering_mode(self) -> typing.AsyncIterator[None]:
"""Context manager to ensure m1m3 enters and exists engineering
mode before/after an operation.

If M1M3 is in engineering mode before, this context manager is a
nop, e.g. it will leave M1M3 in engineering mode afterwards.
"""
try:
m1m3_in_engineering_mode_before = await self.is_m1m3_in_engineering_mode()
await self.enter_m1m3_engineering_mode()
yield
finally:
if not m1m3_in_engineering_mode_before:
await self.exit_m1m3_engineering_mode()

async def run_m1m3_hard_point_test(self, hp: int) -> None:
"""Test an M1M3 hard point.

Expand Down Expand Up @@ -2628,7 +2644,6 @@ async def close_m1m3_booster_valve(self) -> None:
"""Close M1M3 booster valves."""
if self.check.mtm1m3:
await self._handle_m1m3_booster_valve(open=False)
await asyncio.sleep(self.fast_timeout)

async def _handle_m1m3_booster_valve(self, open: bool) -> None:
"""Handle opening the M1M3 booster valves"""
Expand Down
19 changes: 19 additions & 0 deletions tests/maintel/test_mtcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2455,3 +2455,22 @@ async def assert_m1m3_slew_settings_applied(
assert (
actual_settings[setting] == expected_value
), f"Setting {setting} expected to be {expected_value} but was {actual_settings[setting]}"

async def test_m1m3_in_engineering_mode(self) -> None:

async with self.mtcs.m1m3_in_engineering_mode():
await asyncio.sleep(0)

self.mtcs.rem.mtm1m3.cmd_enterEngineering.start.assert_awaited_once()
self.mtcs.rem.mtm1m3.cmd_exitEngineering.start.assert_awaited_once()

async def test_m1m3_in_engineering_mode_with_failed_op(self) -> None:

try:
async with self.mtcs.m1m3_in_engineering_mode():
raise RuntimeError("This is a test.")
except RuntimeError:
pass

self.mtcs.rem.mtm1m3.cmd_enterEngineering.start.assert_awaited_once()
self.mtcs.rem.mtm1m3.cmd_exitEngineering.start.assert_awaited_once()
Loading