Files
flutterApp/lib/features/devices/presentation/bloc/device_task_state.dart
Songzex 06718ed957 集成双 MQTT 客户端实现设备实时数据监控(未测试)
1.集成两个独立的 MQTT 客户端,支持 WebSocket 和 TCP 协议
2.实现无人机/机场 OSD 实时监控(ws://1.95.137.212:8083/mqtt)
3.实现任务状态消息订阅(tcp://1.95.137.212:59020)
4.采用清洁架构设计,分层清晰(Domain → Data → Presentation)
2026-06-18 16:41:02 +08:00

66 lines
1.9 KiB
Dart

import 'package:equatable/equatable.dart';
import '../../domain/entities/device_task_entity.dart';
enum DeviceTaskOperationType {
none,
cancel,
pause,
recovery,
}
class DeviceTaskState extends Equatable {
final List<DeviceTaskEntity> taskPool;
final DeviceTaskEntity? currentTask;
final int? currentTaskId;
final List<DeviceTaskEntity> activeTasks; // 🔥 活跃任务列表(供用户选择)
final bool isLoading;
final String? errorMessage;
final DeviceTaskOperationType operationType;
final bool shouldShowError; // 🔥 标记是否需要显示错误弹窗
const DeviceTaskState({
this.taskPool = const [],
this.currentTask,
this.currentTaskId,
this.activeTasks = const [], // 🔥 默认空列表
this.isLoading = false,
this.errorMessage,
this.operationType = DeviceTaskOperationType.none,
this.shouldShowError = false,
});
DeviceTaskState copyWith({
List<DeviceTaskEntity>? taskPool,
DeviceTaskEntity? currentTask,
int? currentTaskId,
List<DeviceTaskEntity>? activeTasks, // 🔥 新增
bool? isLoading,
String? errorMessage,
DeviceTaskOperationType? operationType,
bool? shouldShowError,
}) {
return DeviceTaskState(
taskPool: taskPool ?? this.taskPool,
currentTask: currentTask ?? this.currentTask,
currentTaskId: currentTaskId ?? this.currentTaskId,
activeTasks: activeTasks ?? this.activeTasks, // 🔥 新增
isLoading: isLoading ?? this.isLoading,
errorMessage: errorMessage,
operationType: operationType ?? this.operationType,
shouldShowError: shouldShowError ?? false, // 🔥 默认重置为 false
);
}
@override
List<Object?> get props => [
taskPool,
currentTask,
currentTaskId,
activeTasks, // 🔥 新增
isLoading,
errorMessage,
operationType,
shouldShowError,
];
}