完善遥控权限、控制发送和急停反馈

This commit is contained in:
2026-11-21 14:37:46 +08:00
parent c284aefc7d
commit 9a8a42a0a1
55 changed files with 5009 additions and 1308 deletions

View File

@@ -7,12 +7,40 @@ import '../../domain/entities/reverse_camera_data.dart';
enum RemoteControlStatus { initial, controlling, error }
/// 本次遥控会话的最后一次用户操作,不代表设备已执行。
enum MowerLastOperation { none, turnOn, turnOff }
enum PermissionRequestPhase {
idle,
checking,
sending,
waiting,
granted,
failed,
timedOut,
}
class RemoteControlState extends Equatable {
final RemoteControlStatus status;
final MachineControlStatusEntity controlEntity; // 控制业务实体
final MowerLastOperation lastMowerOperation;
final String? errorMessage;
final bool hasPermission; // 是否获得 0x12 权限
final PermissionRequestPhase permissionRequestPhase;
final String permissionFeedbackKey;
final int permissionFeedbackId;
bool get isPermissionRequestBusy =>
permissionRequestPhase == PermissionRequestPhase.checking ||
permissionRequestPhase == PermissionRequestPhase.sending ||
permissionRequestPhase == PermissionRequestPhase.waiting;
final bool isEmergency;
final bool hasEmergencyStatus;
/// 本地急停请求状态,不代表已取得设备动作确认。
final bool isEmergencyRequestPending;
final bool emergencyRequestFailed;
final String emergencyFeedbackKey;
final bool isLocked;
final int ping;
final int battery; //电池量
@@ -42,9 +70,17 @@ class RemoteControlState extends Equatable {
const RemoteControlState({
this.status = RemoteControlStatus.initial,
required this.controlEntity,
this.lastMowerOperation = MowerLastOperation.none,
this.errorMessage,
this.hasPermission = false,
this.permissionRequestPhase = PermissionRequestPhase.idle,
this.permissionFeedbackKey = '',
this.permissionFeedbackId = 0,
this.isEmergency = false,
this.hasEmergencyStatus = false,
this.isEmergencyRequestPending = false,
this.emergencyRequestFailed = false,
this.emergencyFeedbackKey = '',
this.isLocked = false,
this.ping = 0,
this.battery = 0,
@@ -70,9 +106,17 @@ class RemoteControlState extends Equatable {
RemoteControlState copyWith({
RemoteControlStatus? status,
MachineControlStatusEntity? controlEntity,
MowerLastOperation? lastMowerOperation,
String? errorMessage,
bool? hasPermission,
PermissionRequestPhase? permissionRequestPhase,
String? permissionFeedbackKey,
int? permissionFeedbackId,
bool? isEmergency,
bool? hasEmergencyStatus,
bool? isEmergencyRequestPending,
bool? emergencyRequestFailed,
String? emergencyFeedbackKey,
bool? isLocked,
int? ping,
int? battery,
@@ -90,15 +134,28 @@ class RemoteControlState extends Equatable {
bool? topRightIsExpanded,
bool? obstacleRecognitionFlag,
DeviceEntity? targetDevice,
bool clearTargetDevice = false,
String? updateType,
ReverseCameraData? reverseCamera,
}) {
return RemoteControlState(
status: status ?? this.status,
controlEntity: controlEntity ?? this.controlEntity,
lastMowerOperation: lastMowerOperation ?? this.lastMowerOperation,
errorMessage: errorMessage ?? this.errorMessage,
hasPermission: hasPermission ?? this.hasPermission,
permissionRequestPhase:
permissionRequestPhase ?? this.permissionRequestPhase,
permissionFeedbackKey:
permissionFeedbackKey ?? this.permissionFeedbackKey,
permissionFeedbackId: permissionFeedbackId ?? this.permissionFeedbackId,
isEmergency: isEmergency ?? this.isEmergency,
hasEmergencyStatus: hasEmergencyStatus ?? this.hasEmergencyStatus,
isEmergencyRequestPending:
isEmergencyRequestPending ?? this.isEmergencyRequestPending,
emergencyRequestFailed:
emergencyRequestFailed ?? this.emergencyRequestFailed,
emergencyFeedbackKey: emergencyFeedbackKey ?? this.emergencyFeedbackKey,
isLocked: isLocked ?? this.isLocked,
ping: ping ?? this.ping,
battery: battery ?? this.battery,
@@ -113,11 +170,14 @@ class RemoteControlState extends Equatable {
showRightPip: showRightPip ?? this.showRightPip,
runningStatusModel: runningStatusModel ?? this.runningStatusModel,
obstacleFlag: obstacleFlag ?? this.obstacleFlag,
hasReceivedStatusPush: hasReceivedStatusPush ?? this.hasReceivedStatusPush,
hasReceivedStatusPush:
hasReceivedStatusPush ?? this.hasReceivedStatusPush,
topRightIsExpanded: topRightIsExpanded ?? this.topRightIsExpanded,
obstacleRecognitionFlag:
obstacleRecognitionFlag ?? this.obstacleRecognitionFlag,
targetDevice: targetDevice ?? this.targetDevice,
targetDevice: clearTargetDevice
? null
: targetDevice ?? this.targetDevice,
updateType: updateType, // 不使用 ??,因为我们想要 null 的时候就是 null
reverseCamera: reverseCamera ?? this.reverseCamera,
);
@@ -127,9 +187,17 @@ class RemoteControlState extends Equatable {
List<Object?> get props => [
status,
controlEntity,
lastMowerOperation,
errorMessage,
hasPermission,
permissionRequestPhase,
permissionFeedbackKey,
permissionFeedbackId,
isEmergency,
hasEmergencyStatus,
isEmergencyRequestPending,
emergencyRequestFailed,
emergencyFeedbackKey,
isLocked,
ping,
battery,