| | |
| | | mowerNumber = incomingDeviceId; |
| | | } |
| | | |
| | | // 检查是否正在导航预览模式 |
| | | boolean isNavigating = checkIfNavigating(); |
| | | |
| | | String latitudeValue = sanitizeField(fields, 2); |
| | | String latitudeHemisphere = sanitizeField(fields, 3); |
| | | String longitudeValue = sanitizeField(fields, 4); |
| | | String longitudeHemisphere = sanitizeField(fields, 5); |
| | | |
| | | String combinedLatitude = combineCoordinate(latitudeValue, latitudeHemisphere); |
| | | if (hasMeaningfulValue(combinedLatitude)) { |
| | | realtimeLatitude = combinedLatitude; |
| | | } |
| | | String combinedLongitude = combineCoordinate(longitudeValue, longitudeHemisphere); |
| | | if (hasMeaningfulValue(combinedLongitude)) { |
| | | realtimeLongitude = combinedLongitude; |
| | | // 只有在非导航预览模式下才更新位置相关数据 |
| | | if (!isNavigating) { |
| | | String combinedLatitude = combineCoordinate(latitudeValue, latitudeHemisphere); |
| | | if (hasMeaningfulValue(combinedLatitude)) { |
| | | realtimeLatitude = combinedLatitude; |
| | | } |
| | | String combinedLongitude = combineCoordinate(longitudeValue, longitudeHemisphere); |
| | | if (hasMeaningfulValue(combinedLongitude)) { |
| | | realtimeLongitude = combinedLongitude; |
| | | } |
| | | |
| | | String altitudeValue = sanitizeField(fields, 9); |
| | | if (hasMeaningfulValue(altitudeValue)) { |
| | | realtimeAltitude = altitudeValue; |
| | | } |
| | | |
| | | // 更新位置坐标 |
| | | updateRelativeCoordinates(latitudeValue, latitudeHemisphere, longitudeValue, longitudeHemisphere); |
| | | |
| | | // 更新航向角(位置相关) |
| | | heading = defaultIfEmpty(sanitizeField(fields, 19)); |
| | | } |
| | | |
| | | String altitudeValue = sanitizeField(fields, 9); |
| | | if (hasMeaningfulValue(altitudeValue)) { |
| | | realtimeAltitude = altitudeValue; |
| | | } |
| | | |
| | | // 其他数据(电量、卫星数等)始终更新 |
| | | positioningStatus = defaultIfEmpty(sanitizeField(fields, 6)); |
| | | // 同步到绘制模块的数据源,保证往返绘制定时器能识别定位质量 |
| | | try { |
| | |
| | | battery = defaultIfEmpty(sanitizeField(fields, 16)); |
| | | pitch = defaultIfEmpty(sanitizeField(fields, 17)); |
| | | realtimeSpeed = defaultIfEmpty(sanitizeField(fields, 18)); |
| | | heading = defaultIfEmpty(sanitizeField(fields, 19)); |
| | | GupdateTime = String.valueOf(System.currentTimeMillis()); |
| | | |
| | | updateRelativeCoordinates(latitudeValue, latitudeHemisphere, longitudeValue, longitudeHemisphere); |
| | | } |
| | | |
| | | /**串口更新GNGGA数据*/ |
| | |
| | | return; |
| | | } |
| | | |
| | | |
| | | // 检查是否正在导航预览模式 |
| | | boolean isNavigating = checkIfNavigating(); |
| | | |
| | | String latitudeValue = sanitizeField(fields, 2); |
| | | String latitudeHemisphere = sanitizeField(fields, 3); |
| | | String longitudeValue = sanitizeField(fields, 4); |
| | | String longitudeHemisphere = sanitizeField(fields, 5); |
| | | |
| | | String combinedLatitude = combineCoordinate(latitudeValue, latitudeHemisphere); |
| | | if (hasMeaningfulValue(combinedLatitude)) { |
| | | realtimeLatitude = combinedLatitude; |
| | | } |
| | | String combinedLongitude = combineCoordinate(longitudeValue, longitudeHemisphere); |
| | | if (hasMeaningfulValue(combinedLongitude)) { |
| | | realtimeLongitude = combinedLongitude; |
| | | // 只有在非导航预览模式下才更新位置相关数据 |
| | | if (!isNavigating) { |
| | | String combinedLatitude = combineCoordinate(latitudeValue, latitudeHemisphere); |
| | | if (hasMeaningfulValue(combinedLatitude)) { |
| | | realtimeLatitude = combinedLatitude; |
| | | } |
| | | String combinedLongitude = combineCoordinate(longitudeValue, longitudeHemisphere); |
| | | if (hasMeaningfulValue(combinedLongitude)) { |
| | | realtimeLongitude = combinedLongitude; |
| | | } |
| | | |
| | | String altitudeValue = sanitizeField(fields, 9); |
| | | if (hasMeaningfulValue(altitudeValue)) { |
| | | realtimeAltitude = altitudeValue; |
| | | } |
| | | |
| | | // 更新位置坐标 |
| | | updateRelativeCoordinates(latitudeValue, latitudeHemisphere, longitudeValue, longitudeHemisphere); |
| | | |
| | | // 串口收到GNGGA数据后,触发拖尾更新 |
| | | notifyMowerTrailUpdate(); |
| | | } |
| | | |
| | | String altitudeValue = sanitizeField(fields, 9); |
| | | if (hasMeaningfulValue(altitudeValue)) { |
| | | realtimeAltitude = altitudeValue; |
| | | } |
| | | |
| | | // 其他数据(电量、卫星数等)始终更新 |
| | | positioningStatus = defaultIfEmpty(sanitizeField(fields, 6)); |
| | | // 同步到绘制模块的数据源,保证往返绘制定时器能识别定位质量 |
| | | try { |
| | |
| | | differentialAge = defaultIfEmpty(sanitizeField(fields, 13)); |
| | | realtimeSpeed ="0"; |
| | | GupdateTime = String.valueOf(System.currentTimeMillis()); |
| | | |
| | | updateRelativeCoordinates(latitudeValue, latitudeHemisphere, longitudeValue, longitudeHemisphere); |
| | | |
| | | // 串口收到GNGGA数据后,触发拖尾更新 |
| | | notifyMowerTrailUpdate(); |
| | | } |
| | | |
| | | /** |
| | | * 通知地图渲染器更新割草机拖尾 |
| | | * 当串口收到GNGGA数据并更新位置后调用 |
| | | */ |
| | | /** |
| | | * 检查是否正在导航预览模式 |
| | | * @return 如果正在导航预览返回true,否则返回false |
| | | */ |
| | | private boolean checkIfNavigating() { |
| | | try { |
| | | dikuai.daohangyulan nav = dikuai.daohangyulan.getInstance(); |
| | | if (nav != null) { |
| | | return nav.isNavigating(); |
| | | } |
| | | } catch (Exception e) { |
| | | // 如果获取导航实例失败,返回false(不影响主要功能) |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private void notifyMowerTrailUpdate() { |
| | | try { |
| | | // 通过Shouye.getInstance()获取实例,避免循环依赖 |