Skip to content

Commit

Permalink
Ensure missions don't start on deprecated robot
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddasol committed Apr 2, 2024
1 parent 7bbba8c commit 2dc1884
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions backend/api/Controllers/RobotController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,14 @@ [FromRoute] string armPosition
logger.LogWarning("{Message}", errorMessage);
return Conflict(errorMessage);
}

if (robot.Deprecated)
{
string errorMessage = $"Robot {robotId} is deprecated ({robot.Status}) and cannot run missions";
logger.LogWarning("{Message}", errorMessage);
return Conflict(errorMessage);
}

try { await isarService.StartMoveArm(robot, armPosition); }
catch (HttpRequestException e)
{
Expand Down
6 changes: 6 additions & 0 deletions backend/api/Services/LocalizationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ public async Task<MissionRun> CreateLocalizationMissionInArea(string robotId, st
logger.LogWarning("{Message}", errorMessage);
throw new RobotNotAvailableException(errorMessage);
}
if (robot.Deprecated)
{
string errorMessage = $"Robot '{robot.Id}' is deprecated and cannot localize";
logger.LogWarning("{Message}", errorMessage);
throw new RobotNotAvailableException(errorMessage);
}

var localizationMissionRun = new MissionRun
{
Expand Down
7 changes: 7 additions & 0 deletions backend/api/Services/MissionSchedulingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,13 @@ private async Task StartMissionRun(MissionRun queuedMissionRun)
throw new RobotNotAvailableException(errorMessage);
}

if (robot.Deprecated)
{
string errorMessage = $"Robot {robotId} is deprecated and cannot start mission";
logger.LogError("{Message}", errorMessage);
throw new RobotNotAvailableException(errorMessage);
}

var missionRun = await missionRunService.ReadById(missionRunId);
if (missionRun == null)
{
Expand Down

0 comments on commit 2dc1884

Please sign in to comment.