diff --git a/src/isar/state_machine/state_machine.py b/src/isar/state_machine/state_machine.py index 4ccfae60..f6c9bd04 100644 --- a/src/isar/state_machine/state_machine.py +++ b/src/isar/state_machine/state_machine.py @@ -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 " @@ -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) @@ -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): diff --git a/src/isar/state_machine/states/monitor.py b/src/isar/state_machine/states/monitor.py index b221ebde..f4a03f07 100644 --- a/src/isar/state_machine/states/monitor.py +++ b/src/isar/state_machine/states/monitor.py @@ -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