diff --git a/backend/api.test/Database/DatabaseUtilities.cs b/backend/api.test/Database/DatabaseUtilities.cs index c2d32ec18..da9fc3fa6 100644 --- a/backend/api.test/Database/DatabaseUtilities.cs +++ b/backend/api.test/Database/DatabaseUtilities.cs @@ -40,7 +40,7 @@ public async Task NewMissionRun( Robot robot, Area area, bool writeToDatabase = false, - MissionRunPriority missionRunPriority = MissionRunPriority.Normal, + MissionRunType missionRunType = MissionRunType.Normal, MissionStatus missionStatus = MissionStatus.Pending, string? isarMissionId = null ) @@ -51,7 +51,7 @@ public async Task NewMissionRun( Robot = robot, MissionId = null, IsarMissionId = isarMissionId, - MissionRunPriority = missionRunPriority, + MissionRunType = missionRunType, Status = missionStatus, DesiredStartTime = DateTime.Now, Area = area, @@ -59,7 +59,7 @@ public async Task NewMissionRun( Map = new MapMetadata(), InstallationCode = installationCode }; - if (missionRunPriority == MissionRunPriority.Localization) + if (missionRunType == MissionRunType.Localization) { missionRun.Tasks = new List { diff --git a/backend/api.test/EventHandlers/TestMissionEventHandler.cs b/backend/api.test/EventHandlers/TestMissionEventHandler.cs index 6985505d3..d6dfe7d82 100644 --- a/backend/api.test/EventHandlers/TestMissionEventHandler.cs +++ b/backend/api.test/EventHandlers/TestMissionEventHandler.cs @@ -309,7 +309,7 @@ public async void QueuedMissionsAreAbortedWhenLocalizationFails() var deck = await _databaseUtilities.NewDeck(installation.InstallationCode, plant.PlantCode); var area = await _databaseUtilities.NewArea(installation.InstallationCode, plant.PlantCode, deck.Name); var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, area); - var localizationMissionRun = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, area, true, MissionRunPriority.Localization, MissionStatus.Ongoing, Guid.NewGuid().ToString()); + var localizationMissionRun = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, area, true, MissionRunType.Localization, MissionStatus.Ongoing, Guid.NewGuid().ToString()); var missionRun1 = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, area, true); Thread.Sleep(100); @@ -342,7 +342,7 @@ public async void LocalizationMissionCompletesAfterPressingSendToSafeZoneButton( var deck = await _databaseUtilities.NewDeck(installation.InstallationCode, plant.PlantCode); var area = await _databaseUtilities.NewArea(installation.InstallationCode, plant.PlantCode, deck.Name); var robot = await _databaseUtilities.NewRobot(RobotStatus.Busy, installation, area); - await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, area, true, MissionRunPriority.Localization, MissionStatus.Ongoing, Guid.NewGuid().ToString()); + await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, area, true, MissionRunType.Localization, MissionStatus.Ongoing, Guid.NewGuid().ToString()); Thread.Sleep(100); diff --git a/backend/api/Controllers/MissionSchedulingController.cs b/backend/api/Controllers/MissionSchedulingController.cs index d68addde6..d6a09ccd8 100644 --- a/backend/api/Controllers/MissionSchedulingController.cs +++ b/backend/api/Controllers/MissionSchedulingController.cs @@ -79,7 +79,7 @@ [FromBody] ScheduleMissionQuery scheduledMissionQuery Robot = robot, MissionId = missionRun.MissionId, Status = MissionStatus.Pending, - MissionRunPriority = MissionRunPriority.Normal, + MissionRunType = MissionRunType.Normal, Tasks = missionTasks, DesiredStartTime = scheduledMissionQuery.DesiredStartTime ?? DateTime.UtcNow, InstallationCode = missionRun.InstallationCode, @@ -156,7 +156,7 @@ [FromBody] ScheduleMissionQuery scheduledMissionQuery Robot = robot, MissionId = missionDefinition.Id, Status = MissionStatus.Pending, - MissionRunPriority = MissionRunPriority.Normal, + MissionRunType = MissionRunType.Normal, DesiredStartTime = scheduledMissionQuery.DesiredStartTime ?? DateTime.UtcNow, Tasks = missionTasks, InstallationCode = missionDefinition.InstallationCode, @@ -317,7 +317,7 @@ [FromBody] ScheduledMissionQuery scheduledMissionQuery Robot = robot, MissionId = scheduledMissionDefinition.Id, Status = MissionStatus.Pending, - MissionRunPriority = MissionRunPriority.Normal, + MissionRunType = MissionRunType.Normal, DesiredStartTime = scheduledMissionQuery.DesiredStartTime ?? DateTime.UtcNow, Tasks = missionTasks, InstallationCode = scheduledMissionQuery.InstallationCode, diff --git a/backend/api/Controllers/Models/MissionRunResponse.cs b/backend/api/Controllers/Models/MissionRunResponse.cs index 0d71049de..c65617d35 100644 --- a/backend/api/Controllers/Models/MissionRunResponse.cs +++ b/backend/api/Controllers/Models/MissionRunResponse.cs @@ -40,7 +40,7 @@ public class MissionRunResponse public MapMetadata? Map { get; set; } - public MissionRunPriority MissionRunPriority { get; set; } + public MissionRunType MissionRunType { get; set; } [JsonConstructor] #nullable disable @@ -67,7 +67,7 @@ public MissionRunResponse(MissionRun mission) EstimatedDuration = mission.EstimatedDuration; Tasks = mission.Tasks; Map = mission.Map; - MissionRunPriority = mission.MissionRunPriority; + MissionRunType = mission.MissionRunType; } } diff --git a/backend/api/Database/Models/MissionRun.cs b/backend/api/Database/Models/MissionRun.cs index a918db5e2..1ba61015d 100644 --- a/backend/api/Database/Models/MissionRun.cs +++ b/backend/api/Database/Models/MissionRun.cs @@ -55,7 +55,7 @@ public IList Tasks } [Required] - public MissionRunPriority MissionRunPriority { get; set; } + public MissionRunType MissionRunType { get; set; } [MaxLength(200)] public string? IsarMissionId { get; set; } @@ -207,10 +207,10 @@ public enum MissionStatus PartiallySuccessful } - public enum MissionRunPriority + public enum MissionRunType { Normal, - Response, + ReturnHome, Emergency, Localization } diff --git a/backend/api/EventHandlers/MissionEventHandler.cs b/backend/api/EventHandlers/MissionEventHandler.cs index a1fa6b9cd..22bb66156 100644 --- a/backend/api/EventHandlers/MissionEventHandler.cs +++ b/backend/api/EventHandlers/MissionEventHandler.cs @@ -163,7 +163,7 @@ private async void OnMissionCompleted(object? sender, MissionCompletedEventArgs var lastMissionRun = await MissionService.ReadLastExecutedMissionRunByRobotWithoutTracking(robot.Id); if (lastMissionRun != null) { - if (lastMissionRun.MissionRunPriority == MissionRunPriority.Emergency & lastMissionRun.Status == MissionStatus.Successful) + if (lastMissionRun.MissionRunType == MissionRunType.Emergency & lastMissionRun.Status == MissionStatus.Successful) { _logger.LogInformation("Return to safe zone mission on robot {RobotName} was successful.", robot.Name); SignalRService.ReportSafeZoneSuccessToSignalR(robot, $"Robot {robot.Name} is in the safe zone"); diff --git a/backend/api/Services/ActionServices/CustomMissionSchedulingService.cs b/backend/api/Services/ActionServices/CustomMissionSchedulingService.cs index e85e37d97..1d825068b 100644 --- a/backend/api/Services/ActionServices/CustomMissionSchedulingService.cs +++ b/backend/api/Services/ActionServices/CustomMissionSchedulingService.cs @@ -113,7 +113,7 @@ public async Task QueueCustomMissionRun(CustomMissionQuery customMis Comment = customMissionQuery.Comment, Robot = robot, Status = MissionStatus.Pending, - MissionRunPriority = MissionRunPriority.Normal, + MissionRunType = MissionRunType.Normal, DesiredStartTime = customMissionQuery.DesiredStartTime ?? DateTime.UtcNow, Tasks = missionTasks, InstallationCode = customMissionQuery.InstallationCode, diff --git a/backend/api/Services/LocalizationService.cs b/backend/api/Services/LocalizationService.cs index a39e4971b..6e25c66b1 100644 --- a/backend/api/Services/LocalizationService.cs +++ b/backend/api/Services/LocalizationService.cs @@ -86,7 +86,7 @@ public async Task CreateLocalizationMissionInArea(string robotId, st { Name = "Localization mission", Robot = robot, - MissionRunPriority = MissionRunPriority.Localization, + MissionRunType = MissionRunType.Localization, InstallationCode = area.Installation.InstallationCode, Area = area, Status = MissionStatus.Pending, diff --git a/backend/api/Services/MissionRunService.cs b/backend/api/Services/MissionRunService.cs index bab67d3d7..2da077b6e 100644 --- a/backend/api/Services/MissionRunService.cs +++ b/backend/api/Services/MissionRunService.cs @@ -134,14 +134,14 @@ public async Task> ReadMissionRunQueue(string robotId) return await GetMissionRunsWithSubModels() .OrderBy(missionRun => missionRun.DesiredStartTime) .FirstOrDefaultAsync(missionRun => - missionRun.Robot.Id == robotId && missionRun.MissionRunPriority == MissionRunPriority.Emergency && missionRun.Status == MissionStatus.Pending); + missionRun.Robot.Id == robotId && missionRun.MissionRunType == MissionRunType.Emergency && missionRun.Status == MissionStatus.Pending); } public async Task ReadNextScheduledLocalizationMissionRun(string robotId) { var nextScheduledMissionRun = await GetMissionRunsWithSubModels() .OrderBy(missionRun => missionRun.DesiredStartTime) - .FirstOrDefaultAsync(missionRun => missionRun.Robot.Id == robotId && missionRun.Status == MissionStatus.Pending && missionRun.MissionRunPriority == MissionRunPriority.Localization); + .FirstOrDefaultAsync(missionRun => missionRun.Robot.Id == robotId && missionRun.Status == MissionStatus.Pending && missionRun.MissionRunType == MissionRunType.Localization); return nextScheduledMissionRun; } diff --git a/backend/api/Services/MissionSchedulingService.cs b/backend/api/Services/MissionSchedulingService.cs index a8074c126..ae0878cf1 100644 --- a/backend/api/Services/MissionSchedulingService.cs +++ b/backend/api/Services/MissionSchedulingService.cs @@ -240,7 +240,7 @@ public async Task ScheduleMissionToDriveToSafePosition(string robotId, string ar { Name = "Drive to Safe Position", Robot = robot, - MissionRunPriority = MissionRunPriority.Emergency, + MissionRunType = MissionRunType.Emergency, InstallationCode = area.Installation.InstallationCode, Area = area, Status = MissionStatus.Pending, @@ -306,7 +306,7 @@ private async Task MoveInterruptedMissionsToQueue(IEnumerable interrupte { Name = missionRun.Name, Robot = missionRun.Robot, - MissionRunPriority = missionRun.MissionRunPriority, + MissionRunType = missionRun.MissionRunType, InstallationCode = missionRun.Area!.Installation.InstallationCode, Area = missionRun.Area, Status = MissionStatus.Pending, @@ -450,7 +450,7 @@ private async Task TheSystemIsAvailableToRunAMission(string robotId, strin throw new MissionRunNotFoundException(errorMessage); } - if (robot.MissionQueueFrozen && missionRun.MissionRunPriority != MissionRunPriority.Emergency && missionRun.MissionRunPriority != MissionRunPriority.Localization) + if (robot.MissionQueueFrozen && missionRun.MissionRunType != MissionRunType.Emergency && missionRun.MissionRunType != MissionRunType.Localization) { logger.LogInformation("Mission run {MissionRunId} was not started as the mission run queue for robot {RobotName} is frozen", missionRun.Id, robot.Name); return false; diff --git a/backend/api/Services/ReturnToHomeService.cs b/backend/api/Services/ReturnToHomeService.cs index 7391d3f71..7cd62697e 100644 --- a/backend/api/Services/ReturnToHomeService.cs +++ b/backend/api/Services/ReturnToHomeService.cs @@ -92,7 +92,7 @@ private async Task ScheduleReturnToHomeMissionRun(string robotId) Name = "Return to home mission", Robot = robot, InstallationCode = robot.CurrentInstallation.InstallationCode, - MissionRunPriority = MissionRunPriority.Normal, + MissionRunType = MissionRunType.ReturnHome, Area = robot.CurrentArea, Status = MissionStatus.Pending, DesiredStartTime = DateTime.UtcNow,