完成远程控制页面中点火和熄火的长按选中类别的业务层-待测试

完成远程控制页面中割刀的长按选中类别的操作业务层-待测试
完成远程控制页面中地盘的长按选中类别的操作-待测试
This commit is contained in:
2026-03-18 09:53:04 +08:00
parent 68a45ee487
commit 14dd6bd292
4 changed files with 31 additions and 19 deletions

View File

@@ -17,6 +17,7 @@ abstract class RemoteControlRepository {
/// 新增:请求控制权限 (发送 0x04 指令) /// 新增:请求控制权限 (发送 0x04 指令)
Future<bool> requestControlPermission(String deviceName, String deviceId); Future<bool> requestControlPermission(String deviceName, String deviceId);
/// 新增:响应控制权限 同意和拒绝(发送 0x05 指令) /// 新增:响应控制权限 同意和拒绝(发送 0x05 指令)
void respondPermission(bool bool, String deviceId); void respondPermission(bool bool, String deviceId);
} }

View File

@@ -172,9 +172,6 @@ class RemoteControlCubit extends Cubit<RemoteControlState> {
void requestControlPermission() { void requestControlPermission() {
// 1. 关闭弹窗 // 1. 关闭弹窗
emit(state.copyWith(showPermissionRequestDialog: false)); emit(state.copyWith(showPermissionRequestDialog: false));
// 2. 这里执行你发送 0x12 指令的逻辑
// _sendProtocolData(0x12, ...);
} }
void toggleLeftPip() => emit(state.copyWith(showLeftPip: !state.showLeftPip)); void toggleLeftPip() => emit(state.copyWith(showLeftPip: !state.showLeftPip));
@@ -244,6 +241,20 @@ class RemoteControlCubit extends Cubit<RemoteControlState> {
}, },
); );
} }
/// 发送底盘指令
void sendChassisCommand(int i) {
updateFunction(lift: i);
}
/// 发送割刀指令
void sendMowerCommand(int i) {
updateFunction(mower: i);
}
/// 发送点火指令
void sendFireCommand(int i) {
//void updateFunction({int? mower, int? lift, int? ignition, bool? emergency})
// updateFunction(mower:0, lift: 0, ignition: i, emergency: false);
updateFunction(ignition: i);
}

View File

@@ -131,17 +131,17 @@ class CenterControlArea extends StatelessWidget {
case "start": case "start":
debugPrint('⬆️ 底盘 - 向上(例如:前进)'); debugPrint('⬆️ 底盘 - 向上(例如:前进)');
// TODO: 发送底盘前进指令 // TODO: 发送底盘前进指令
// cubit.sendChassisCommand(ChassisCommand.forward); cubit.sendChassisCommand(1);
break; break;
case "center": case "center":
debugPrint('️ 底盘 - 中间(例如:停止)'); debugPrint('️ 底盘 - 中间(例如:停止)');
// TODO: 发送底盘停止指令 // TODO: 发送底盘停止指令
// cubit.sendChassisCommand(ChassisCommand.stop); cubit.sendChassisCommand(0);
break; break;
case "end": case "end":
debugPrint('⬇️ 底盘 - 向下(例如:后退)'); debugPrint('⬇️ 底盘 - 向下(例如:后退)');
// TODO: 发送底盘后退指令 // TODO: 发送底盘后退指令
// cubit.sendChassisCommand(ChassisCommand.backward); cubit.sendChassisCommand(2);
break; break;
} }
} }
@@ -154,17 +154,17 @@ class CenterControlArea extends StatelessWidget {
case "start": case "start":
debugPrint('⬆️ 割刀 - 向上(例如:抬刀)'); debugPrint('⬆️ 割刀 - 向上(例如:抬刀)');
// TODO: 发送抬刀指令 // TODO: 发送抬刀指令
// cubit.sendMowerCommand(MowerCommand.lift); cubit.sendMowerCommand(1);
break; break;
case "center": case "center":
debugPrint('⏹️ 割刀 - 中间(例如:保持)'); debugPrint('⏹️ 割刀 - 中间(例如:保持)');
// TODO: 发送保持指令 // TODO: 发送保持指令
// cubit.sendMowerCommand(MowerCommand.hold); cubit.sendMowerCommand(0);
break; break;
case "end": case "end":
debugPrint('⬇️ 割刀 - 向下(例如:降刀)'); debugPrint('⬇️ 割刀 - 向下(例如:降刀)');
// TODO: 发送降刀指令 // TODO: 发送降刀指令
// cubit.sendMowerCommand(MowerCommand.lower); cubit.sendMowerCommand(2);
break; break;
} }
} }

View File

@@ -256,25 +256,25 @@ class TopStatusBar extends StatelessWidget {
_handleChassisAction(action, context); _handleChassisAction(action, context);
} }
// 🔥 底盘的业务逻辑(左滑块) // 🔥 点火的业务逻辑(左滑块)
void _handleChassisAction(String action, BuildContext context) { void _handleChassisAction(String action, BuildContext context) {
final cubit = context.read<RemoteControlCubit>(); final cubit = context.read<RemoteControlCubit>();
switch (action) { switch (action) {
case "start": case "start":
debugPrint('⬆️ 底盘 - 向上(例如:前进)'); debugPrint('⬆点火啊');
// TODO: 发送底盘前进指令 // TODO: 发送 🔥点火指令
// cubit.sendChassisCommand(ChassisCommand.forward); cubit.sendFireCommand(1);
break; break;
case "center": case "center":
debugPrint('️ 底盘 - 中间(例如:停止)'); debugPrint('️熄火');
// TODO: 发送底盘停止指令 // TODO: 发送点火停止指令
// cubit.sendChassisCommand(ChassisCommand.stop); cubit.sendFireCommand(0);
break; break;
case "end": case "end":
debugPrint('⬇️ 底盘 - 向下(例如:后退)'); debugPrint('⬇熄火)');
// TODO: 发送底盘后退指令 // TODO: 发送熄火后退指令
// cubit.sendChassisCommand(ChassisCommand.backward); cubit.sendFireCommand(2);
break; break;
} }
} }