Skip to content

Commit

Permalink
Reset current mission in onIsarStatusUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
oysand committed Nov 27, 2024
1 parent 9d11170 commit f7e0086
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions backend/api/EventHandlers/MqttEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,16 @@ private async void OnIsarStatus(object? sender, MqttReceivedArgs mqttArgs)

_logger.LogInformation("OnIsarStatus: Robot {robotName} has status {robotStatus} and current area {areaName}", updatedRobot.Name, updatedRobot.Status, updatedRobot.CurrentArea?.Name);

if (isarStatus.Status == RobotStatus.Available) MissionScheduling.TriggerRobotAvailable(new RobotAvailableEventArgs(robot.Id));
if (isarStatus.Status == RobotStatus.Available)
{
try { await RobotService.UpdateCurrentMissionId(robot.Id, null); }
catch (RobotNotFoundException)
{
_logger.LogError("Robot {robotName} not found when updating current mission id to null", robot.Name);
return;
}
MissionScheduling.TriggerRobotAvailable(new RobotAvailableEventArgs(robot.Id));
}
else if (isarStatus.Status == RobotStatus.Offline)
{
await RobotService.UpdateCurrentArea(robot.Id, null);
Expand Down Expand Up @@ -333,16 +342,6 @@ private async void OnIsarMissionUpdate(object? sender, MqttReceivedArgs mqttArgs
}
}

try
{
await RobotService.UpdateCurrentMissionId(robot.Id, null);
}
catch (RobotNotFoundException)
{
_logger.LogError("Robot {robotName} not found when updating current mission id to null", robot.Name);
return;
}

_logger.LogInformation("Robot '{Id}' ('{Name}') - completed mission run {MissionRunId}", robot.IsarId, robot.Name, updatedFlotillaMissionRun.Id);

if (updatedFlotillaMissionRun.IsLocalizationMission() && (updatedFlotillaMissionRun.Status == MissionStatus.Successful || updatedFlotillaMissionRun.Status == MissionStatus.PartiallySuccessful))
Expand Down

0 comments on commit f7e0086

Please sign in to comment.