蓝牙绑定设备+场站切换支持高清图层的一对一显示+设备实时状态的部分显示

This commit is contained in:
2026-09-02 16:58:45 +08:00
parent 61bce2c1cf
commit 5141d6e83f
10 changed files with 458 additions and 133 deletions

View File

@@ -262,12 +262,13 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
// 更新 _cachedGps
_cachedGps = GPSEntity(location.latitude!, location.longitude!);
// 更新 _cachedStatus 中的航向角和坐标(复用已有缓存或新建空壳)
// 更新 _cachedStatus 中的航向角、坐标、定位质量(复用已有缓存或新建空壳)
final base = _cachedStatus ?? RunningStatusEntity();
_cachedStatus = base.copyWith(
latitude: location.latitude!,
longitude: location.longitude!,
yaw: location.heading ?? base.yaw,
qual: _fixStatusToQual(location.fixStatus, base.qual),
);
// 500ms节流:与 TCP 0x02 时代逻辑一致
@@ -397,6 +398,24 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
_currentDeviceId = deviceId;
}
/// 🔥 将 MQTT location/post 的 fix_status 字符串映射为 qual 整数值
int _fixStatusToQual(String? fixStatus, int fallback) {
if (fixStatus == null) return fallback;
switch (fixStatus) {
case 'no_fix': return 0;
case 'single': return 1;
case 'dgnss': return 2;
case 'ins': return 3;
case 'rtk_fixed': return 4;
case 'rtk_float': return 5;
case 'single_no_heading': return 6;
case 'dgnss_no_heading': return 7;
case 'rtk_fixed_no_heading': return 8;
case 'rtk_float_no_heading': return 9;
default: return fallback;
}
}
// 🔥 节流发射:500ms到期后发射缓存的最新数据
void _emitCachedStatus() {
if (_cachedStatus != null && _cachedGps != null && !isClosed) {