From 14dd6bd29266f0e148ad6309a4c72f11689c972e Mon Sep 17 00:00:00 2001 From: Songzex <2402265378@qq.com> Date: Wed, 18 Mar 2026 09:53:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=BF=9C=E7=A8=8B=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E9=A1=B5=E9=9D=A2=E4=B8=AD=E7=82=B9=E7=81=AB=E5=92=8C?= =?UTF-8?q?=E7=86=84=E7=81=AB=E7=9A=84=E9=95=BF=E6=8C=89=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E7=B1=BB=E5=88=AB=E7=9A=84=E4=B8=9A=E5=8A=A1=E5=B1=82-?= =?UTF-8?q?=E5=BE=85=E6=B5=8B=E8=AF=95=20=E5=AE=8C=E6=88=90=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=E6=8E=A7=E5=88=B6=E9=A1=B5=E9=9D=A2=E4=B8=AD=E5=89=B2?= =?UTF-8?q?=E5=88=80=E7=9A=84=E9=95=BF=E6=8C=89=E9=80=89=E4=B8=AD=E7=B1=BB?= =?UTF-8?q?=E5=88=AB=E7=9A=84=E6=93=8D=E4=BD=9C=E4=B8=9A=E5=8A=A1=E5=B1=82?= =?UTF-8?q?-=E5=BE=85=E6=B5=8B=E8=AF=95=20=E5=AE=8C=E6=88=90=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=E6=8E=A7=E5=88=B6=E9=A1=B5=E9=9D=A2=E4=B8=AD=E5=9C=B0?= =?UTF-8?q?=E7=9B=98=E7=9A=84=E9=95=BF=E6=8C=89=E9=80=89=E4=B8=AD=E7=B1=BB?= =?UTF-8?q?=E5=88=AB=E7=9A=84=E6=93=8D=E4=BD=9C-=E5=BE=85=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../remote_control_repository.dart | 1 + .../bloc/remote_control_cubit.dart | 17 +++++++++++++--- .../widgets/center_control_area.dart | 12 +++++------ .../presentation/widgets/top_status_bar.dart | 20 +++++++++---------- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/lib/features/remote_control/domain/repositories/remote_control_repository.dart b/lib/features/remote_control/domain/repositories/remote_control_repository.dart index 6d3fdfc9..c26fa5df 100644 --- a/lib/features/remote_control/domain/repositories/remote_control_repository.dart +++ b/lib/features/remote_control/domain/repositories/remote_control_repository.dart @@ -17,6 +17,7 @@ abstract class RemoteControlRepository { /// 新增:请求控制权限 (发送 0x04 指令) Future requestControlPermission(String deviceName, String deviceId); + /// 新增:响应控制权限 同意和拒绝(发送 0x05 指令) void respondPermission(bool bool, String deviceId); } diff --git a/lib/features/remote_control/presentation/bloc/remote_control_cubit.dart b/lib/features/remote_control/presentation/bloc/remote_control_cubit.dart index e332648b..cd30fc79 100644 --- a/lib/features/remote_control/presentation/bloc/remote_control_cubit.dart +++ b/lib/features/remote_control/presentation/bloc/remote_control_cubit.dart @@ -172,9 +172,6 @@ class RemoteControlCubit extends Cubit { void requestControlPermission() { // 1. 关闭弹窗 emit(state.copyWith(showPermissionRequestDialog: false)); - - // 2. 这里执行你发送 0x12 指令的逻辑 - // _sendProtocolData(0x12, ...); } void toggleLeftPip() => emit(state.copyWith(showLeftPip: !state.showLeftPip)); @@ -244,6 +241,20 @@ class RemoteControlCubit extends Cubit { }, ); } +/// 发送底盘指令 + 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); + } diff --git a/lib/features/remote_control/presentation/widgets/center_control_area.dart b/lib/features/remote_control/presentation/widgets/center_control_area.dart index d06001db..1cb90a34 100644 --- a/lib/features/remote_control/presentation/widgets/center_control_area.dart +++ b/lib/features/remote_control/presentation/widgets/center_control_area.dart @@ -131,17 +131,17 @@ class CenterControlArea extends StatelessWidget { case "start": debugPrint('⬆️ 底盘 - 向上(例如:前进)'); // TODO: 发送底盘前进指令 - // cubit.sendChassisCommand(ChassisCommand.forward); + cubit.sendChassisCommand(1); break; case "center": debugPrint('️ 底盘 - 中间(例如:停止)'); // TODO: 发送底盘停止指令 - // cubit.sendChassisCommand(ChassisCommand.stop); + cubit.sendChassisCommand(0); break; case "end": debugPrint('⬇️ 底盘 - 向下(例如:后退)'); // TODO: 发送底盘后退指令 - // cubit.sendChassisCommand(ChassisCommand.backward); + cubit.sendChassisCommand(2); break; } } @@ -154,17 +154,17 @@ class CenterControlArea extends StatelessWidget { case "start": debugPrint('⬆️ 割刀 - 向上(例如:抬刀)'); // TODO: 发送抬刀指令 - // cubit.sendMowerCommand(MowerCommand.lift); + cubit.sendMowerCommand(1); break; case "center": debugPrint('⏹️ 割刀 - 中间(例如:保持)'); // TODO: 发送保持指令 - // cubit.sendMowerCommand(MowerCommand.hold); + cubit.sendMowerCommand(0); break; case "end": debugPrint('⬇️ 割刀 - 向下(例如:降刀)'); // TODO: 发送降刀指令 - // cubit.sendMowerCommand(MowerCommand.lower); + cubit.sendMowerCommand(2); break; } } diff --git a/lib/features/remote_control/presentation/widgets/top_status_bar.dart b/lib/features/remote_control/presentation/widgets/top_status_bar.dart index 4960210a..b0e25efb 100644 --- a/lib/features/remote_control/presentation/widgets/top_status_bar.dart +++ b/lib/features/remote_control/presentation/widgets/top_status_bar.dart @@ -256,25 +256,25 @@ class TopStatusBar extends StatelessWidget { _handleChassisAction(action, context); } - // 🔥 底盘的业务逻辑(左滑块) + // 🔥 点火的业务逻辑(左滑块) void _handleChassisAction(String action, BuildContext context) { final cubit = context.read(); switch (action) { case "start": - debugPrint('⬆️ 底盘 - 向上(例如:前进)'); - // TODO: 发送底盘前进指令 - // cubit.sendChassisCommand(ChassisCommand.forward); + debugPrint('⬆点火啊'); + // TODO: 发送 🔥点火指令 + cubit.sendFireCommand(1); break; case "center": - debugPrint('️ 底盘 - 中间(例如:停止)'); - // TODO: 发送底盘停止指令 - // cubit.sendChassisCommand(ChassisCommand.stop); + debugPrint('️熄火'); + // TODO: 发送点火停止指令 + cubit.sendFireCommand(0); break; case "end": - debugPrint('⬇️ 底盘 - 向下(例如:后退)'); - // TODO: 发送底盘后退指令 - // cubit.sendChassisCommand(ChassisCommand.backward); + debugPrint('⬇熄火)'); + // TODO: 发送熄火后退指令 + cubit.sendFireCommand(2); break; } }