Skip to content

Commit

Permalink
Adress requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrica-equinor committed Oct 15, 2024
1 parent ea9030b commit b8e6176
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/backend_lint_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,8 @@ jobs:
# We are using severity level 'info' here.
- name: Run dotnet format
run: dotnet format --severity info --verbosity diagnostic --verify-no-changes --exclude ./api/migrations

- name: Run csharpier format
run: |
dotnet tool restore
dotnet csharpier --check
7 changes: 4 additions & 3 deletions backend/api/Database/Models/Inspection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public Inspection(CustomInspectionQuery inspectionQuery)
}

// Creates a blank deepcopy of the provided inspection
public Inspection(Inspection copy, InspectionStatus? inspectionStatus = null, bool useEmptyIDs = false)
public Inspection(Inspection copy, InspectionStatus? inspectionStatus = null, bool useEmptyID = false)
{
Id = useEmptyIDs ? "" : Guid.NewGuid().ToString();
IsarTaskId = copy.IsarTaskId;
Id = useEmptyID ? "" : Guid.NewGuid().ToString();
IsarTaskId = useEmptyID ? "" : copy.IsarTaskId;
Status = inspectionStatus ?? copy.Status;
InspectionType = copy.InspectionType;
VideoDuration = copy.VideoDuration;
Expand Down Expand Up @@ -133,6 +133,7 @@ public void UpdateStatus(IsarTaskStatus isarStatus)
IsarTaskStatus.Successful => InspectionStatus.Successful,
IsarTaskStatus.Cancelled => InspectionStatus.Cancelled,
IsarTaskStatus.Failed => InspectionStatus.Failed,
IsarTaskStatus.Paused => InspectionStatus.InProgress,
_
=> throw new ArgumentException(
$"ISAR task status '{isarStatus}' not supported for inspection status"
Expand Down
4 changes: 1 addition & 3 deletions backend/api/Database/Models/MissionRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,13 @@ public void CalculateEstimatedDuration()
const int AssumedXyMetersFromFirst = 20;

double distance = 0;
int numberOfTags = 0;
var prevPosition = new Position(
Tasks.First().RobotPose.Position.X + AssumedXyMetersFromFirst,
Tasks.First().RobotPose.Position.Y + AssumedXyMetersFromFirst,
Tasks.First().RobotPose.Position.Z
);
foreach (var task in Tasks)
{
numberOfTags += 1;
var currentPosition = task.RobotPose.Position;
distance +=
Math.Abs(currentPosition.X - prevPosition.X)
Expand All @@ -170,7 +168,7 @@ public void CalculateEstimatedDuration()
}
int estimate = (int)(
(distance / (RobotVelocity * EfficiencyFactor))
+ (numberOfTags * InspectionTime)
+ InspectionTime
);
EstimatedDuration = (uint)estimate * 60;
}
Expand Down
16 changes: 7 additions & 9 deletions backend/api/Database/Models/MissionTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public MissionTask(
TaskStatus status = TaskStatus.NotStarted,
MissionTaskType type = MissionTaskType.Inspection)
{
Inspection = inspection;
TagLink = tagLink;
TagId = tagId;
RobotPose = robotPose;
PoseId = poseId;
TaskOrder = taskOrder;
Status = status;
Type = type;
if (inspection != null) Inspection = new Inspection(inspection);
}

public MissionTask(CustomTaskQuery taskQuery)
Expand All @@ -45,12 +45,15 @@ public MissionTask(CustomTaskQuery taskQuery)
RobotPose = taskQuery.RobotPose;
TaskOrder = taskQuery.TaskOrder;
Status = TaskStatus.NotStarted;
Type = MissionTaskType.ReturnHome;
if (taskQuery.Inspection is not null)
{
Inspection = new Inspection((CustomInspectionQuery)taskQuery.Inspection);
Type = MissionTaskType.Inspection;
}
else
{
Type = MissionTaskType.ReturnHome;
}
}

public MissionTask(Pose robotPose, MissionTaskType type)
Expand Down Expand Up @@ -201,13 +204,8 @@ public static string CalculateHashFromTasks(IList<MissionTask> tasks)
Id = "",
IsarTaskId = "",
};
if (taskCopy.Inspection is not null)
{
taskCopy.Inspection = new Inspection(taskCopy.Inspection, useEmptyIDs: true)
{
IsarTaskId = ""
};
}
if (taskCopy.Inspection is not null) taskCopy.Inspection = new Inspection(taskCopy.Inspection, useEmptyID: true);

genericTasks.Add(taskCopy);
}

Expand Down
33 changes: 16 additions & 17 deletions backend/api/Services/EchoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,30 +265,29 @@ List<EchoPlantInfoResponse> echoPlantInfoResponse
public IList<MissionTask> MissionTasksFromEchoTag(EchoTag echoTag)
{
var inspections = echoTag.Inspections
.Select(inspection => new Inspection(
inspectionType: inspection.InspectionType,
videoDuration: inspection.TimeInSeconds,
inspection.InspectionPoint,
status: InspectionStatus.NotStarted))
.ToList();
.Select(inspection => new Inspection(
inspectionType: inspection.InspectionType,
videoDuration: inspection.TimeInSeconds,
inspection.InspectionPoint,
status: InspectionStatus.NotStarted))
.ToList();

var missionTasks = new List<MissionTask>();

foreach (var inspection in inspections)
{
missionTasks.Add(
new MissionTask
(
inspection: inspection,
tagLink: echoTag.URL,
tagId: echoTag.TagId,
robotPose: echoTag.Pose,
poseId: echoTag.PoseId,
taskOrder: echoTag.PlanOrder,
status: Database.Models.TaskStatus.NotStarted,
type: MissionTaskType.Inspection
));

(
inspection: inspection,
tagLink: echoTag.URL,
tagId: echoTag.TagId,
robotPose: echoTag.Pose,
poseId: echoTag.PoseId,
taskOrder: echoTag.PlanOrder,
status: Database.Models.TaskStatus.NotStarted,
type: MissionTaskType.Inspection
));
}

return missionTasks;
Expand Down
2 changes: 1 addition & 1 deletion backend/api/Services/MissionDefinitionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private IQueryable<MissionDefinition> GetMissionDefinitionsWithSubModels(bool re
.Include(missionDefinition => missionDefinition.LastSuccessfulRun)
.ThenInclude(missionRun => missionRun != null ? missionRun.Tasks : null)!
.ThenInclude(missionTask => missionTask.Inspection)
.ThenInclude(inspection => inspection != null ? inspection.InspectionFindings : null)!
.ThenInclude(inspection => inspection != null ? inspection.InspectionFindings : null)
.Include(missionDefinition => missionDefinition.Area != null ? missionDefinition.Area.Deck : null)
.ThenInclude(deck => deck != null ? deck.DefaultLocalizationPose : null)
.ThenInclude(defaultLocalizationPose => defaultLocalizationPose != null ? defaultLocalizationPose.Pose : null)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/models/Inspection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface Inspection {
inspectionTarget: Position
videoDuration?: number
analysisType?: string
inspectionUrl?: string | null
inspectionUrl?: string
startTime?: Date
endTime?: Date
}
Expand Down

0 comments on commit b8e6176

Please sign in to comment.