Skip to content

Commit

Permalink
Refactor and add guard statement in MissionEventHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhammadUsama-afk-equinor committed Feb 16, 2024
1 parent 0938c69 commit d9c2a1a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
7 changes: 2 additions & 5 deletions backend/api/EventHandlers/MissionEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,9 @@ private async void OnRobotAvailable(object? sender, RobotAvailableEventArgs e)
return;
}

MissionRun? missionRun;
var missionRun = await MissionService.ReadNextScheduledLocalizationMissionRun(robot.Id);

missionRun = await MissionService.ReadNextScheduledLocalizationMissionRun(robot.Id);

if (missionRun != null) { _logger.LogInformation("The robot will be localized in the next mission"); }
else
if (missionRun == null)
{
if (robot.MissionQueueFrozen) { missionRun = await MissionService.ReadNextScheduledEmergencyMissionRun(robot.Id); }
else { missionRun = await MissionService.ReadNextScheduledMissionRun(robot.Id); }
Expand Down
1 change: 0 additions & 1 deletion backend/api/Services/LocalizationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ private async Task<MissionRun> CreateLocalizationMissionInArea(string robotId, s
new(area.Deck.DefaultLocalizationPose.Pose, MissionTaskType.Localization)
},
Map = new MapMetadata()

};
logger.LogWarning("Starting localization mission");
await missionRunService.Create(localizationMissionRun, triggerCreatedMissionRunEvent: false);
Expand Down

0 comments on commit d9c2a1a

Please sign in to comment.