import 'package:equatable/equatable.dart';
import 'package:laki_icu_app/models/bo/device_control_bo.dart';
import 'package:laki_icu_app/utils/bluetooth/index.dart';

/// 用途：设备控制事件基类
abstract class DeviceControlEvent extends Equatable {
  const DeviceControlEvent();

  @override
  List<Object?> get props => [];
}

// ==================== 基础事件 ====================

/// 加载设备控制数据
class DeviceControlLoadRequested extends DeviceControlEvent {
  const DeviceControlLoadRequested();
}

/// 更新设备控制全部数据
class DeviceControlDataUpdated extends DeviceControlEvent {
  final DeviceControlBO data;

  const DeviceControlDataUpdated(this.data);

  @override
  List<Object?> get props => [data];
}

/// MCU上报数据同步到设备控制
class DeviceControlMcuReportFetched extends DeviceControlEvent {
  final McuReport report;

  const DeviceControlMcuReportFetched(this.report);

  @override
  List<Object?> get props => [report];
}

// ==================== 设备SN事件 ====================

/// 获取设备SN（从MCU获取）
class DeviceControlSnFetched extends DeviceControlEvent {
  final String? sn;

  const DeviceControlSnFetched(this.sn);

  @override
  List<Object?> get props => [sn];
}

/// 设置设备SN（用户配置，发送给MCU）
class DeviceControlSnChanged extends DeviceControlEvent {
  final String? sn;

  const DeviceControlSnChanged(this.sn);

  @override
  List<Object?> get props => [sn];
}

// ==================== 舱内温度控制事件 ====================

/// 获取舱内温度当前值（从MCU获取）
class DeviceControlCabinTempCurrentValueFetched extends DeviceControlEvent {
  final String currentValue;

  const DeviceControlCabinTempCurrentValueFetched(this.currentValue);

  @override
  List<Object?> get props => [currentValue];
}

/// 设置舱内温度设定值（用户配置，发送给MCU）
class DeviceControlCabinTempSetValueChanged extends DeviceControlEvent {
  final String setValue;

  const DeviceControlCabinTempSetValueChanged(this.setValue);

  @override
  List<Object?> get props => [setValue];
}

/// 调整舱内温度设定值（用户点击 -/+，发送给MCU）
class DeviceControlCabinTempSetValueAdjusted extends DeviceControlEvent {
  final int step;

  const DeviceControlCabinTempSetValueAdjusted(this.step);

  @override
  List<Object?> get props => [step];
}

/// 设置舱内温度开关
class DeviceControlCabinTempSwitchChanged extends DeviceControlEvent {
  final bool isOn;

  const DeviceControlCabinTempSwitchChanged(this.isOn);

  @override
  List<Object?> get props => [isOn];
}

// ==================== 舱内湿度控制事件 ====================

/// 获取舱内湿度当前值（从MCU获取）
class DeviceControlCabinHumidityCurrentValueFetched extends DeviceControlEvent {
  final String currentValue;

  const DeviceControlCabinHumidityCurrentValueFetched(this.currentValue);

  @override
  List<Object?> get props => [currentValue];
}

/// 设置舱内湿度设定值（用户配置，发送给MCU）
class DeviceControlCabinHumiditySetValueChanged extends DeviceControlEvent {
  final String setValue;

  const DeviceControlCabinHumiditySetValueChanged(this.setValue);

  @override
  List<Object?> get props => [setValue];
}

/// 调整舱内湿度设定值（用户点击 -/+，发送给MCU）
class DeviceControlCabinHumiditySetValueAdjusted extends DeviceControlEvent {
  final int step;

  const DeviceControlCabinHumiditySetValueAdjusted(this.step);

  @override
  List<Object?> get props => [step];
}

/// 设置舱内湿度开关
class DeviceControlCabinHumiditySwitchChanged extends DeviceControlEvent {
  final bool isOn;

  const DeviceControlCabinHumiditySwitchChanged(this.isOn);

  @override
  List<Object?> get props => [isOn];
}

// ==================== 氧气浓度控制事件 ====================

/// 获取氧气浓度当前值（从MCU获取）
class DeviceControlOxygenConcentrationCurrentValueFetched
    extends DeviceControlEvent {
  final String currentValue;

  const DeviceControlOxygenConcentrationCurrentValueFetched(this.currentValue);

  @override
  List<Object?> get props => [currentValue];
}

/// 设置氧气浓度设定值（用户配置，发送给MCU）
class DeviceControlOxygenConcentrationSetValueChanged
    extends DeviceControlEvent {
  final String setValue;

  const DeviceControlOxygenConcentrationSetValueChanged(this.setValue);

  @override
  List<Object?> get props => [setValue];
}

/// 调整氧气浓度设定值（用户点击 -/+，发送给MCU）
class DeviceControlOxygenConcentrationSetValueAdjusted
    extends DeviceControlEvent {
  final int step;

  const DeviceControlOxygenConcentrationSetValueAdjusted(this.step);

  @override
  List<Object?> get props => [step];
}

/// 设置氧气浓度开关
class DeviceControlOxygenConcentrationSwitchChanged extends DeviceControlEvent {
  final bool isOn;

  const DeviceControlOxygenConcentrationSwitchChanged(this.isOn);

  @override
  List<Object?> get props => [isOn];
}

// ==================== 二氧化碳浓度控制事件 ====================

/// 获取二氧化碳浓度当前值（从MCU获取）
class DeviceControlCO2ConcentrationCurrentValueFetched
    extends DeviceControlEvent {
  final String currentValue;

  const DeviceControlCO2ConcentrationCurrentValueFetched(this.currentValue);

  @override
  List<Object?> get props => [currentValue];
}

/// 设置二氧化碳浓度告警阈值（用户配置，发送给MCU）
class DeviceControlCO2ConcentrationAlarmThresholdChanged
    extends DeviceControlEvent {
  final String alarmThreshold;

  const DeviceControlCO2ConcentrationAlarmThresholdChanged(this.alarmThreshold);

  @override
  List<Object?> get props => [alarmThreshold];
}

/// 调整二氧化碳浓度设定值（用户点击 -/+，发送给MCU）
class DeviceControlCO2ConcentrationAlarmThresholdAdjusted
    extends DeviceControlEvent {
  final int step;

  const DeviceControlCO2ConcentrationAlarmThresholdAdjusted(this.step);

  @override
  List<Object?> get props => [step];
}

// ==================== 护理等级控制事件 ====================

/// 设置护理等级（用户配置，发送给MCU）
class DeviceControlCareLevelChanged extends DeviceControlEvent {
  final CareLevel level;

  const DeviceControlCareLevelChanged(this.level);

  @override
  List<Object?> get props => [level];
}

// ==================== 新风进化控制事件 ====================

/// 设置新风模式（用户配置，发送给MCU）
class DeviceControlFreshAirModeChanged extends DeviceControlEvent {
  final FreshAirMode mode;

  const DeviceControlFreshAirModeChanged(this.mode);

  @override
  List<Object?> get props => [mode];
}

// ==================== 风速调节控制事件 ====================

/// 设置风速模式（用户配置，发送给MCU）
class DeviceControlWindSpeedModeChanged extends DeviceControlEvent {
  final WindSpeedMode mode;

  const DeviceControlWindSpeedModeChanged(this.mode);

  @override
  List<Object?> get props => [mode];
}

// ==================== 雾化时间设置事件 ====================

/// 设置雾化时间（用户配置，发送给MCU）
class DeviceControlNebulizationTimeChanged extends DeviceControlEvent {
  final String minutes;

  const DeviceControlNebulizationTimeChanged(this.minutes);

  @override
  List<Object?> get props => [minutes];
}

// ==================== 消毒时间设置事件 ====================

/// 设置消毒时间（用户配置，发送给MCU）
class DeviceControlDisinfectionTimeChanged extends DeviceControlEvent {
  final String minutes;

  const DeviceControlDisinfectionTimeChanged(this.minutes);

  @override
  List<Object?> get props => [minutes];
}

// ==================== 开放供氧控制事件 ====================

/// 设置开放供氧开关（用户配置，发送给MCU）
class DeviceControlOpenOxygenSwitchChanged extends DeviceControlEvent {
  final bool isOn;

  const DeviceControlOpenOxygenSwitchChanged(this.isOn);

  @override
  List<Object?> get props => [isOn];
}

// ==================== 供氧计时事件 ====================

/// 更新供氧计时（从MCU获取）
class DeviceControlOxygenTimerUpdated extends DeviceControlEvent {
  final String hours;
  final String minutes;
  final String seconds;

  const DeviceControlOxygenTimerUpdated(this.hours, this.minutes, this.seconds);

  @override
  List<Object?> get props => [hours, minutes, seconds];
}

/// 清零供氧计时（用户操作）
class DeviceControlOxygenTimerCleared extends DeviceControlEvent {
  const DeviceControlOxygenTimerCleared();
}

// ==================== 循环模式控制事件 ====================

/// 设置循环模式（用户配置，发送给MCU）
class DeviceControlCirculationModeChanged extends DeviceControlEvent {
  final CirculationMode mode;

  const DeviceControlCirculationModeChanged(this.mode);

  @override
  List<Object?> get props => [mode];
}

// ==================== 灯光控制事件 ====================

/// 设置检查灯开关（用户配置，发送给MCU）
class DeviceControlCheckLightSwitchChanged extends DeviceControlEvent {
  final bool isOn;

  const DeviceControlCheckLightSwitchChanged(this.isOn);

  @override
  List<Object?> get props => [isOn];
}

/// 设置照明灯开关（用户配置，发送给MCU）
class DeviceControlIlluminationLightSwitchChanged extends DeviceControlEvent {
  final bool isOn;

  const DeviceControlIlluminationLightSwitchChanged(this.isOn);

  @override
  List<Object?> get props => [isOn];
}

/// 设置蓝光灯开关（用户配置，发送给MCU）
class DeviceControlBlueLightSwitchChanged extends DeviceControlEvent {
  final bool isOn;

  const DeviceControlBlueLightSwitchChanged(this.isOn);

  @override
  List<Object?> get props => [isOn];
}

/// 设置红光灯开关（用户配置，发送给MCU）
class DeviceControlRedLightSwitchChanged extends DeviceControlEvent {
  final bool isOn;

  const DeviceControlRedLightSwitchChanged(this.isOn);

  @override
  List<Object?> get props => [isOn];
}

// ==================== 全局统计数据事件 ====================

/// 更新总运行时长（从MCU获取）
class DeviceControlTotalRunTimeUpdated extends DeviceControlEvent {
  final String totalRunTime;

  const DeviceControlTotalRunTimeUpdated(this.totalRunTime);

  @override
  List<Object?> get props => [totalRunTime];
}

/// 更新环境温度（从MCU获取）
class DeviceControlEnvironmentTempUpdated extends DeviceControlEvent {
  final String environmentTemp;

  const DeviceControlEnvironmentTempUpdated(this.environmentTemp);

  @override
  List<Object?> get props => [environmentTemp];
}

/// 更新总制氧时长（从MCU获取）
class DeviceControlTotalOxygenTimeUpdated extends DeviceControlEvent {
  final String totalOxygenTime;

  const DeviceControlTotalOxygenTimeUpdated(this.totalOxygenTime);

  @override
  List<Object?> get props => [totalOxygenTime];
}

/// 初始化设备设置（用户操作，重置为默认值）
class DeviceControlResetSettings extends DeviceControlEvent {
  const DeviceControlResetSettings();
}
