完善遥控权限、控制发送和急停反馈
This commit is contained in:
@@ -8,7 +8,7 @@ import 'package:maibu_satabot_v2/features/remote_control/presentation/bloc/remot
|
||||
/// 由调用方决定注入哪一个实现,UI 与控制语义代码零改动。
|
||||
///
|
||||
/// 段位值统一沿用远程遥控编码:上=1、中=0、下=2
|
||||
/// (割刀 1 抬 / 2 降、底盘 1 升 / 2 降、点火 1 点火 / 2 熄火,0 都是停止)。
|
||||
/// 割刀段位由 Cubit 映射为开1/关0/不操作2;底盘、点火编码不变。
|
||||
abstract interface class PvRobotCommandChannel {
|
||||
/// 前进 / 后退(左摇杆,-100~100,上推为正=前进)。
|
||||
void sendDriveY(int y);
|
||||
@@ -19,19 +19,19 @@ abstract interface class PvRobotCommandChannel {
|
||||
/// 底盘升降。
|
||||
void sendChassis(int cmd);
|
||||
|
||||
/// 割刀升降。
|
||||
/// 割刀滑块段位:1=上拨开启、2=下拨关闭、0=回中不操作。
|
||||
void sendMower(int cmd);
|
||||
|
||||
/// 点火 / 熄火。
|
||||
void sendIgnition(int cmd);
|
||||
|
||||
/// 紧急停止。
|
||||
void sendEmergencyStop(bool on);
|
||||
Future<bool> sendEmergencyStop(bool on);
|
||||
|
||||
/// 双轴归零(松手即停,安全底线)。
|
||||
Future<void> stopAllMovement();
|
||||
|
||||
/// 进入控制态:查询一次控制权限,并开始持续下发控制帧(默认 100ms 控制循环)。
|
||||
/// 进入控制态:查询一次控制权限,并开始持续下发控制帧(默认 250ms 控制循环)。
|
||||
void activate();
|
||||
|
||||
/// 退出控制态:归零、停止控制循环、释放控制权、复位权限。
|
||||
@@ -58,22 +58,22 @@ class RemoteControlRobotChannel implements PvRobotCommandChannel {
|
||||
void sendChassis(int cmd) => _cubit.sendChassisCommand(cmd);
|
||||
|
||||
@override
|
||||
void sendMower(int cmd) => _cubit.sendMowerCommand(cmd);
|
||||
void sendMower(int cmd) => _cubit.sendMowerSliderCommand(cmd);
|
||||
|
||||
@override
|
||||
void sendIgnition(int cmd) => _cubit.sendFireCommand(cmd);
|
||||
|
||||
@override
|
||||
void sendEmergencyStop(bool on) => _cubit.updateEmergency(on);
|
||||
Future<bool> sendEmergencyStop(bool on) => _cubit.updateEmergency(on);
|
||||
|
||||
@override
|
||||
Future<void> stopAllMovement() => _cubit.stopAllMovement();
|
||||
Future<void> stopAllMovement() => _cubit.stopAllMovement(reason: 'hud_stop');
|
||||
|
||||
@override
|
||||
void activate() {
|
||||
final cubit = _cubit;
|
||||
// 与远程遥控页一致:进控制态先「仅查询」一次控制权限(grabControl=false,
|
||||
// 只把接口结果如实同步到 hasPermission,不发 TCP 抢占),再启动 100ms 控制循环。
|
||||
// 只把接口结果如实同步到 hasPermission,不发 TCP 抢占),再启动 250ms 控制循环。
|
||||
// 无权限时控制循环会自动跳过发送,行为与极简模式完全相同。
|
||||
final deviceName = cubit.state.targetDevice?.deviceName;
|
||||
if (deviceName != null && deviceName.isNotEmpty) {
|
||||
@@ -90,11 +90,11 @@ class RemoteControlRobotChannel implements PvRobotCommandChannel {
|
||||
|
||||
@override
|
||||
Future<bool?> deactivate() async {
|
||||
// 先解除急停,避免 HUD 退出时残留 isEmergency=true,
|
||||
// 让下一次进入(含极简远程遥控页)控制循环被锁住无法运动。
|
||||
_cubit.updateEmergency(false);
|
||||
_cubit.cancelPermissionRequest();
|
||||
// 退出页面不再自动解除急停;只有明确的用户操作可发送 eStop=0。
|
||||
// 旧调用保留:_cubit.updateEmergency(false);
|
||||
// 停止指令无视权限强制发送,先归零再停循环,避免残留运动。
|
||||
await _cubit.stopAllMovement();
|
||||
await _cubit.stopAllMovement(reason: 'hud_deactivate');
|
||||
_cubit.stopControlLoop();
|
||||
// 与远程遥控页一致:退出释放远程控制权限(type=2),设备名取当前 targetDevice。
|
||||
final deviceId = _cubit.state.targetDevice?.deviceName;
|
||||
|
||||
Reference in New Issue
Block a user