完善遥控权限、控制发送和急停反馈
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import '../../../devices/domain/entities/running_status_entity.dart';
|
||||
|
||||
/// 光伏巡检机器人实时遥测数据(本批次为 Mock 假数据,后续可替换为 MQTT/TCP 真实来源)
|
||||
/// 光伏巡检机器人遥测数据;状态值缺失时保留 null,由 UI 展示未知。
|
||||
///
|
||||
/// 采用不可变对象 + copyWith,便于后续接入真实数据流时局部更新字段。
|
||||
@immutable
|
||||
@@ -15,7 +16,14 @@ class PvTelemetry {
|
||||
this.isAutoDriving = true,
|
||||
// 默认留空:具体文案由 UI 层按当前语言兜底(见 PvInfoColumn)
|
||||
this.taskStatus = '',
|
||||
this.speed = 0.3,
|
||||
this.speed,
|
||||
this.leftMeasuredRpm,
|
||||
this.rightMeasuredRpm,
|
||||
this.leftTargetRpm,
|
||||
this.rightTargetRpm,
|
||||
this.mowerRpm,
|
||||
this.motion,
|
||||
this.emergencyStop,
|
||||
this.mileage,
|
||||
this.networkNormal = true,
|
||||
this.temperature,
|
||||
@@ -39,8 +47,58 @@ class PvTelemetry {
|
||||
final bool isAutoDriving;
|
||||
final String taskStatus;
|
||||
|
||||
/// 当前速度 m/s
|
||||
final double speed;
|
||||
/// 当前线速度 m/s;负数表示倒车,null 表示未有效上报。
|
||||
final double? speed;
|
||||
final double? leftMeasuredRpm;
|
||||
final double? rightMeasuredRpm;
|
||||
final double? leftTargetRpm;
|
||||
final double? rightTargetRpm;
|
||||
|
||||
/// 车辆实时 cuttingSpeed / TCP 割刀转速;不使用本地启停指令推断。
|
||||
final double? mowerRpm;
|
||||
final String? motion;
|
||||
final bool? emergencyStop;
|
||||
|
||||
/// 每次从当前状态生成新快照,缺失字段不会沿用上帧数值或默认零值。
|
||||
factory PvTelemetry.fromRunningStatus(
|
||||
RunningStatusEntity? status, {
|
||||
String deviceName = '',
|
||||
bool obstacleAlert = false,
|
||||
}) {
|
||||
final raw = status?.hostRealtime?.rawData ?? const <String, dynamic>{};
|
||||
double? number(String field) {
|
||||
final value = raw[field];
|
||||
final parsed = value is num
|
||||
? value.toDouble()
|
||||
: double.tryParse(value?.toString() ?? '');
|
||||
return parsed != null && parsed.isFinite ? parsed : null;
|
||||
}
|
||||
|
||||
final cutter = double.tryParse(status?.knifeCuttingSpeed ?? '');
|
||||
final battery = number('battery_percentage');
|
||||
return PvTelemetry(
|
||||
deviceName: deviceName,
|
||||
obstacleAlert: obstacleAlert,
|
||||
battery: battery != null && battery >= 0 && battery <= 100
|
||||
? battery
|
||||
: null,
|
||||
mileage: number('total_work_distance'),
|
||||
temperature: number('main_temperature'),
|
||||
speed: number('linear_speed'),
|
||||
leftMeasuredRpm: number('left_measured_rpm'),
|
||||
rightMeasuredRpm: number('right_measured_rpm'),
|
||||
leftTargetRpm: number('left_target_rpm'),
|
||||
rightTargetRpm: number('right_target_rpm'),
|
||||
mowerRpm: cutter != null && cutter.isFinite ? cutter : null,
|
||||
motion: status?.hostRealtime?.motion,
|
||||
emergencyStop: status?.emergencyStop,
|
||||
controlMode: status?.controlMode,
|
||||
fixStatus: status?.qual,
|
||||
satelliteCount: status != null && status.satelliteCnt > 0
|
||||
? status.satelliteCnt
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
/// 巡检里程(累计作业里程);null=未收到实时数据(显示"未知")
|
||||
final double? mileage;
|
||||
@@ -79,6 +137,13 @@ class PvTelemetry {
|
||||
bool? isAutoDriving,
|
||||
String? taskStatus,
|
||||
double? speed,
|
||||
double? leftMeasuredRpm,
|
||||
double? rightMeasuredRpm,
|
||||
double? leftTargetRpm,
|
||||
double? rightTargetRpm,
|
||||
double? mowerRpm,
|
||||
String? motion,
|
||||
bool? emergencyStop,
|
||||
double? mileage,
|
||||
bool? networkNormal,
|
||||
double? temperature,
|
||||
@@ -98,6 +163,13 @@ class PvTelemetry {
|
||||
isAutoDriving: isAutoDriving ?? this.isAutoDriving,
|
||||
taskStatus: taskStatus ?? this.taskStatus,
|
||||
speed: speed ?? this.speed,
|
||||
leftMeasuredRpm: leftMeasuredRpm ?? this.leftMeasuredRpm,
|
||||
rightMeasuredRpm: rightMeasuredRpm ?? this.rightMeasuredRpm,
|
||||
leftTargetRpm: leftTargetRpm ?? this.leftTargetRpm,
|
||||
rightTargetRpm: rightTargetRpm ?? this.rightTargetRpm,
|
||||
mowerRpm: mowerRpm ?? this.mowerRpm,
|
||||
motion: motion ?? this.motion,
|
||||
emergencyStop: emergencyStop ?? this.emergencyStop,
|
||||
mileage: mileage ?? this.mileage,
|
||||
networkNormal: networkNormal ?? this.networkNormal,
|
||||
temperature: temperature ?? this.temperature,
|
||||
|
||||
Reference in New Issue
Block a user