Skip to content

Commit

Permalink
Remove battery requirement for scheduling missions
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddasol committed Jan 17, 2025
1 parent 3e0a52b commit 3fee8e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
8 changes: 4 additions & 4 deletions backend/api/Controllers/MissionSchedulingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ [FromBody] ScheduleMissionQuery scheduledMissionQuery
Robot robot;
try
{
robot = await robotService.GetRobotWithPreCheck(
robot = await robotService.GetRobotWithSchedulingPreCheck(
scheduledMissionQuery.RobotId,
readOnly: true
);
Expand Down Expand Up @@ -141,7 +141,7 @@ [FromBody] ScheduleMissionQuery scheduledMissionQuery
Robot robot;
try
{
robot = await robotService.GetRobotWithPreCheck(
robot = await robotService.GetRobotWithSchedulingPreCheck(
scheduledMissionQuery.RobotId,
readOnly: true
);
Expand Down Expand Up @@ -261,7 +261,7 @@ [FromBody] ScheduledMissionQuery scheduledMissionQuery
Robot robot;
try
{
robot = await robotService.GetRobotWithPreCheck(
robot = await robotService.GetRobotWithSchedulingPreCheck(
scheduledMissionQuery.RobotId,
readOnly: true
);
Expand Down Expand Up @@ -484,7 +484,7 @@ [FromBody] CustomMissionQuery customMissionQuery
Robot robot;
try
{
robot = await robotService.GetRobotWithPreCheck(
robot = await robotService.GetRobotWithSchedulingPreCheck(
customMissionQuery.RobotId,
readOnly: true
);
Expand Down
31 changes: 5 additions & 26 deletions backend/api/Services/RobotService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface IRobotService
{
public Task<Robot> Create(Robot newRobot);
public Task<Robot> CreateFromQuery(CreateRobotQuery robotQuery);
public Task<Robot> GetRobotWithPreCheck(string robotId, bool readOnly = true);
public Task<Robot> GetRobotWithSchedulingPreCheck(string robotId, bool readOnly = true);
public Task<IEnumerable<Robot>> ReadAll(bool readOnly = true);
public Task<IEnumerable<string>> ReadAllActivePlants(bool readOnly = true);
public Task<Robot?> ReadById(string id, bool readOnly = true);
Expand Down Expand Up @@ -136,7 +136,10 @@ public async Task<Robot> CreateFromQuery(CreateRobotQuery robotQuery)
);
}

public async Task<Robot> GetRobotWithPreCheck(string robotId, bool readOnly = true)
public async Task<Robot> GetRobotWithSchedulingPreCheck(
string robotId,
bool readOnly = true
)
{
var robot = await ReadById(robotId, readOnly: readOnly);

Expand All @@ -162,30 +165,6 @@ public async Task<Robot> GetRobotWithPreCheck(string robotId, bool readOnly = tr
throw new RobotPreCheckFailedException(errorMessage);
}

if (robot.IsRobotPressureTooLow())
{
string errorMessage =
$"The robot pressure on {robot.Name} is too low to start a mission";
logger.LogError("{Message}", errorMessage);
throw new RobotPreCheckFailedException(errorMessage);
}

if (robot.IsRobotPressureTooHigh())
{
string errorMessage =
$"The robot pressure on {robot.Name} is too high to start a mission";
logger.LogError("{Message}", errorMessage);
throw new RobotPreCheckFailedException(errorMessage);
}

if (robot.IsRobotBatteryTooLow())
{
string errorMessage =
$"The robot battery level on {robot.Name} is too low to start a mission";
logger.LogError("{Message}", errorMessage);
throw new RobotPreCheckFailedException(errorMessage);
}

return robot;
}

Expand Down

0 comments on commit 3fee8e6

Please sign in to comment.