Skip to content

Commit

Permalink
Add additional logging
Browse files Browse the repository at this point in the history
  • Loading branch information
oysand committed Dec 20, 2023
1 parent 15d3f9c commit 619bc15
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions backend/api/EventHandlers/MqttEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ private async void OnIsarRobotStatus(object? sender, MqttReceivedArgs mqttArgs)
return;
}

if (robot.Status == isarRobotStatus.RobotStatus) { return; }
if (robot.Status == isarRobotStatus.RobotStatus)
{
_logger.LogInformation("Robot {robotName} received a new isar robot status {isarRobotStatus}, but the robot status was already the same", robot.Name, isarRobotStatus.RobotStatus);
return;
}

robot = await robotService.UpdateRobotStatus(robot.Id, isarRobotStatus.RobotStatus);
_logger.LogInformation("Updated status for robot {Name} to {Status}", robot.Name, robot.Status);
Expand Down Expand Up @@ -237,14 +241,26 @@ private async void OnMissionUpdate(object? sender, MqttReceivedArgs mqttArgs)
}

try { await robotService.UpdateCurrentMissionId(robot.Id, null); }
catch (RobotNotFoundException) { return; }
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, flotillaMissionRun.Id);

if (flotillaMissionRun.MissionId == null) { return; }
if (flotillaMissionRun.MissionId == null)
{
_logger.LogInformation("Mission run {missionRunId} does not have a mission definition assosiated with it", flotillaMissionRun.Id);
return;
}

try { await lastMissionRunService.SetLastMissionRun(flotillaMissionRun.Id, flotillaMissionRun.MissionId); }
catch (MissionNotFoundException) { return; }
catch (MissionNotFoundException)
{
_logger.LogError("Mission not found when setting last mission run for mission definition {missionId}", flotillaMissionRun.MissionId);
return;
}

await taskDurationService.UpdateAverageDurationPerTask(robot.Model.Type);
}
Expand Down

0 comments on commit 619bc15

Please sign in to comment.