作业首页和机器状态的数据

This commit is contained in:
2026-11-06 08:41:44 +08:00
parent d882db7995
commit 85c83ec143
41 changed files with 3702 additions and 656 deletions

View File

@@ -57,6 +57,9 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
// 🔥 当前 MQTT 机器状态监听的设备 SN(用于换设备时清空旧缓存)
String? _currentListeningSn;
/// 当前实时快照的设备身份,供入口模式确认使用(只读)。
String? get listeningDeviceSn => _currentListeningSn;
// 🔥 MQTT机器状态收帧计数(用于链路日志)
int _mqttVehicleFrameCount = 0;
int _mqttLocationFrameCount = 0;
@@ -322,8 +325,12 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
rightTargetSpeed: host.rightTargetRpm,
leftMeasureSpeed: host.leftMeasuredRpm,
rightMeasureSpeed: host.rightMeasuredRpm,
controlMode:
host.controlMode.isNotEmpty ? host.controlMode : base.controlMode,
// 严格按后端本帧给的值写:没带 control_mode 就置空(显示「未知」)。
// 以前写的是 host.controlMode.isNotEmpty ? ... : base.controlMode,
// 导致“后端已经不发控制模式了”界面仍永远停在第一次收到的值上。
// 代价:若 host 帧偶发漏带该字段,此栏会在真值与「未知」间跳动;
// 现场若出现闪烁,说明 host 帧字段不稳定,应从后端侧解决而非在此兜底。
controlMode: host.controlMode,
workingArea: host.totalWorkArea.toString(),
// 🔥 供全功能模式(pv_control)展示:累计作业里程 + host 已推数据标记
totalWorkDistance: host.totalWorkDistance,
@@ -486,7 +493,11 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
if (_cachedStatus != null && !isClosed) {
final gps = _cachedGps ??
GPSEntity(_cachedStatus!.latitude, _cachedStatus!.longitude);
debugPrint('📤 [节流发射] 电压=${_cachedStatus!.voltage}V 电量=${_cachedStatus!.battery}% 经纬度=(${gps.latitude}, ${gps.longitude}) yaw=${_cachedStatus!.yaw} 控制模式=${_cachedStatus!.controlMode} | ${DateTime.now().toString().substring(11, 19)}');
// 控制模式为空串 = 后端从未给过,日志里显式标出来,免得和 0 混看
final controlModeLog = _cachedStatus!.controlMode.isEmpty
? '--(未收到)'
: _cachedStatus!.controlMode;
debugPrint('📤 [节流发射] 电压=${_cachedStatus!.voltage}V 电量=${_cachedStatus!.battery}% 经纬度=(${gps.latitude}, ${gps.longitude}) yaw=${_cachedStatus!.yaw} 控制模式=$controlModeLog | ${DateTime.now().toString().substring(11, 19)}');
emit(DeviceStatusUpdated(_cachedStatus!, gps));
}
}