Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use step_status for not stepwise robots #526

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions src/isar/state_machine/states/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from injector import inject
from transitions import State
from isar.mission_planner.task_selector_interface import TaskSelectorStop

from isar.services.utilities.threaded_request import (
ThreadedRequest,
Expand All @@ -19,7 +20,7 @@
)
from robot_interface.models.inspection.inspection import Inspection
from robot_interface.models.mission.mission import Mission
from robot_interface.models.mission.status import MissionStatus
from robot_interface.models.mission.status import MissionStatus, TaskStatus
from robot_interface.models.mission.step import InspectionStep, Step, StepStatus

if TYPE_CHECKING:
Expand Down Expand Up @@ -56,16 +57,10 @@ def _run(self) -> None:
break

if not self.step_status_thread:
if self.state_machine.stepwise_mission:
self._run_get_status_thread(
status_function=self.state_machine.robot.step_status,
thread_name="State Machine Monitor Get Step Status",
)
else:
self._run_get_status_thread(
status_function=self.state_machine.robot.mission_status,
thread_name="State Machine Monitor Get Mission Status",
)
self._run_get_status_thread(
status_function=self.state_machine.robot.step_status,
thread_name="State Machine Monitor Get Step Status",
)

try:
status: Union[StepStatus, MissionStatus] = (
Expand Down Expand Up @@ -106,7 +101,7 @@ def _run(self) -> None:
f"Retrieving the status failed because: {e.error_description}"
)

if self.state_machine.stepwise_mission and isinstance(status, StepStatus):
if isinstance(status, StepStatus):
self.state_machine.current_step.status = status
elif isinstance(status, MissionStatus):
self.state_machine.current_mission.status = status
Expand All @@ -126,6 +121,29 @@ def _run(self) -> None:
transition = self.state_machine.step_finished # type: ignore
break
else:
if (
andchiind marked this conversation as resolved.
Show resolved Hide resolved
isinstance(status, StepStatus)
and self.state_machine.current_task != None
):
if (
status != StepStatus.InProgress
and status != StepStatus.NotStarted
): # If task is done
self.state_machine.current_task.update_task_status()
else: # If not all steps are done
self.state_machine.current_task.status = TaskStatus.InProgress

self.state_machine.publish_task_status(
self.state_machine.current_task
)
if self.state_machine.current_task.status == TaskStatus.Successful:
try:
self.state_machine.current_task = (
self.state_machine.task_selector.next_task()
)
except TaskSelectorStop:
# Indicates that all tasks are finished
self.state_machine.current_task = None
if self._mission_finished(self.state_machine.current_mission):
transition = self.state_machine.full_mission_finished # type: ignore
break
Expand Down
Loading