终于解决了 第二次作业之后的 路径不清除的问题 ,一直保留着上一次作业发送的完成点
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:get_it/get_it.dart';
|
||||
import 'package:isar_community/isar.dart';
|
||||
import 'package:maibu_satabot_v2/core/logging/i_logger_service.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/data/models/device_add_path_point_model.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/presentation/bloc/devices_cubit.dart';
|
||||
import '../../../../core/di/injection.dart';
|
||||
import '../../../../core/env/path_planning_config.dart';
|
||||
import '../../../../core/network/net_message_dispatcher.dart';
|
||||
@@ -235,6 +236,8 @@ class PathPlanner {
|
||||
// print("🗑️ 清空待发送队列,剩余 ${locationQueue.length} 个点");
|
||||
_logger.log("[清空待发送队列,剩余 ${locationQueue.length} 个点]");
|
||||
locationQueue.clear();
|
||||
final devicesCubit = sl<DevicesCubit>();
|
||||
devicesCubit.setArrivedLocation(0.0, 0.0);
|
||||
|
||||
var entity = new RoutePlanSendEntity(commandType: 0x01, pointCounts: 0, targetLatitude: 0, targetLongitude: 0, speed: 0);
|
||||
// print("📡 发送停止指令到设备...");
|
||||
|
||||
@@ -47,7 +47,6 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
|
||||
final ILoggerService _logger = GetIt.I<ILoggerService>();
|
||||
|
||||
|
||||
DevicesCubit(
|
||||
this.repository,
|
||||
this._getUserDeviceUseCase,
|
||||
@@ -232,7 +231,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
|
||||
// 🔥 关键修复 2:发起新连接
|
||||
// connect 方法内部会自动调用 _sendAuthPacket -> 获取设备列表 -> 自动订阅当前选中的设备
|
||||
// debugPrint('🔌 开始重新新连接 TCP,将自动订阅新设备:${device.deviceName}');
|
||||
// debugPrint('🔌 开始重新新连接 TCP,将自动订阅新设备:${device.deviceName}');
|
||||
_logger.logWithLevel('🔌 启动重新新连接 TCP,将自动订阅新设备:${device.deviceName}');
|
||||
await _tcpClient.connectBySwitch(host: TCPConsts.TCP_IP, port: TCPConsts.TCP_PORT, deviceName: device.deviceName);
|
||||
// 🔥 关键修复 3:重置设备状态 Bloc,清除旧设备图表数据
|
||||
@@ -354,12 +353,12 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
|
||||
// 开始路径规划
|
||||
Future<void> startRoutePlanning(Queue<DeviceAddPathPointModel> locationQueue) async {
|
||||
/// print("cubit层开始路径规划");
|
||||
/// print("cubit层开始路径规划");
|
||||
_logger.logWithLevel('开始路径规划');
|
||||
// 清空全局 Service 中的队列
|
||||
// _routePlanningUseCase.clearLocationQueue();
|
||||
final List<DeviceAddPathPointModel> pathList = locationQueue.toList();
|
||||
// print('✅ 队列转换为 List,长度:${pathList.length}');
|
||||
// print('✅ 队列转换为 List,长度:${pathList.length}');
|
||||
_logger.logWithLevel('队列转换为 List,长度:${pathList.length}');
|
||||
|
||||
_pathPlanningService.updateQueue(pathList);
|
||||
@@ -397,6 +396,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
Future<void> stopRoutePlanning() async {
|
||||
emit(state.copyWith(isLoading: true));
|
||||
final result = await _routePlanningUseCase.stopRoutePlanning();
|
||||
|
||||
// 🔥 重置 PathPlanningService 中的全局的队列
|
||||
_pathPlanningService.clear();
|
||||
result.fold((failure) => emit(state.copyWith(isLoading: false, errorMessage: failure.message ?? '停止失败')), (_) => emit(state.copyWith(isLoading: false)));
|
||||
@@ -418,7 +418,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
|
||||
void setArrivedLocation(double latitude, double longitude) {
|
||||
emit(state.copyWith(arriLatitude: latitude, arriLongitude: longitude));
|
||||
// print('✅ [DevicesCubit] 监听更新已完成到达位置:Lat=$latitude, Lng=$longitude');
|
||||
// print('✅ [DevicesCubit] 监听更新已完成到达位置:Lat=$latitude, Lng=$longitude');
|
||||
_logger.logWithLevel('✅ [DevicesCubit] 监听更新已完成到达位置:Lat=$latitude, Lng=$longitude');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user