Files
flutterApp/lib/features/pv_control/presentation/models/pv_telemetry.dart

114 lines
3.6 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/foundation.dart';
/// 光伏巡检机器人实时遥测数据(本批次为 Mock 假数据,后续可替换为 MQTT/TCP 真实来源)
///
/// 采用不可变对象 + copyWith,便于后续接入真实数据流时局部更新字段。
@immutable
class PvTelemetry {
const PvTelemetry({
// 设备名占位留空:实际名称由页面注入(见 PvControlPage._resolveTelemetry),
// 避免写死中文在英文环境下露出来
this.deviceName = '',
this.serialNumber = 'PV-RB-001',
this.isOnline = true,
this.battery,
this.isAutoDriving = true,
// 默认留空:具体文案由 UI 层按当前语言兜底(见 PvInfoColumn)
this.taskStatus = '',
this.speed = 0.3,
this.mileage,
this.networkNormal = true,
this.temperature,
this.fixStatus,
this.satelliteCount,
this.controlMode,
this.resolution = '1920 × 1080',
this.fps = 30,
this.obstacleAlert = false,
this.obstacleDistance = 1.2,
});
final String deviceName;
final String serialNumber;
final bool isOnline;
/// 电量百分比 0~100;null=未收到实时数据(显示"未知")
final double? battery;
/// true=自动驾驶中,false=手动控制
final bool isAutoDriving;
final String taskStatus;
/// 当前速度 m/s
final double speed;
/// 巡检里程(累计作业里程);null=未收到实时数据(显示"未知")
final double? mileage;
/// 网络是否正常
final bool networkNormal;
/// 设备温度(实时主温度)℃;null=未收到实时数据(显示"未知")
final double? temperature;
/// 定位质量枚举值(来自 location/post 的 fix_status:4=RTK固定解);null=未知
final int? fixStatus;
/// 卫星数(realtime/post 尚未推送,目前无数据源);null=未知
final int? satelliteCount;
/// 当前控制模式原始值(host control_mode,拨杆:0无控制/1本地/2蓝牙/3TCP/4其他);null=未知
final String? controlMode;
final String resolution;
final int fps;
/// 是否障碍物预警。
/// 由机器推送驱动(真实接入前可用设置面板「模拟障碍物信息」手动触发);
/// 为 true 时预警横幅 + AR 障碍框 + 屏幕泛红呼吸同时展示,默认不亮。
final bool obstacleAlert;
/// 前方障碍距离 m
final double obstacleDistance;
PvTelemetry copyWith({
String? deviceName,
String? serialNumber,
bool? isOnline,
double? battery,
bool? isAutoDriving,
String? taskStatus,
double? speed,
double? mileage,
bool? networkNormal,
double? temperature,
int? fixStatus,
int? satelliteCount,
String? controlMode,
String? resolution,
int? fps,
bool? obstacleAlert,
double? obstacleDistance,
}) {
return PvTelemetry(
deviceName: deviceName ?? this.deviceName,
serialNumber: serialNumber ?? this.serialNumber,
isOnline: isOnline ?? this.isOnline,
battery: battery ?? this.battery,
isAutoDriving: isAutoDriving ?? this.isAutoDriving,
taskStatus: taskStatus ?? this.taskStatus,
speed: speed ?? this.speed,
mileage: mileage ?? this.mileage,
networkNormal: networkNormal ?? this.networkNormal,
temperature: temperature ?? this.temperature,
fixStatus: fixStatus ?? this.fixStatus,
satelliteCount: satelliteCount ?? this.satelliteCount,
controlMode: controlMode ?? this.controlMode,
resolution: resolution ?? this.resolution,
fps: fps ?? this.fps,
obstacleAlert: obstacleAlert ?? this.obstacleAlert,
obstacleDistance: obstacleDistance ?? this.obstacleDistance,
);
}
}