async def assert_dome_az(self, azimuth, move_expected): """Check the ATDome and ATDomeController commanded azimuth. Parameters ---------- expected_azimuth : `float` Expected new azimuth position (deg); ignored if ``move_expected`` false. move_expected : `bool` Is a move expected? Notes ----- If ``move_expected`` then read the next ``azimuthCommandedState`` ATDome event. Otherwise try to read the next event and expect it to time out. """ if move_expected: az_cmd_state = await self.assert_next_sample( self.dome_remote.evt_azimuthCommandedState, commandedState=AzimuthCommandedState.GOTOPOSITION, ) utils.assert_angles_almost_equal(az_cmd_state.azimuth, azimuth) else: with self.assertRaises(asyncio.TimeoutError): await self.dome_remote.evt_azimuthCommandedState.next( flush=False, timeout=NODATA_TIMEOUT)
async def assert_dome_azimuth(self, expected_azimuth, move_expected): """Check the Dome and MTDomeController commanded azimuth. Parameters ---------- expected_azimuth : `float` Expected new azimuth position (deg); ignored if ``move_expected`` false. move_expected : `bool` Is a move expected? Notes ----- If ``move_expected`` then read the next ``azTarget`` MTDome event. Otherwise try to read the next event and expect it to time out. """ if move_expected: dome_azimuth_target = await self.dome_remote.evt_azTarget.next( flush=False, timeout=STD_TIMEOUT) utils.assert_angles_almost_equal(dome_azimuth_target.position, expected_azimuth) else: with pytest.raises(asyncio.TimeoutError): await self.dome_remote.evt_azTarget.next( flush=False, timeout=NODATA_TIMEOUT)
async def test_move_azimuth(self): """Test issuing moveAzimuth commands to ATDome.""" async with self.make_csc(initial_state=salobj.State.ENABLED): await self.assert_next_summary_state(salobj.State.ENABLED) await self.assert_next_sample( self.remote.evt_azimuthCommandedState, commandedState=AzimuthCommandedState.UNKNOWN, ) position = await self.remote.tel_position.next( flush=True, timeout=STD_TIMEOUT ) utils.assert_angles_almost_equal(position.azimuthPosition, 0) for az in (3, -1): predicted_duration = ( abs(az - position.azimuthPosition) / self.csc.az_vel ) start_time = time.time() # be conservative about the end time predicted_end_time = start_time + predicted_duration safe_done_end_time = ( predicted_end_time + self.csc.telemetry_interval * 2 ) await self.remote.cmd_moveAzimuth.set_start( azimuth=az, timeout=STD_TIMEOUT ) az_cmd_state = await self.assert_next_sample( self.remote.evt_azimuthCommandedState, commandedState=AzimuthCommandedState.GOTOPOSITION, ) utils.assert_angles_almost_equal(az_cmd_state.azimuth, az) isfirst = True while True: position = await self.remote.tel_position.next( flush=True, timeout=STD_TIMEOUT ) if isfirst: isfirst = False with self.assertRaises(AssertionError): utils.assert_angles_almost_equal( position.azimuthPosition, az ) elif time.time() > safe_done_end_time: utils.assert_angles_almost_equal(position.azimuthPosition, az) break await asyncio.sleep(self.csc.telemetry_interval)
async def assert_dome_elevation(self, expected_elevation, move_expected): """Check the Dome and MTDomeController commanded elevation. Parameters ---------- expected_elevation : `float` Expected new elevation position (deg); ignored if ``move_expected`` false. move_expected : `bool` Is a move expected? Notes ----- If ``move_expected`` then read one ``elTarget`` Dome event. """ if move_expected: dome_elevation_target = await self.dome_remote.evt_elTarget.next( flush=False, timeout=STD_TIMEOUT) utils.assert_angles_almost_equal(dome_elevation_target.position, expected_elevation) else: with pytest.raises(asyncio.TimeoutError): await self.dome_remote.evt_elTarget.next( flush=False, timeout=NODATA_TIMEOUT)
def assert_telescope_target(self, elevation, azimuth): utils.assert_angles_almost_equal( self.csc.telescope_target.azimuth.position, azimuth) utils.assert_angles_almost_equal( self.csc.telescope_target.elevation.position, elevation)