Skip to content

Commit

Permalink
Update task status after each step
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Jun 4, 2024
1 parent 6d1c941 commit 3cf3b37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/isar/state_machine/states/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ def _run(self) -> None:
else:
if isinstance(status, StepStatus):
if self._step_finished(self.state_machine.current_step):
self.state_machine.update_current_task()
if self.state_machine.current_task == None:
transition = self.state_machine.full_mission_finished # type: ignore
break
self.state_machine.update_current_step()
self.state_machine.current_task.update_task_status()
else: # If not all steps are done
Expand Down
11 changes: 10 additions & 1 deletion src/robot_interface/models/mission/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def is_finished(self) -> bool:
return True

def update_task_status(self) -> None:
some_not_started: bool = False
for step in self.steps:
if step.status is StepStatus.Failed and isinstance(step, MotionStep):
self.error_message = ErrorMessage(
Expand All @@ -79,8 +80,16 @@ def update_task_status(self) -> None:
elif step.status is StepStatus.Successful:
continue

elif (step.status is StepStatus.NotStarted) and isinstance(
step, InspectionStep
):
some_not_started = True

if self.status is not TaskStatus.PartiallySuccessful:
self.status = TaskStatus.Successful
if some_not_started:
self.status = TaskStatus.InProgress # TODO: handle all not_started
else:
self.status = TaskStatus.Successful

elif self._all_inspection_steps_failed():
self.error_message = ErrorMessage(
Expand Down

0 comments on commit 3cf3b37

Please sign in to comment.