guoshilong
2023-10-18 53bcb7e5dffa071d2c6593f5db7f0b6e4e2f8dfe
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
import { commonColor } from '/@/utils/color'
 
// 任务类型
export enum TaskType {
  Immediate = 0, // 立即执行
  Timed = 1, // 单次定时任务
  Repeat = 2, // 重复定时任务
  Continuous = 3, // 连续执行任务
}
 
export const TaskTypeMap = {
  [TaskType.Immediate]: '立即执行',
  [TaskType.Timed]: '单次定时',
  [TaskType.Repeat]: '重复定时',
  [TaskType.Continuous]: '连续执行',
}
 
export const TaskTypeOptions = [
  { value: TaskType.Immediate, label: TaskTypeMap[TaskType.Immediate] },
  { value: TaskType.Timed, label: TaskTypeMap[TaskType.Timed] },
  // { value: TaskType.Repeat, label: TaskTypeMap[TaskType.Repeat] },
  // { value: TaskType.Continuous, label: TaskTypeMap[TaskType.Continuous] },
]
 
// 频率类型
export enum FrequencyType {
  day = 1, // 日
  week = 2, // 周
  month = 3, // 月
}
 
export const FrequencyTypeMap = {
  [FrequencyType.day]: '日',
  [FrequencyType.week]: '周',
  [FrequencyType.month]: '月',
}
 
export const FrequencyTypeOptions = [
  { value: FrequencyType.month, label: FrequencyTypeMap[FrequencyType.month] },
  { value: FrequencyType.week, label: FrequencyTypeMap[FrequencyType.week] },
  { value: FrequencyType.day, label: FrequencyTypeMap[FrequencyType.day] },
]
 
// 重复规则类型
export enum RepeatRuleType {
  day = 1, // 按日期
  week = 2, // 按星期
}
 
export const RepeatRuleTypeMap = {
  [RepeatRuleType.day]: '按日期',
  [RepeatRuleType.week]: '按星期',
}
 
export const RepeatRuleTypeOptions = [
  { value: RepeatRuleType.day, label: RepeatRuleTypeMap[RepeatRuleType.day] },
  { value: RepeatRuleType.week, label: RepeatRuleTypeMap[RepeatRuleType.week] },
]
 
export const WhichWeekOptions = [
  { value: 1, label: '第一个' },
  { value: 2, label: '第二个' },
  { value: 3, label: '第三个' },
  { value: 4, label: '第四个' },
]
export const WhichDayOptions = [
  { value: 7, label: '周日', checked: false },
  { value: 1, label: '周一', checked: false },
  { value: 2, label: '周二', checked: false },
  { value: 3, label: '周三', checked: false },
  { value: 4, label: '周四', checked: false },
  { value: 5, label: '周五', checked: false },
  { value: 6, label: '周六', checked: false },
]
 
// 失控动作
export enum OutOfControlAction {
  ReturnToHome = 0,
  Hover = 1,
  Land = 2,
}
enum OutOfControlActionText {
  返航 = 0,
  盘旋 = 1,
  降落 = 2,
}
export const OutOfControlActionMap = {
  [OutOfControlAction.ReturnToHome]: '返航',
  [OutOfControlAction.Hover]: '盘旋',
  [OutOfControlAction.Land]: '降落',
}
 
export const OutOfControlActionOptions = [
  { value: OutOfControlAction.ReturnToHome, label: OutOfControlActionMap[OutOfControlAction.ReturnToHome] },
  { value: OutOfControlAction.Hover, label: OutOfControlActionMap[OutOfControlAction.Hover] },
  { value: OutOfControlAction.Land, label: OutOfControlActionMap[OutOfControlAction.Land] },
]
 
// 任务状态
export enum TaskStatus {
  Wait = 1, //  待执行
  Carrying = 2, // 执行中
  Success = 3, // 完成
  CanCel = 4, // 取消
  Fail = 5, // 失败
  Paused = 6, // 暂停
}
 
export const TaskStatusMap = {
  [TaskStatus.Wait]: '待执行',
  [TaskStatus.Carrying]: '正在进行',
  [TaskStatus.Success]: '任务完成',
  [TaskStatus.CanCel]: '任务取消',
  [TaskStatus.Fail]: '任务失败',
  [TaskStatus.Paused]: '已暂停',
}
 
export const TaskStatusOptions = [
  { value: TaskStatus.Wait, label: TaskStatusMap[TaskStatus.Wait] },
  { value: TaskStatus.Carrying, label: TaskStatusMap[TaskStatus.Carrying] },
  { value: TaskStatus.Success, label: TaskStatusMap[TaskStatus.Success] },
  { value: TaskStatus.CanCel, label: TaskStatusMap[TaskStatus.CanCel] },
  { value: TaskStatus.Fail, label: TaskStatusMap[TaskStatus.Fail] },
  { value: TaskStatus.Paused, label: TaskStatusMap[TaskStatus.Paused] },
]
 
export const TaskStatusColor = {
  [TaskStatus.Wait]: commonColor.BLUE,
  [TaskStatus.Carrying]: commonColor.BLUE,
  [TaskStatus.Success]: commonColor.NORMAL,
  [TaskStatus.CanCel]: commonColor.FAIL,
  [TaskStatus.Fail]: commonColor.FAIL,
  [TaskStatus.Paused]: commonColor.BLUE,
}
 
// 任务执行 ws 消息状态
export enum TaskProgressStatus {
  Sent = 'sent', // 已下发
  inProgress = 'in_progress', // 执行中
  Paused = 'paused', // 暂停
  Rejected = 'rejected', // 拒绝
  Canceled = 'canceled', // 取消或终止
  Timeout = 'timeout', // 超时
  Failed = 'failed', // 失败
  OK = 'ok', // 上传成功
}
 
// 任务进度消息
export interface TaskProgressInfo {
  bid: string,
  output:{
    ext: {
      current_waypoint_index: number,
      media_count: number // 媒体文件
    },
    progress:{
      current_step: number,
      percent: number
    },
    status: TaskProgressStatus
  },
  result: number,
}
 
// ws status => log status
export const TaskProgressWsStatusMap = {
  [TaskProgressStatus.Sent]: TaskStatus.Carrying,
  [TaskProgressStatus.inProgress]: TaskStatus.Carrying,
  [TaskProgressStatus.Rejected]: TaskStatus.Fail,
  [TaskProgressStatus.OK]: TaskStatus.Success,
  [TaskProgressStatus.Failed]: TaskStatus.Fail,
  [TaskProgressStatus.Canceled]: TaskStatus.CanCel,
  [TaskProgressStatus.Timeout]: TaskStatus.Fail,
  [TaskProgressStatus.Paused]: TaskStatus.Paused,
}
 
// 根据媒体文件上传进度信息,前端自己判断出的状态
export enum MediaStatus { // 媒体上传进度
  ToUpload = 1, // 待上传
  Uploading = 2, // 上传中
  Empty = 3, // 无媒体文件
  Success = 4, // 上传成功
}
 
export const MediaStatusMap = {
  [MediaStatus.ToUpload]: 'Waiting to upload',
  [MediaStatus.Uploading]: 'Uploading…',
  [MediaStatus.Success]: 'Uploaded',
  [MediaStatus.Empty]: 'No media files',
}
 
export const MediaStatusColorMap = {
  [MediaStatus.ToUpload]: commonColor.BLUE,
  [MediaStatus.Uploading]: commonColor.BLUE,
  [MediaStatus.Success]: commonColor.NORMAL,
  [MediaStatus.Empty]: commonColor.WARN,
}
 
// 媒体上传进度消息
export interface MediaStatusProgressInfo {
  job_id: string,
  media_count: number
  uploaded_count: number,
}
 
// 媒体上传优先级消息
export interface TaskMediaHighestPriorityProgressInfo {
  pre_job_id: string,
  job_id: string,
}