Skip to content

Commit

Permalink
Make API queue names distinct
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Jan 15, 2025
1 parent a447564 commit fbd7b14
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions src/isar/models/communication/queues/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/isar/services/utilities/scheduling_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions src/isar/state_machine/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,19 +308,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

Expand Down Expand Up @@ -350,7 +350,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

Expand Down Expand Up @@ -469,7 +469,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",
Expand Down
2 changes: 1 addition & 1 deletion src/isar/state_machine/transitions/pause.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/isar/state_machine/transitions/resume.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/isar/state_machine/transitions/start_mission.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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()
2 changes: 1 addition & 1 deletion src/isar/state_machine/transitions/stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
20 changes: 10 additions & 10 deletions tests/isar/models/communication/test_queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)


Expand Down

0 comments on commit fbd7b14

Please sign in to comment.