export type CarState =
  | 'idle'
  | 'running'
  | 'charging'
  | 'paused'
  | 'fault'
  | 'offline'

export interface Car {
  id: string
  rawId?: number
  name: string
  typeName: string
  x: number
  y: number
  theta: number
  batterySoc: number
  state: CarState
  missionId?: string
  lastUpdate: string
  group?: string
  address?: string
  ip?: string
  onboardUrl?: string
  lstatus?: string
  /** 运行时富化：报警文案（车体_AlarmInfo） */
  alarmInfo?: string
  /** 运行时富化：报警级别（>0 视为有报警） */
  alarmLevel?: number
  /** 运行时富化：交管摘要（畅通 / 正常拿锁 / 被 X 车阻塞 / 互锁） */
  trafficStatus?: string
  /** 运行时富化：当前锁点 / 占点摘要 */
  lockPoint?: string
  /** 运行时富化：当前站点 id（siteID，-1 表示无） */
  siteId?: number
}

/** 车队健康探测行（优先 GET /api/fleet/health；延迟为 WatchDog TCP RTT） */
export interface FleetHealthRow {
  carId: number
  carName?: string
  ip?: string
  onboardUrl?: string
  latencyMs?: number
  reachable?: boolean
  probedAt?: string
  uptimeSecs?: number
  alarmActiveSecs?: number
  faultRatePercent?: number
  isAlarmActive?: boolean
  cpuPercent?: number
  memPercent?: number
  /** watchdog | onboard | none */
  latencySource?: string
}

/** 车辆运维卡片合并模型 */
export interface VehicleCardModel extends Car {
  latencyMs?: number
  reachable?: boolean
  faultRatePercent?: number
  isAlarmActive?: boolean
  cpuPercent?: number
  memPercent?: number
  maintenanceMode?: 'online' | 'offline' | 'repair' | 'blown'
}
