Skip to content

Commit

Permalink
Merge pull request #187 from lsst-ts/tickets/DM-47890
Browse files Browse the repository at this point in the history
  • Loading branch information
edennihy authored Dec 19, 2024
2 parents 9bcef43 + c439a52 commit 4f347a4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
- name: Install
run: |
$CONDA/bin/conda config --set solver classic
$CONDA/bin/conda install -c lsstts -c conda-forge pre-commit ts-pre-commit-config python=3.11 -y
$CONDA/bin/conda install -c conda-forge pre-commit -y
$CONDA/bin/conda install -c lsstts -c conda-forge pre-commit ts-pre-commit-config python=3.11 identify>=2.6 -y
$CONDA/bin/conda install -c conda-forge pre-commit identify>=2.6 -y
$CONDA/bin/generate_pre_commit_conf --skip-pre-commit-install
- name: Run pre commit checks
Expand Down
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()

0 comments on commit 4f347a4

Please sign in to comment.