feat: 完善机巢任务安全控制与状态诊断

同步新版飞控与 WebSocket 回执合同,完善独立指令等待、暂停继续和返航状态;增加真机诊断并优化倒计时与素材库展示。
This commit is contained in:
2026-11-04 17:34:28 +08:00
parent 1c766ff12f
commit e3979e9e32
44 changed files with 4575 additions and 581 deletions
@@ -6,7 +6,7 @@ enum DroneDockSafetyCommand: String, CaseIterable, Sendable {
case pause = "flighttask_pause"
/// 恢复已暂停的航线。
case resume = "flighttask_recovery"
/// 立即返航;服务端会中断当前任务并释放飞行锁。
/// 立即返航;中断拍摄结果,回巢前仍占用设备。
case returnHome = "return_home"
/// 取消返航,不代表已恢复或重新创建原拍摄任务。
case cancelReturn = "return_home_cancel"
@@ -14,6 +14,26 @@ enum DroneDockSafetyCommand: String, CaseIterable, Sendable {
/// 指令受理回执;仅保留后端返回的身份、读数与状态,不推断设备已完成动作。
struct DroneDockCommandResponse: Decodable, Equatable, Sendable {
/// 明确受理标记,仅受理不表示设备已执行。
let accepted: Bool?
/// 回执探测时是否确认设备状态;页面最终仍读取完整 shooting/WS。
let deviceConfirmed: Bool?
/// 本次指令的服务端唯一标识。
let commandID: String?
/// 回显本次点击的幂等键,提供时必须与请求一致。
let clientRequestID: String?
/// 回执顶层的指令进度;完整任务快照位于 flight_control 内。
let pendingCommand: DroneDockCommandProgress?
/// 受理提示原文,用于诊断,不作为展示状态。
let hint: String?
/// 回执所属批次,必须与提交时一致。
let executionBatch: Int64?
/// 回执对应快照版本,用作后续状态核对的最低版本。
let stateVersion: Int64?
/// 设备身份在提供时必须匹配任务锁定设备。
let planeID: Int?
/// 回执中的设备状态不替代完整任务快照。
let flightControl: DroneDockFlightControl?
/// 文档要求回显的订单飞行任务 ID。
let orderFlightTaskID: Int?
/// 本次回显的指令码,API 核验其与请求一致。
@@ -29,6 +49,9 @@ struct DroneDockCommandResponse: Decodable, Equatable, Sendable {
/// 朱工指令回执字段映射。
private enum CodingKeys: String, CodingKey {
case accepted, deviceConfirmed = "device_confirmed", hint, executionBatch = "execution_batch"
case commandID = "command_id", clientRequestID = "client_request_id", pendingCommand = "pending_command"
case stateVersion = "state_version", planeID = "plane_id", flightControl = "flight_control"
case orderFlightTaskID = "order_flight_task_id", command, airportSN = "airport_sn"
case djiStatus = "dji_status", metrics
}
@@ -36,6 +59,16 @@ struct DroneDockCommandResponse: Decodable, Equatable, Sendable {
/// 不补造身份、状态或读数,完整 JSON 仍保留实际出现的 null 字段。
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
accepted = try container.decodeIfPresent(Bool.self, forKey: .accepted)
deviceConfirmed = try container.decodeIfPresent(Bool.self, forKey: .deviceConfirmed)
commandID = try container.decodeIfPresent(String.self, forKey: .commandID)
clientRequestID = try container.decodeIfPresent(String.self, forKey: .clientRequestID)
pendingCommand = try container.decodeIfPresent(DroneDockCommandProgress.self, forKey: .pendingCommand)
hint = try container.decodeIfPresent(String.self, forKey: .hint)
executionBatch = try container.decodeIfPresent(Int64.self, forKey: .executionBatch)
stateVersion = try container.decodeIfPresent(Int64.self, forKey: .stateVersion)
planeID = try container.decodeIfPresent(Int.self, forKey: .planeID)
flightControl = try container.decodeIfPresent(DroneDockFlightControl.self, forKey: .flightControl)
orderFlightTaskID = try container.decodeIfPresent(Int.self, forKey: .orderFlightTaskID)
command = try container.decodeIfPresent(String.self, forKey: .command)
airportSN = try container.decodeIfPresent(String.self, forKey: .airportSN)