#连接库初步完成
This commit is contained in:
@@ -1,88 +1,85 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:maibu_satabot_v2/features/remote_control/data/models/running_status_model.dart';
|
||||
|
||||
import '../../domain/entities/machine_control_status_entity.dart';
|
||||
import '../../domain/entities/machine_control_entity.dart';
|
||||
import '../../domain/entities/running_status_entity.dart';
|
||||
|
||||
enum RemoteControlStatus { initial, controlling, error }
|
||||
|
||||
enum ControlMode { TCP, BLE, LOCAL, NONE, OTHER }
|
||||
|
||||
class RemoteControlState extends Equatable {
|
||||
// --- 核心业务状态 ---
|
||||
final RemoteControlStatus status;
|
||||
final MachineControlStatusEntity controlEntity; // 控制业务实体
|
||||
final RunningStatusModel runningStatusModel;
|
||||
//状态业务实体
|
||||
final String? errorMessage;
|
||||
final bool hasPermission; // 是否获得了 0x12 权限
|
||||
final bool isEmergency;
|
||||
final bool isLocked;
|
||||
final int ping;
|
||||
final int battery;
|
||||
final int voltage;
|
||||
final String permissionPlatform;
|
||||
final String currentPlatform;
|
||||
final bool showPermissionRequestDialog;
|
||||
final bool showLeftPip;
|
||||
final bool showRightPip;
|
||||
final MachineControlEntity controlEntity; // 发送给机器的控制业务实体
|
||||
final RunningStatusEntity runningStatusEntity; // 机器回传的状态业务实体
|
||||
|
||||
final String obstacleFlag; //障碍物标志位
|
||||
// --- 权限与平台逻辑 ---
|
||||
final bool hasPermission; // 0x12 权限状态
|
||||
final String permissionPlatform; // 权限来源平台 (如 "Web", "App")
|
||||
final String currentPlatform; // 当前操作平台
|
||||
final bool showPermissionRequestDialog; // 是否显示权限请求弹窗
|
||||
|
||||
// --- 安全与锁定 ---
|
||||
final bool isEmergency; // 紧急停止状态
|
||||
final bool isLocked; // 控制锁定状态
|
||||
final String obstacleFlag; // 障碍物标志位文字 (对应 Entity 里的 0/1)
|
||||
|
||||
// --- 网络与连接 ---
|
||||
final int ping; // 延迟/心跳
|
||||
final String? errorMessage; // 错误提示
|
||||
|
||||
// --- UI 视图配置 ---
|
||||
final bool showLeftPip; // 左侧画中画显示
|
||||
final bool showRightPip; // 右侧画中画显示
|
||||
|
||||
const RemoteControlState({
|
||||
this.status = RemoteControlStatus.initial,
|
||||
required this.controlEntity,
|
||||
this.errorMessage,
|
||||
required this.runningStatusEntity,
|
||||
this.hasPermission = false,
|
||||
this.isEmergency = false,
|
||||
this.isLocked = false,
|
||||
this.ping = 0,
|
||||
this.battery = 0,
|
||||
this.voltage = 0,
|
||||
this.permissionPlatform = '',
|
||||
this.currentPlatform = '',
|
||||
this.showPermissionRequestDialog = false,
|
||||
this.isEmergency = false,
|
||||
this.isLocked = false,
|
||||
this.obstacleFlag = '无',
|
||||
this.ping = 0,
|
||||
this.errorMessage,
|
||||
this.showLeftPip = true,
|
||||
this.showRightPip = true,
|
||||
this.obstacleFlag = '',
|
||||
required this.runningStatusModel,
|
||||
});
|
||||
|
||||
// 方便 UI 更新部分属性
|
||||
// 辅助属性:判断当前是否具备物理驾驶条件
|
||||
bool get canDrive => hasPermission && !isEmergency && !isLocked;
|
||||
|
||||
RemoteControlState copyWith({
|
||||
RemoteControlStatus? status,
|
||||
MachineControlStatusEntity? controlEntity,
|
||||
String? errorMessage,
|
||||
MachineControlEntity? controlEntity,
|
||||
RunningStatusEntity? runningStatusEntity,
|
||||
bool? hasPermission,
|
||||
bool? isEmergency,
|
||||
bool? isLocked,
|
||||
int? ping,
|
||||
int? battery,
|
||||
int? voltage,
|
||||
String? permissionPlatform,
|
||||
String? currentPlatform,
|
||||
bool? showPermissionRequestDialog,
|
||||
bool? isEmergency,
|
||||
bool? isLocked,
|
||||
String? obstacleFlag,
|
||||
int? ping,
|
||||
String? errorMessage,
|
||||
bool? showLeftPip,
|
||||
bool? showRightPip,
|
||||
RunningStatusModel? runningStatusModel,
|
||||
String? obstacleFlag,
|
||||
}) {
|
||||
return RemoteControlState(
|
||||
status: status ?? this.status,
|
||||
controlEntity: controlEntity ?? this.controlEntity,
|
||||
errorMessage: errorMessage ?? this.errorMessage,
|
||||
runningStatusEntity: runningStatusEntity ?? this.runningStatusEntity,
|
||||
hasPermission: hasPermission ?? this.hasPermission,
|
||||
isEmergency: isEmergency ?? this.isEmergency,
|
||||
isLocked: isLocked ?? this.isLocked,
|
||||
ping: ping ?? this.ping,
|
||||
battery: battery ?? this.battery,
|
||||
voltage: voltage ?? this.voltage,
|
||||
permissionPlatform: permissionPlatform ?? this.permissionPlatform,
|
||||
currentPlatform: currentPlatform ?? this.currentPlatform,
|
||||
showPermissionRequestDialog:
|
||||
showPermissionRequestDialog ?? this.showPermissionRequestDialog,
|
||||
showPermissionRequestDialog: showPermissionRequestDialog ?? this.showPermissionRequestDialog,
|
||||
isEmergency: isEmergency ?? this.isEmergency,
|
||||
isLocked: isLocked ?? this.isLocked,
|
||||
obstacleFlag: obstacleFlag ?? this.obstacleFlag,
|
||||
ping: ping ?? this.ping,
|
||||
errorMessage: errorMessage ?? this.errorMessage,
|
||||
showLeftPip: showLeftPip ?? this.showLeftPip,
|
||||
showRightPip: showRightPip ?? this.showRightPip,
|
||||
runningStatusModel: runningStatusModel ?? this.runningStatusModel,
|
||||
obstacleFlag: obstacleFlag ?? this.obstacleFlag,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -90,19 +87,17 @@ class RemoteControlState extends Equatable {
|
||||
List<Object?> get props => [
|
||||
status,
|
||||
controlEntity,
|
||||
errorMessage,
|
||||
runningStatusEntity,
|
||||
hasPermission,
|
||||
isEmergency,
|
||||
isLocked,
|
||||
ping,
|
||||
battery,
|
||||
voltage,
|
||||
permissionPlatform,
|
||||
currentPlatform,
|
||||
showPermissionRequestDialog,
|
||||
isEmergency,
|
||||
isLocked,
|
||||
obstacleFlag,
|
||||
ping,
|
||||
errorMessage,
|
||||
showLeftPip,
|
||||
showRightPip,
|
||||
runningStatusModel,
|
||||
obstacleFlag,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user