From 249593feb8491abe05627c2f6b9ed9ca3d88bb63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Chirico=20Indreb=C3=B8?= Date: Tue, 14 Jan 2025 15:08:38 +0100 Subject: [PATCH] Make API queue names distinct --- .../models/communication/queues/queues.py | 8 ++++---- .../utilities/scheduling_utilities.py | 8 ++++---- src/isar/state_machine/state_machine.py | 10 +++++----- src/isar/state_machine/transitions/pause.py | 2 +- src/isar/state_machine/transitions/resume.py | 2 +- .../transitions/start_mission.py | 4 ++-- src/isar/state_machine/transitions/stop.py | 2 +- .../isar/models/communication/test_queues.py | 20 +++++++++---------- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/isar/models/communication/queues/queues.py b/src/isar/models/communication/queues/queues.py index 54f49086..9e0c0366 100644 --- a/src/isar/models/communication/queues/queues.py +++ b/src/isar/models/communication/queues/queues.py @@ -7,10 +7,10 @@ class Queues: def __init__(self) -> None: - self.start_mission: QueueIO = QueueIO(input_size=1, output_size=1) - self.stop_mission: QueueIO = QueueIO(input_size=1, output_size=1) - self.pause_mission: QueueIO = QueueIO(input_size=1, output_size=1) - self.resume_mission: QueueIO = QueueIO(input_size=1, output_size=1) + self.api_start_mission: QueueIO = QueueIO(input_size=1, output_size=1) + self.api_stop_mission: QueueIO = QueueIO(input_size=1, output_size=1) + self.api_pause_mission: QueueIO = QueueIO(input_size=1, output_size=1) + self.api_resume_mission: QueueIO = QueueIO(input_size=1, output_size=1) self.state_machine_start_mission: QueueIO = QueueIO(input_size=1, output_size=1) self.state_machine_stop_mission: QueueIO = QueueIO(input_size=1, output_size=1) diff --git a/src/isar/services/utilities/scheduling_utilities.py b/src/isar/services/utilities/scheduling_utilities.py index ede9692c..44d31941 100644 --- a/src/isar/services/utilities/scheduling_utilities.py +++ b/src/isar/services/utilities/scheduling_utilities.py @@ -156,7 +156,7 @@ def start_mission( mission=deepcopy(mission), initial_pose=initial_pose, ), - self.queues.start_mission, + self.queues.api_start_mission, ) except QueueTimeoutError: error_message = "Internal Server Error - Failed to start mission in ISAR" @@ -175,7 +175,7 @@ def pause_mission(self) -> ControlMissionResponse: If there is a timeout while communicating with the state machine """ try: - return self._send_command(True, self.queues.pause_mission) + return self._send_command(True, self.queues.api_pause_mission) except QueueTimeoutError: error_message = "Internal Server Error - Failed to pause mission" self.logger.error(error_message) @@ -194,7 +194,7 @@ def resume_mission(self) -> ControlMissionResponse: If there is a timeout while communicating with the state machine """ try: - return self._send_command(True, self.queues.resume_mission) + return self._send_command(True, self.queues.api_resume_mission) except QueueTimeoutError: error_message = "Internal Server Error - Failed to resume mission" self.logger.error(error_message) @@ -214,7 +214,7 @@ def stop_mission(self) -> ControlMissionResponse: """ try: stop_mission_response: ControlMissionResponse = self._send_command( - True, self.queues.stop_mission + True, self.queues.api_stop_mission ) except QueueTimeoutError: error_message = "Internal Server Error - Failed to stop mission" diff --git a/src/isar/state_machine/state_machine.py b/src/isar/state_machine/state_machine.py index 72d7114f..73d8f37d 100644 --- a/src/isar/state_machine/state_machine.py +++ b/src/isar/state_machine/state_machine.py @@ -321,19 +321,19 @@ def get_initialize_params(self): def should_start_mission(self) -> Optional[StartMissionMessage]: try: - return self.queues.start_mission.input.get(block=False) + return self.queues.api_start_mission.input.get(block=False) except queue.Empty: return None def should_stop_mission(self) -> bool: try: - return self.queues.stop_mission.input.get(block=False) + return self.queues.api_stop_mission.input.get(block=False) except queue.Empty: return False def should_pause_mission(self) -> bool: try: - return self.queues.pause_mission.input.get(block=False) + return self.queues.api_pause_mission.input.get(block=False) except queue.Empty: return False @@ -363,7 +363,7 @@ def get_task_failure(self) -> Optional[ErrorMessage]: def should_resume_mission(self) -> bool: try: - return self.queues.resume_mission.input.get(block=False) + return self.queues.api_resume_mission.input.get(block=False) except queue.Empty: return False @@ -484,7 +484,7 @@ def _make_control_mission_response(self) -> ControlMissionResponse: ) def _queue_empty_response(self): - self.queues.stop_mission.output.put( + self.queues.api_stop_mission.output.put( ControlMissionResponse( mission_id="None", mission_status="None", diff --git a/src/isar/state_machine/transitions/pause.py b/src/isar/state_machine/transitions/pause.py index 347b736e..1bf04666 100644 --- a/src/isar/state_machine/transitions/pause.py +++ b/src/isar/state_machine/transitions/pause.py @@ -15,7 +15,7 @@ def pause_mission(state_machine: "StateMachine") -> bool: paused_mission_response: ControlMissionResponse = ( state_machine._make_control_mission_response() ) - state_machine.queues.pause_mission.output.put(paused_mission_response) + state_machine.queues.api_pause_mission.output.put(paused_mission_response) state_machine.publish_mission_status() state_machine.publish_task_status(task=state_machine.current_task) diff --git a/src/isar/state_machine/transitions/resume.py b/src/isar/state_machine/transitions/resume.py index 1b5bdd46..5e7f670b 100644 --- a/src/isar/state_machine/transitions/resume.py +++ b/src/isar/state_machine/transitions/resume.py @@ -19,7 +19,7 @@ def resume_mission(state_machine: "StateMachine") -> bool: resume_mission_response: ControlMissionResponse = ( state_machine._make_control_mission_response() ) - state_machine.queues.resume_mission.output.put(resume_mission_response) + state_machine.queues.api_resume_mission.output.put(resume_mission_response) state_machine.robot.resume() return True diff --git a/src/isar/state_machine/transitions/start_mission.py b/src/isar/state_machine/transitions/start_mission.py index 47a59392..45b04e25 100644 --- a/src/isar/state_machine/transitions/start_mission.py +++ b/src/isar/state_machine/transitions/start_mission.py @@ -14,7 +14,7 @@ def put_start_mission_on_queue(state_machine: "StateMachine") -> bool: - state_machine.queues.start_mission.output.put(True) + state_machine.queues.api_start_mission.output.put(True) return True @@ -78,5 +78,5 @@ def trigger_start_mission_or_task_event(state_machine: "StateMachine") -> bool: def _initialization_failed(state_machine: "StateMachine") -> None: - state_machine.queues.start_mission.output.put(False) + state_machine.queues.api_start_mission.output.put(False) state_machine._finalize() diff --git a/src/isar/state_machine/transitions/stop.py b/src/isar/state_machine/transitions/stop.py index 8bbf043e..ed229c44 100644 --- a/src/isar/state_machine/transitions/stop.py +++ b/src/isar/state_machine/transitions/stop.py @@ -31,7 +31,7 @@ def stop_mission(state_machine: "StateMachine") -> bool: stopped_mission_response: ControlMissionResponse = ( state_machine._make_control_mission_response() ) - state_machine.queues.stop_mission.output.put(stopped_mission_response) + state_machine.queues.api_stop_mission.output.put(stopped_mission_response) state_machine.publish_task_status(task=state_machine.current_task) state_machine._finalize() diff --git a/tests/isar/models/communication/test_queues.py b/tests/isar/models/communication/test_queues.py index 02edcafa..337705df 100644 --- a/tests/isar/models/communication/test_queues.py +++ b/tests/isar/models/communication/test_queues.py @@ -8,23 +8,23 @@ class TestQueues: def test_queues(self) -> None: queues = Queues() - assert queues.start_mission is not None + assert queues.api_start_mission is not None assert ( - queues.start_mission.input is not None - and queues.start_mission.input.maxsize == 1 + queues.api_start_mission.input is not None + and queues.api_start_mission.input.maxsize == 1 ) assert ( - queues.start_mission.output is not None - and queues.start_mission.output.maxsize == 1 + queues.api_start_mission.output is not None + and queues.api_start_mission.output.maxsize == 1 ) - assert queues.stop_mission is not None + assert queues.api_stop_mission is not None assert ( - queues.stop_mission.input is not None - and queues.stop_mission.input.maxsize == 1 + queues.api_stop_mission.input is not None + and queues.api_stop_mission.input.maxsize == 1 ) assert ( - queues.stop_mission.output is not None - and queues.stop_mission.output.maxsize == 1 + queues.api_stop_mission.output is not None + and queues.api_stop_mission.output.maxsize == 1 )