完成远程控制页面中点火和熄火的长按选中类别的业务层-待测试
完成远程控制页面中割刀的长按选中类别的操作业务层-待测试 完成远程控制页面中地盘的长按选中类别的操作-待测试
This commit is contained in:
@@ -17,6 +17,7 @@ abstract class RemoteControlRepository {
|
||||
|
||||
/// 新增:请求控制权限 (发送 0x04 指令)
|
||||
Future<bool> requestControlPermission(String deviceName, String deviceId);
|
||||
|
||||
/// 新增:响应控制权限 同意和拒绝(发送 0x05 指令)
|
||||
void respondPermission(bool bool, String deviceId);
|
||||
}
|
||||
|
||||
@@ -172,9 +172,6 @@ class RemoteControlCubit extends Cubit<RemoteControlState> {
|
||||
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<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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,25 +256,25 @@ class TopStatusBar extends StatelessWidget {
|
||||
_handleChassisAction(action, context);
|
||||
}
|
||||
|
||||
// 🔥 底盘的业务逻辑(左滑块)
|
||||
// 🔥 点火的业务逻辑(左滑块)
|
||||
void _handleChassisAction(String action, BuildContext context) {
|
||||
final cubit = context.read<RemoteControlCubit>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user