diff --git a/python/lsst/ts/observatory/control/maintel/mtcalsys.py b/python/lsst/ts/observatory/control/maintel/mtcalsys.py index 144b1e5d..1046eaf1 100644 --- a/python/lsst/ts/observatory/control/maintel/mtcalsys.py +++ b/python/lsst/ts/observatory/control/maintel/mtcalsys.py @@ -272,12 +272,12 @@ async def change_laser_optical_configuration( ---------- optical_configuration : LaserOpticalConfiguration """ - assert optical_configuration in LaserOpticalConfiguration + assert optical_configuration in list(LaserOpticalConfiguration) current_configuration = ( - await self.rem.tunablelaser.evt_opticalConfiguration.aget().configuration + await self.rem.tunablelaser.evt_opticalConfiguration.aget() ) - if current_configuration != optical_configuration: + if current_configuration.configuration != optical_configuration: self.log.debug( f"Changing optical configuration from {current_configuration} to {optical_configuration}" ) @@ -361,11 +361,12 @@ async def get_laser_parameters(self) -> tuple: async def laser_start_propagate(self) -> None: """Start the propagation of the Tunable Laser""" - laser_state = self.rem.tunablelaser.evt_detailedState.next( + laser_state = await self.rem.tunablelaser.evt_detailedState.next( flush=True, timeout=self.long_timeout ) + self.log.debug(f"HERE: {laser_state.DetailedState}") - while laser_state.DetailedState not in { + if laser_state.DetailedState not in { LaserDetailedState.PROPAGATING_CONTINUOUS_MODE, LaserDetailedState.PROPAGATING_BURST_MODE, }: @@ -373,7 +374,7 @@ async def laser_start_propagate(self) -> None: await self.rem.tunablelaser.cmd_startPropagateLaser.start( timeout=self.laser_warmup ) - laser_state = self.rem.tunablelaser.evt_detailedState.next( + laser_state = await self.rem.tunablelaser.evt_detailedState.next( flush=True, timeout=self.long_timeout ) self.log.info(f"Laser state: {laser_state.DetailedState}") @@ -385,11 +386,11 @@ async def laser_start_propagate(self) -> None: async def laser_stop_propagate(self) -> None: """Stop the propagation of the Tunable Laser""" - laser_state = self.rem.tunablelaser.evt_detailedState.next( + laser_state = await self.rem.tunablelaser.evt_detailedState.next( flush=True, timeout=self.long_timeout ) - while laser_state.DetailedState not in { + if laser_state.DetailedState not in { LaserDetailedState.NONPROPAGATING_CONTINUOUS_MODE, LaserDetailedState.NONPROPAGATING_BURST_MODE, }: @@ -397,7 +398,7 @@ async def laser_stop_propagate(self) -> None: await self.rem.tunablelaser.cmd_stopPropagateLaser.start( timeout=self.laser_warmup ) - laser_state = self.rem.tunablelaser.evt_detailedState.next( + laser_state = await self.rem.tunablelaser.evt_detailedState.next( flush=True, timeout=self.long_timeout ) self.log.info(f"Laser state: {laser_state.DetailedState}") diff --git a/tests/maintel/test_mtcalsys.py b/tests/maintel/test_mtcalsys.py index c5447550..fdabcd87 100644 --- a/tests/maintel/test_mtcalsys.py +++ b/tests/maintel/test_mtcalsys.py @@ -28,7 +28,6 @@ from lsst.ts.observatory.control.maintel.mtcalsys import MTCalsys, MTCalsysUsages from lsst.ts.observatory.control.mock import RemoteGroupAsyncMock from lsst.ts.utils import index_generator -from lsst.ts.xml.enums.TunableLaser import LaserDetailedState class TestMTCalsys(RemoteGroupAsyncMock): @@ -49,6 +48,7 @@ async def setup_mocks(self) -> None: "evt_largeFileObjectAvailable.next.side_effect": self.mock_fiberspectrograph_lfoa } ) + self.mtcalsys.rem.tunablelaser.configure_mock() async def setup_types(self) -> None: pass @@ -120,7 +120,7 @@ async def test_setup_laser(self) -> None: mode=config_data["laser_mode"], wavelength=config_data["wavelength"], optical_configuration=config_data["optical_configuration"], - use_projector=config_data["false"], + use_projector=False, ) self.mtcalsys.rem.tunablelaser.cmd_setOpticalConfiguration.set_start.assert_awaited_with( @@ -128,11 +128,6 @@ async def test_setup_laser(self) -> None: timeout=self.mtcalsys.long_timeout, ) - assert ( - self.mtcalsys.rem.tunablelaser.evt_opticalConfiguration.aget().configuration - == config_data["optical_configuration"] - ) - async def test_laser_start_propagation(self) -> None: await self.mtcalsys.laser_start_propagate() @@ -140,12 +135,6 @@ async def test_laser_start_propagation(self) -> None: timeout=self.mtcalsys.laser_warmup ) - laser_state = self.mtcalsys.rem.tunablelaser.evt_detailedState.next() - assert laser_state.DetailedState in { - LaserDetailedState.PROPAGATING_CONTINUOUS_MODE, - LaserDetailedState.PROPAGATING_BURST_MODE, - } - async def test_laser_stop_propagation(self) -> None: await self.mtcalsys.laser_stop_propagate() @@ -153,12 +142,6 @@ async def test_laser_stop_propagation(self) -> None: timeout=self.mtcalsys.laser_warmup ) - laser_state = self.mtcalsys.rem.tunablelaser.evt_detailedState.next() - assert laser_state.DetailedState in { - LaserDetailedState.NONPROPAGATING_CONTINUOUS_MODE, - LaserDetailedState.NONPROPAGATING_BURST_MODE, - } - async def test_prepare_for_whitelight_flat(self) -> None: mock_comcam = ComCam( "FakeDomain", log=self.log, intended_usage=ComCamUsages.DryTest