Skip to content

Commit

Permalink
Improve handling of single step tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Apr 18, 2024
1 parent f3dd2a8 commit 1a13f22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/isar/state_machine/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ def _mission_finished(self) -> None:
]
partially_fail_statuses = fail_statuses + [TaskStatus.PartiallySuccessful]

if all(task.status in fail_statuses for task in self.current_mission.tasks):
if len(self.current_mission.tasks) == 0:
self.current_mission.status = MissionStatus.Successful
elif all(task.status in fail_statuses for task in self.current_mission.tasks):
self.current_mission.error_message = ErrorMessage(
error_reason=None,
error_description="The mission failed because all tasks in the mission "
Expand All @@ -290,9 +292,12 @@ def _mission_started(self) -> None:
self.current_mission.status = MissionStatus.InProgress
self.publish_mission_status()
self.current_task = self.task_selector.next_task()
self.current_task.status = TaskStatus.InProgress
self.publish_task_status(task=self.current_task)
self.update_current_step()
if self.current_task == None:
self._mission_finished()
else:
self.current_task.status = TaskStatus.InProgress
self.publish_task_status(task=self.current_task)
self.update_current_step()

def _step_finished(self) -> None:
self.publish_step_status(step=self.current_step)
Expand Down Expand Up @@ -393,7 +398,7 @@ def update_current_task(self):
self.current_task = None

def update_current_step(self):
if self.current_task:
if self.current_task != None:
self.current_step = self.current_task.next_step()

def update_remaining_steps(self):
Expand Down
1 change: 0 additions & 1 deletion src/isar/state_machine/states/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def _run(self) -> None:
else:
if isinstance(status, StepStatus):
if self._step_finished(self.state_machine.current_step):
self.state_machine.update_current_step()
self.state_machine.current_task.update_task_status()
else: # If not all steps are done
self.state_machine.current_task.status = TaskStatus.InProgress
Expand Down

0 comments on commit 1a13f22

Please sign in to comment.