forked from equinor/flotilla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIsarStep.cs
110 lines (95 loc) · 3.2 KB
/
IsarStep.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
#nullable disable
namespace Api.Database.Models
{
[Owned]
public class IsarStep
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string Id { get; set; }
[Required]
public string IsarStepId { get; set; }
[Required]
public virtual IsarTask Task { get; set; }
public string TagId { get; set; }
[Required]
public IsarStepStatus StepStatus { get; set; }
[Required]
public StepTypeEnum StepType { get; set; }
public InspectionTypeEnum InspectionType { get; set; }
[Required]
public DateTimeOffset Time { get; set; }
[MaxLength(128)]
public string FileLocation { get; set; }
public enum IsarStepStatus
{
Successful,
InProgress,
NotStarted,
Failed,
Cancelled
}
public enum StepTypeEnum
{
DriveToPose,
TakeImage,
TakeVideo,
TakeThermalImage,
TakeThermalVideo,
RecordAudio
}
public enum InspectionTypeEnum
{
Image,
ThermalImage,
Video,
ThermalVideo,
Audio
}
public static IsarStepStatus StatusFromString(string status)
{
return status switch
{
"successful" => IsarStepStatus.Successful,
"not_started" => IsarStepStatus.NotStarted,
"in_progress" => IsarStepStatus.InProgress,
"failed" => IsarStepStatus.Failed,
"cancelled" => IsarStepStatus.Cancelled,
_
=> throw new ArgumentException(
$"Failed to parse mission status {status} as it's not supported"
)
};
}
public static StepTypeEnum StepTypeFromString(string sensorType)
{
return sensorType switch
{
"DriveToPose" => StepTypeEnum.DriveToPose,
"RecordAudio" => StepTypeEnum.RecordAudio,
"TakeImage" => StepTypeEnum.TakeImage,
"TakeVideo" => StepTypeEnum.TakeVideo,
"TakeThermalImage" => StepTypeEnum.TakeThermalImage,
"TakeThermalVideo" => StepTypeEnum.TakeThermalVideo,
_ => StepTypeEnum.TakeImage,
};
}
public static InspectionTypeEnum InspectionTypeFromString(string sensorType)
{
return sensorType switch
{
"Picture" => InspectionTypeEnum.Image,
"ThermicPicture" => InspectionTypeEnum.ThermalImage,
"Audio" => InspectionTypeEnum.Audio,
"TakeImage" => InspectionTypeEnum.Image,
"TakeVideo" => InspectionTypeEnum.Video,
"TakeThermalImage" => InspectionTypeEnum.ThermalImage,
"TakeThermalVideo" => InspectionTypeEnum.ThermalVideo,
_ => InspectionTypeEnum.Image,
};
}
}
}