Skip to content

Commit d7c89c1

Browse files
committed
Only cancel current mission outside inspection area
1 parent c42ee86 commit d7c89c1

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

backend/api/Services/MissionSchedulingService.cs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,28 +123,30 @@ public async Task StartNextMissionRunIfSystemIsAvailable(Robot robot)
123123
)
124124
{
125125
logger.LogError(
126-
"Robot {RobotNAme} with Id {RobotId} is not on the same inspection area as the mission run with Id {MissionRunId}. Aborting all mission runs",
126+
"Robot {RobotNAme} with Id {RobotId} is not on the same inspection area as the mission run with Id {MissionRunId}. Aborting this mission run",
127127
robot.Name,
128128
robot.Id,
129129
missionRun.Id
130130
);
131131
try
132132
{
133-
await AbortAllScheduledNormalMissions(
134-
robot.Id,
135-
$"All missions aborted: Robot {robot.Name} is on inspection area {robot.CurrentInspectionArea?.Name} "
136-
+ $"and mission run was on inspection area {missionRun.InspectionArea?.Name}"
133+
await AbortMissionRun(
134+
missionRun,
135+
$"Mission run {missionRun.Id} aborted: Robot {robot.Name} is on inspection area {robot.CurrentInspectionArea?.Name} "
136+
+ $"and mission run is on inspection area {missionRun.InspectionArea?.Name}"
137137
);
138138
}
139139
catch (RobotNotFoundException)
140140
{
141141
logger.LogError(
142-
"Failed to abort all scheduled missions for robot {RobotName} with Id {RobotId}",
142+
"Failed to abort scheduled mission {missionRun.Id} for robot {RobotName} with Id {RobotId}",
143+
missionRun.Id,
143144
robot.Name,
144145
robot.Id
145146
);
146147
}
147148

149+
await StartNextMissionRunIfSystemIsAvailable(robot);
148150
return;
149151
}
150152

@@ -341,6 +343,20 @@ public async Task StopCurrentMissionRun(string robotId)
341343
catch (RobotNotFoundException) { }
342344
}
343345

346+
public async Task AbortMissionRun(MissionRun missionRun, string abortReason)
347+
{
348+
await missionRunService.UpdateMissionRunProperty(
349+
missionRun.Id,
350+
"Status",
351+
MissionStatus.Aborted
352+
);
353+
await missionRunService.UpdateMissionRunProperty(
354+
missionRun.Id,
355+
"StatusReason",
356+
abortReason
357+
);
358+
}
359+
344360
public async Task AbortAllScheduledNormalMissions(string robotId, string? abortReason)
345361
{
346362
var robot = await robotService.ReadById(robotId, readOnly: true);

0 commit comments

Comments
 (0)