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

DM-48023: Offset script shall enable and then disable M1M3 slew flag. #186

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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-48023.feature.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated ``MTCS`` to implement ``ready_to_offset``, which uses the ``m1m3_booster_valve`` context manager to enable/disable slew flag before/after offseting.
4 changes: 4 additions & 0 deletions doc/news/DM-48023.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Updated ``BaseTCS`` to introduce a mechanism to execute code to prepare the telescope for offsetting.

This consist of having an async context manager that is used when calling the offset command.
By default this context manager does nothing.
12 changes: 11 additions & 1 deletion python/lsst/ts/observatory/control/base_tcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import abc
import asyncio
import contextlib
import enum
import logging
import typing
Expand Down Expand Up @@ -1367,7 +1368,8 @@ async def _offset(
"""
self.flush_offset_events()

await offset_cmd
async with self.ready_to_offset():
await offset_cmd

try:
await self.offset_done()
Expand All @@ -1379,6 +1381,14 @@ async def _offset(
await asyncio.sleep(self.tel_settle_time)
self.log.debug("Done")

@contextlib.asynccontextmanager
async def ready_to_offset(self) -> typing.AsyncIterator[None]:
"""A context manager to handle preparing the telescope for offset.

By default it does nothing.
"""
yield

async def ready_to_take_data(self) -> None:
"""Wait for the telescope control system to be ready to take data."""
if (
Expand Down
10 changes: 10 additions & 0 deletions python/lsst/ts/observatory/control/maintel/mtcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2721,6 +2721,16 @@ async def m1m3_booster_valve(self) -> typing.AsyncIterator[None]:
await self.wait_m1m3_settle()
await self.close_m1m3_booster_valve()

@contextlib.asynccontextmanager
async def ready_to_offset(self) -> typing.AsyncIterator[None]:
"""Make sure telescope is ready to perform an offset.

Overrides the parent class to implement setting/unsetting
the slew flag on m1m3.
"""
async with self.m1m3_booster_valve():
yield

async def wait_m1m3_settle(self) -> None:
"""Wait until m1m3 has settle."""
# For now this method will only sleep for m1m3_settle_time.
Expand Down
20 changes: 20 additions & 0 deletions tests/maintel/test_mtcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,13 @@ async def test_offset_radec(self) -> None:
type=1, off1=ra_offset, off2=dec_offset, num=0
)

self.mtcs.rem.mtm1m3.cmd_setSlewFlag.set_start.assert_awaited_with(
timeout=self.mtcs.fast_timeout,
)
self.mtcs.rem.mtm1m3.cmd_clearSlewFlag.set_start.assert_awaited_with(
timeout=self.mtcs.fast_timeout,
)

async def test_offset_azel(self) -> None:
az_offset, el_offset = 10.0, -10.0

Expand All @@ -567,6 +574,12 @@ async def test_offset_azel(self) -> None:
self.mtcs.rem.mtptg.cmd_offsetAzEl.set_start.assert_called_with(
az=az_offset, el=el_offset, num=1
)
self.mtcs.rem.mtm1m3.cmd_setSlewFlag.set_start.assert_awaited_with(
timeout=self.mtcs.fast_timeout,
)
self.mtcs.rem.mtm1m3.cmd_clearSlewFlag.set_start.assert_awaited_with(
timeout=self.mtcs.fast_timeout,
)

async def test_offset_azel_with_defaults(self) -> None:
az_offset, el_offset = 10.0, -10.0
Expand Down Expand Up @@ -701,6 +714,13 @@ async def test_offset_xy(self) -> None:
az=az, el=el, num=1
)

self.mtcs.rem.mtm1m3.cmd_setSlewFlag.set_start.assert_awaited_with(
timeout=self.mtcs.fast_timeout,
)
self.mtcs.rem.mtm1m3.cmd_clearSlewFlag.set_start.assert_awaited_with(
timeout=self.mtcs.fast_timeout,
)

async def test_offset_xy_with_defaults(self) -> None:
x_offset, y_offset = 10.0, -10.0

Expand Down
Loading