Merge branch 'feature/my' of http://1.95.137.212:57001/APP/FlutterApp into feature/my
This commit is contained in:
@@ -65,7 +65,7 @@ class NetMessageDispatcher {
|
|||||||
/// 验证头部:data[0]=0xAB, data[1]=0xAA, data[2]=0x01
|
/// 验证头部:data[0]=0xAB, data[1]=0xAA, data[2]=0x01
|
||||||
/// 检查状态位:data[5] == 0x01 表示回复成功
|
/// 检查状态位:data[5] == 0x01 表示回复成功
|
||||||
Stream<RawPacket> onPathPlanningResponse() {
|
Stream<RawPacket> onPathPlanningResponse() {
|
||||||
|
final devicesCubit = sl<DevicesCubit>();
|
||||||
|
|
||||||
debugPrint('[Dispatcher] 开始监听路径规划指令应答 (CMD: 0x01)');
|
debugPrint('[Dispatcher] 开始监听路径规划指令应答 (CMD: 0x01)');
|
||||||
|
|
||||||
@@ -98,15 +98,23 @@ class NetMessageDispatcher {
|
|||||||
///取全局的路径规划发送实体 queue
|
///取全局的路径规划发送实体 queue
|
||||||
/// 发送下一个指令 移除上一条数据
|
/// 发送下一个指令 移除上一条数据
|
||||||
var queue = _pathPlanningService.getQueue();
|
var queue = _pathPlanningService.getQueue();
|
||||||
|
///更新完成jwd
|
||||||
|
var deviceAddPathPointModel = queue.first;
|
||||||
|
devicesCubit.setArrivedLocation(
|
||||||
|
deviceAddPathPointModel.latitude,
|
||||||
|
deviceAddPathPointModel.longitude
|
||||||
|
);
|
||||||
//去除上一条数据
|
//去除上一条数据
|
||||||
queue.removeFirst();
|
queue.removeFirst();
|
||||||
|
|
||||||
|
|
||||||
/// _pathPlanningService.updateQueue(queue as List<DeviceAddPathPointModel>);
|
/// _pathPlanningService.updateQueue(queue as List<DeviceAddPathPointModel>);
|
||||||
_pathPlanningService.updateQueue(queue.toList());
|
_pathPlanningService.updateQueue(queue.toList());
|
||||||
debugPrint('📡 [Dispatcher] 准备触发下一个路径点发送,队列剩余:${queue.length}');
|
debugPrint('📡 [Dispatcher] 准备触发下一个路径点发送,队列剩余:${queue.length}');
|
||||||
///如果还剩0个数据 就停止发送
|
///如果还剩0个数据 就停止发送
|
||||||
if (queue.length==0) {
|
if (queue.length==0) {
|
||||||
debugPrint('⚠️ [Dispatcher] 队列已空,停止发送');
|
debugPrint('⚠️ [Dispatcher] 队列已空,停止发送');
|
||||||
final devicesCubit = sl<DevicesCubit>();
|
// final devicesCubit = sl<DevicesCubit>();
|
||||||
devicesCubit.finishWork();
|
devicesCubit.finishWork();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -407,4 +407,19 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
void resetWorkStatus() {
|
void resetWorkStatus() {
|
||||||
emit(state.copyWith(isFinshWork: false));
|
emit(state.copyWith(isFinshWork: false));
|
||||||
}
|
}
|
||||||
|
void setArrivedLocation(double latitude, double longitude) {
|
||||||
|
emit(state.copyWith(arriLatitude: latitude, arriLongitude: longitude));
|
||||||
|
print('✅ [DevicesCubit] 更新已到达位置:Lat=$latitude, Lng=$longitude');
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取已到达的点的经纬度
|
||||||
|
(double, double) getArrivedLocation() {
|
||||||
|
return (state.arriLatitude ?? 0.0, state.arriLongitude ?? 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置已到达记录
|
||||||
|
void resetArrivedLocation() {
|
||||||
|
emit(state.copyWith(arriLatitude: null, arriLongitude: null));
|
||||||
|
print('🔄 [DevicesCubit] 已重置到达位置');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ class DevicesState extends Equatable {
|
|||||||
final List<DeviceAddPathPointModel>? generatedPath; // 新增字段
|
final List<DeviceAddPathPointModel>? generatedPath; // 新增字段
|
||||||
final AppState appState;
|
final AppState appState;
|
||||||
final bool isFinshWork;
|
final bool isFinshWork;
|
||||||
|
final double? arriLatitude;
|
||||||
|
final double? arriLongitude;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -43,7 +46,7 @@ class DevicesState extends Equatable {
|
|||||||
this.pathData,
|
this.pathData,
|
||||||
this.generatedPath,
|
this.generatedPath,
|
||||||
this.appState = AppState.none,
|
this.appState = AppState.none,
|
||||||
this.isFinshWork = false,
|
this.isFinshWork = false, this.arriLatitude, this.arriLongitude,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 使用 copyWith 方便局部更新状态
|
// 使用 copyWith 方便局部更新状态
|
||||||
@@ -60,6 +63,8 @@ class DevicesState extends Equatable {
|
|||||||
List<DeviceAddPathPointModel>? generatedPath,
|
List<DeviceAddPathPointModel>? generatedPath,
|
||||||
AppState? appState,
|
AppState? appState,
|
||||||
bool? isFinshWork,
|
bool? isFinshWork,
|
||||||
|
double? arriLatitude,
|
||||||
|
double? arriLongitude,
|
||||||
}) {
|
}) {
|
||||||
return DevicesState(
|
return DevicesState(
|
||||||
devices: devices ?? this.devices,
|
devices: devices ?? this.devices,
|
||||||
@@ -74,6 +79,8 @@ class DevicesState extends Equatable {
|
|||||||
generatedPath: generatedPath ?? this.generatedPath, // 更新生成的路径数据
|
generatedPath: generatedPath ?? this.generatedPath, // 更新生成的路径数据
|
||||||
appState: appState ?? this.appState, // 更新应用状态
|
appState: appState ?? this.appState, // 更新应用状态
|
||||||
isFinshWork: isFinshWork ?? this.isFinshWork,
|
isFinshWork: isFinshWork ?? this.isFinshWork,
|
||||||
|
arriLatitude: arriLatitude ?? this.arriLatitude,
|
||||||
|
arriLongitude: arriLongitude ?? this.arriLongitude,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +94,8 @@ class DevicesState extends Equatable {
|
|||||||
operationType,
|
operationType,
|
||||||
generatedPath,
|
generatedPath,
|
||||||
appState,
|
appState,
|
||||||
isFinshWork
|
isFinshWork,
|
||||||
|
arriLatitude,
|
||||||
|
arriLongitude
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user