Skip to content

Commit

Permalink
Make inspectionArea optional and add migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Dec 16, 2024
1 parent 0060030 commit c43a97d
Show file tree
Hide file tree
Showing 10 changed files with 1,811 additions and 66 deletions.
7 changes: 6 additions & 1 deletion backend/api/Controllers/MissionSchedulingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ [FromBody] ScheduledMissionQuery scheduledMissionQuery
if (missionDefinitions.Count > 0)
{
existingMissionDefinition = missionDefinitions.First();
if (existingMissionDefinition.InspectionArea == null)
{
existingMissionDefinition.InspectionArea = area.Deck;
await missionDefinitionService.Update(existingMissionDefinition);
}
}
}

Expand Down Expand Up @@ -319,7 +324,7 @@ [FromBody] ScheduledMissionQuery scheduledMissionQuery
await missionDefinitionService.Create(scheduledMissionDefinition);
}

if (missionRun.Robot.CurrentInspectionArea != null && !await localizationService.RobotIsOnSameDeckAsMission(missionRun.Robot.Id, missionRun.InspectionArea.Id))
if (missionRun.Robot.CurrentInspectionArea != null && !await localizationService.RobotIsOnSameDeckAsMission(missionRun.Robot.Id, missionRun.InspectionArea!.Id))
{
return Conflict($"The robot {missionRun.Robot.Name} is assumed to be in a different inspection area so the mission was not scheduled.");
}
Expand Down
2 changes: 2 additions & 0 deletions backend/api/Database/Context/FlotillaDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

modelBuilder.Entity<MissionDefinition>().OwnsOne(m => m.Map).OwnsOne(t => t.TransformationMatrices);
modelBuilder.Entity<MissionDefinition>().OwnsOne(m => m.Map).OwnsOne(b => b.Boundary);
modelBuilder.Entity<MissionDefinition>().HasOne(m => m.InspectionArea).WithMany().OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<MissionRun>().HasOne(m => m.InspectionArea).WithMany().OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<Robot>().OwnsOne(r => r.Pose).OwnsOne(p => p.Orientation);
modelBuilder.Entity<Robot>().OwnsOne(r => r.Pose).OwnsOne(p => p.Position);

Expand Down
3 changes: 1 addition & 2 deletions backend/api/Database/Models/MissionDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public class MissionDefinition : SortableRecord

public virtual MissionRun? LastSuccessfulRun { get; set; }

[Required]
public Deck InspectionArea { get; set; }
public Deck? InspectionArea { get; set; }

public MapMetadata? Map { get; set; }

Expand Down
3 changes: 1 addition & 2 deletions backend/api/Database/Models/MissionRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ public IList<MissionTask> Tasks
[MaxLength(1000)]
public string? Comment { get; set; }

[Required]
public Deck InspectionArea { get; set; }
public Deck? InspectionArea { get; set; }

public bool IsCompleted =>
_status
Expand Down
Loading

0 comments on commit c43a97d

Please sign in to comment.