Files
flutterApp/lib/features/remote_control/presentation/bloc/remote_control_state.dart

129 lines
4.4 KiB
Dart
Raw Permalink Normal View History

2026-01-18 20:21:14 +08:00
import 'package:equatable/equatable.dart';
2026-01-27 18:44:49 +08:00
import '../../domain/entities/machine_control_entity.dart';
import '../../domain/entities/running_status_entity.dart';
2026-01-18 20:21:14 +08:00
enum RemoteControlStatus { initial, controlling, error }
class RemoteControlState extends Equatable {
2026-01-27 18:44:49 +08:00
// --- 核心业务状态 ---
2026-01-18 20:21:14 +08:00
final RemoteControlStatus status;
2026-01-27 18:44:49 +08:00
final MachineControlEntity controlEntity; // 发送给机器的控制业务实体
final RunningStatusEntity runningStatusEntity; // 机器回传的状态业务实体
// --- 权限与平台逻辑 ---
final bool hasPermission; // 0x12 权限状态
final String permissionPlatform; // 权限来源平台 (如 "Web", "App")
final String currentPlatform; // 当前操作平台
final bool showPermissionRequestDialog; // 是否显示权限请求弹窗
2026-01-21 13:27:55 +08:00
2026-01-27 18:44:49 +08:00
// --- 安全与锁定 ---
final bool isEmergency; // 紧急停止状态
final bool isLocked; // 控制锁定状态
2026-01-29 19:16:41 +08:00
final String obstacleFlag; // 障碍物标志位文字(这是机器传过来的) (对应 Entity 里的 0/1)
2026-01-27 18:44:49 +08:00
// --- 网络与连接 ---
final int ping; // 延迟/心跳
final String? errorMessage; // 错误提示
// --- UI 视图配置 ---
final bool showLeftPip; // 左侧画中画显示
final bool showRightPip; // 右侧画中画显示
2026-01-29 19:16:41 +08:00
final bool topRightIsExpanded; // 顶部右侧按钮展开状态
final bool obstacleRecognitionFlag; // 障碍物识别标志位(这是UI显示的)
final String mainStreamUrl;
final String aiStreamUrl;
final bool isVideoEnabled;
2026-01-18 20:21:14 +08:00
const RemoteControlState({
this.status = RemoteControlStatus.initial,
required this.controlEntity,
2026-01-27 18:44:49 +08:00
required this.runningStatusEntity,
2026-01-18 20:21:14 +08:00
this.hasPermission = false,
this.permissionPlatform = '',
this.currentPlatform = '',
this.showPermissionRequestDialog = false,
2026-01-27 18:44:49 +08:00
this.isEmergency = false,
this.isLocked = false,
this.obstacleFlag = '无',
this.ping = 0,
this.errorMessage,
2026-01-21 13:27:55 +08:00
this.showLeftPip = true,
this.showRightPip = true,
2026-01-29 19:16:41 +08:00
this.topRightIsExpanded = false,
this.obstacleRecognitionFlag = false,
this.mainStreamUrl = '',
this.aiStreamUrl = '',
this.isVideoEnabled = true
2026-01-18 20:21:14 +08:00
});
2026-01-27 18:44:49 +08:00
// 辅助属性:判断当前是否具备物理驾驶条件
2026-01-29 19:16:41 +08:00
bool get canDrive => hasPermission && !isLocked;
2026-01-27 18:44:49 +08:00
2026-01-18 20:21:14 +08:00
RemoteControlState copyWith({
RemoteControlStatus? status,
2026-01-27 18:44:49 +08:00
MachineControlEntity? controlEntity,
RunningStatusEntity? runningStatusEntity,
2026-01-18 20:21:14 +08:00
bool? hasPermission,
String? permissionPlatform,
String? currentPlatform,
bool? showPermissionRequestDialog,
2026-01-27 18:44:49 +08:00
bool? isEmergency,
bool? isLocked,
String? obstacleFlag,
int? ping,
String? errorMessage,
2026-01-21 13:27:55 +08:00
bool? showLeftPip,
bool? showRightPip,
2026-01-29 19:16:41 +08:00
bool? topRightIsExpanded,
bool? obstacleRecognitionFlag,
bool? isVideoEnabled,
String? mainStreamUrl,
String? aiStreamUrl
2026-01-18 20:21:14 +08:00
}) {
return RemoteControlState(
status: status ?? this.status,
controlEntity: controlEntity ?? this.controlEntity,
2026-01-27 18:44:49 +08:00
runningStatusEntity: runningStatusEntity ?? this.runningStatusEntity,
2026-01-18 20:21:14 +08:00
hasPermission: hasPermission ?? this.hasPermission,
2026-01-27 18:44:49 +08:00
permissionPlatform: permissionPlatform ?? this.permissionPlatform,
currentPlatform: currentPlatform ?? this.currentPlatform,
showPermissionRequestDialog: showPermissionRequestDialog ?? this.showPermissionRequestDialog,
2026-01-18 20:21:14 +08:00
isEmergency: isEmergency ?? this.isEmergency,
isLocked: isLocked ?? this.isLocked,
2026-01-27 18:44:49 +08:00
obstacleFlag: obstacleFlag ?? this.obstacleFlag,
2026-01-18 20:21:14 +08:00
ping: ping ?? this.ping,
2026-01-27 18:44:49 +08:00
errorMessage: errorMessage ?? this.errorMessage,
2026-01-21 13:27:55 +08:00
showLeftPip: showLeftPip ?? this.showLeftPip,
showRightPip: showRightPip ?? this.showRightPip,
2026-01-29 19:16:41 +08:00
topRightIsExpanded: topRightIsExpanded ?? this.topRightIsExpanded,
obstacleRecognitionFlag: obstacleRecognitionFlag ?? this.obstacleRecognitionFlag,
isVideoEnabled: isVideoEnabled ?? this.isVideoEnabled,
mainStreamUrl: mainStreamUrl ?? this.mainStreamUrl,
aiStreamUrl: aiStreamUrl ?? this.aiStreamUrl
2026-01-18 20:21:14 +08:00
);
}
@override
List<Object?> get props => [
status,
controlEntity,
2026-01-27 18:44:49 +08:00
runningStatusEntity,
2026-01-18 20:21:14 +08:00
hasPermission,
permissionPlatform,
currentPlatform,
showPermissionRequestDialog,
2026-01-27 18:44:49 +08:00
isEmergency,
isLocked,
obstacleFlag,
ping,
errorMessage,
2026-01-21 13:27:55 +08:00
showLeftPip,
showRightPip,
2026-01-29 19:16:41 +08:00
topRightIsExpanded,
obstacleRecognitionFlag,
isVideoEnabled,
mainStreamUrl,
aiStreamUrl
2026-01-18 20:21:14 +08:00
];
2026-01-27 18:44:49 +08:00
}