APP远程遥控推出页面释放权限集成-待测试
This commit is contained in:
@@ -229,7 +229,15 @@ class RemoteControlCubit extends Cubit<RemoteControlState> {
|
||||
void startControlLoop() {
|
||||
_timer?.cancel();
|
||||
_timer = Timer.periodic(const Duration(milliseconds: 100), (timer) {
|
||||
// 核心调用:直接把 state 里的实体丢给 repository
|
||||
// 🔥 安全检查:无权限或急停时不发送
|
||||
if (!state.hasPermission || state.isEmergency) {
|
||||
debugPrint('⚠️ [定时器] 跳过发送 - hasPermission=${state.hasPermission}, isEmergency=${state.isEmergency}');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
debugPrint('⏰ [定时器] 发送控制指令 - originX=${state.controlEntity.originX}, originY=${state.controlEntity.originY}');
|
||||
_logger.logWithLevel('真实的发送的实体 - originX: ${state.controlEntity.originX}, originY: ${state.controlEntity.originY}');
|
||||
_repository.sendControlMachineCmd(state.controlEntity);
|
||||
});
|
||||
emit(state.copyWith(status: RemoteControlStatus.controlling));
|
||||
@@ -264,16 +272,36 @@ class RemoteControlCubit extends Cubit<RemoteControlState> {
|
||||
}
|
||||
|
||||
void updateOriginY(int y) {
|
||||
debugPrint('📥 [updateOriginY] 收到参数 y=$y');
|
||||
final updatedEntity = state.controlEntity.copyWith(
|
||||
y: y,
|
||||
);
|
||||
debugPrint('📤 [updateOriginY] 创建 updatedEntity.y=${updatedEntity.originY}');
|
||||
emit(state.copyWith(controlEntity: updatedEntity));
|
||||
debugPrint('✅ [updateOriginY] emit 完成,当前 state.controlEntity.originY=${state.controlEntity.originY}');
|
||||
|
||||
// 🔥 关键修复:如果归零,立即发送停止指令,使用更新后的实体
|
||||
if (y == 0) {
|
||||
_logger.logWithLevel('🛑 [updateOriginY] 检测到归零,立即发送停止指令');
|
||||
debugPrint('🛑 [updateOriginY] 发送 updatedEntity: originX=${updatedEntity.originX}, originY=${updatedEntity.originY}');
|
||||
_repository.sendControlMachineCmd(updatedEntity);
|
||||
}
|
||||
}
|
||||
void updateOriginX(int x) {
|
||||
debugPrint('📥 [updateOriginX] 收到参数 x=$x');
|
||||
final updatedEntity = state.controlEntity.copyWith(
|
||||
x: x,
|
||||
);
|
||||
debugPrint('📤 [updateOriginX] 创建 updatedEntity.x=${updatedEntity.originX}');
|
||||
emit(state.copyWith(controlEntity: updatedEntity));
|
||||
debugPrint('✅ [updateOriginX] emit 完成,当前 state.controlEntity.originX=${state.controlEntity.originX}');
|
||||
|
||||
// 🔥 关键修复:如果归零,立即发送停止指令,使用更新后的实体
|
||||
if (x == 0) {
|
||||
_logger.logWithLevel('🛑 [updateOriginX] 检测到归零,立即发送停止指令');
|
||||
debugPrint('🛑 [updateOriginX] 发送 updatedEntity: originX=${updatedEntity.originX}, originY=${updatedEntity.originY}');
|
||||
_repository.sendControlMachineCmd(updatedEntity);
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 停止控制循环
|
||||
@@ -416,6 +444,10 @@ class RemoteControlCubit extends Cubit<RemoteControlState> {
|
||||
return 9999;
|
||||
}
|
||||
}
|
||||
//app退出远程遥控界面释放权限
|
||||
Future<bool> releasePermission(String platform) async {
|
||||
return await _repository.releasePermission(platform);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user