diff --git a/python/lsst/ts/observatory/control/maintel/mtcs.py b/python/lsst/ts/observatory/control/maintel/mtcs.py index 434022b5..33dac535 100644 --- a/python/lsst/ts/observatory/control/maintel/mtcs.py +++ b/python/lsst/ts/observatory/control/maintel/mtcs.py @@ -141,7 +141,6 @@ def __init__( self.dome_flat_az = 20.0 self.dome_flat_el = self.dome_park_el self.dome_slew_tolerance = Angle(1.5 * u.deg) - self.home_dome_az = 328.0 # TODO (DM-45609): This is an initial guess for the time it takes the # dome to park. It might need updating. @@ -845,42 +844,9 @@ async def close_m1_cover(self) -> None: f"{MTMount.DeployableMotionState.DEPLOYED!r}" ) - async def home_dome(self, physical_az: float = 0.0) -> None: - """Utility method to home dome. - - Parameters - ---------- - physical_az : `float` - Azimuth angle of the dome as read by markings (in deg). - - """ - self.log.info("Homing dome") - reported_az = await self.rem.mtdome.tel_azimuth.aget(timeout=self.fast_timeout) - - offset = physical_az - reported_az.positionActual - self.log.debug(f"Dome azimuth offset: {offset} degrees") - target_az = self.home_dome_az - offset - await self.slew_dome_to(target_az) - - self.rem.mtdome.evt_azMotion.flush() - - await self.rem.mtdome.cmd_stop.set_start( - engageBrakes=True, - subSystemIds=MTDome.SubSystemId.AMCS, - timeout=self.long_long_timeout, - ) - motion_state = await self.rem.mtdome.evt_azMotion.aget( - timeout=self.fast_timeout - ) - while motion_state.state != MTDome.MotionState.STOPPED_BRAKED: - motion_state = await self.rem.mtdome.evt_azMotion.next( - flush=False, timeout=self.long_long_timeout - ) - self.log.debug(f"Motion state: {MTDome.MotionState(motion_state.state)!r}") - - await self.rem.mtdome.cmd_setZeroAz.start(timeout=self.fast_timeout) - azimuth = await self.rem.mtdome.tel_azimuth.aget(timeout=self.fast_timeout) - self.log.debug(f"{azimuth.positionActual=}, {azimuth.positionCommanded=}") + async def home_dome(self) -> None: + # TODO: Implement (DM-21336). + raise NotImplementedError("# TODO: Implement (DM-21336).") async def open_dome_shutter(self) -> None: # TODO: Implement (DM-21336). @@ -989,6 +955,38 @@ async def in_m1_cover_operational_range(self) -> bool: return elevation.actualPosition >= self.tel_operate_mirror_covers_el + async def park_mount(self, position: MTMount.ParkPosition) -> None: + """Park the TMA in the selected position. + + Parameters + ---------- + position : `MTMount.ParkPosition` + The position to park the TMA. + """ + + await self.assert_all_enabled( + message="All components need to be enabled for parking the TMA." + ) + + # check first if Mount is already in PARKED state (?) + # to implement + + await self.rem.mtmount.cmd_park.start( + position=position, timeout=self.long_timeout + ) + + async def unpark_mount(self) -> None: + """Un-park the TMA.""" + + await self.assert_all_enabled( + message="All components need to be enabled for unparking the TMA." + ) + + # check first if Mount is PARKED state (?) + # to implement + + await self.rem.mtmount.cmd_unpark.start(timeout=self.long_timeout) + async def prepare_for_flatfield(self, check: typing.Any = None) -> None: # TODO: Implement (DM-21336). raise NotImplementedError("# TODO: Implement (DM-21336).") diff --git a/tests/maintel/test_mtcs.py b/tests/maintel/test_mtcs.py index 1b6face1..1da8c1f3 100644 --- a/tests/maintel/test_mtcs.py +++ b/tests/maintel/test_mtcs.py @@ -840,6 +840,36 @@ async def test_not_in_m1_cover_operational_range(self) -> None: assert not elevation_in_range + async def test_park_mount_zenith(self) -> None: + await self.mtcs.enable() + await self.mtcs.assert_all_enabled() + + await self.mtcs.park_mount(MTMount.ParkPosition.ZENITH) + + self.mtcs.rem.mtmount.cmd_park.start.assert_awaited_with( + position=MTMount.ParkPosition.ZENITH, timeout=self.mtcs.long_timeout + ) + + async def test_park_mount_horizon(self) -> None: + await self.mtcs.enable() + await self.mtcs.assert_all_enabled() + + await self.mtcs.park_mount(MTMount.ParkPosition.HORIZON) + + self.mtcs.rem.mtmount.cmd_park.start.assert_awaited_with( + position=MTMount.ParkPosition.HORIZON, timeout=self.mtcs.long_timeout + ) + + async def test_unpark_mount(self) -> None: + await self.mtcs.enable() + await self.mtcs.assert_all_enabled() + + await self.mtcs.unpark_mount() + + self.mtcs.rem.mtmount.cmd_unpark.start.assert_awaited_with( + timeout=self.mtcs.long_timeout + ) + async def test_slew_to_m1_cover_operational_range(self) -> None: self._mtmount_tel_azimuth.actualPosition = 0.0 self._mtmount_tel_elevation.actualPosition = (