Skip to content

Commit

Permalink
updates from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
parfa30 committed Oct 30, 2024
1 parent 5ce2e7d commit 90f8ef8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
19 changes: 10 additions & 9 deletions python/lsst/ts/observatory/control/maintel/mtcalsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)
Expand Down Expand Up @@ -361,19 +361,20 @@ 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,
}:
try:
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}")
Expand All @@ -385,19 +386,19 @@ 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,
}:
try:
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}")
Expand Down
21 changes: 2 additions & 19 deletions tests/maintel/test_mtcalsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -120,45 +120,28 @@ 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(
configuration=config_data["optical_configuration"],
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()

self.mtcalsys.rem.tunablelaser.cmd_startPropagateLaser.start.assert_awaited_with(
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()

self.mtcalsys.rem.tunablelaser.cmd_stopPropagateLaser.start.assert_awaited_with(
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
Expand Down

0 comments on commit 90f8ef8

Please sign in to comment.