
enum CurtainModuleControl {
  open,
  close,
  stop,
}

// enum CurtainControlBackMode {
//   foward,
//   backward,
// }

class CurtainModuleStatusModel {
  CurtainModuleControl control;
  int percentControl;
  String curCalibration;
  // CurtainControlBackMode controlBackmode;
  int trTimeControl;
  String elecMachineryMode;
  String controlBack;
  CurtainModuleStatusModel({
    required this.control,
    required this.percentControl,
    required this.curCalibration,
    // required this.controlBackmode,
    required this.trTimeControl,
    required this.controlBack,
    required this.elecMachineryMode,
  });
  factory CurtainModuleStatusModel.zero() => CurtainModuleStatusModel(
        control: CurtainModuleControl.stop,
        percentControl: 0,
        // controlBackmode: CurtainControlBackMode.foward,
        curCalibration: '',
        trTimeControl: 0,
        controlBack: '',
        elecMachineryMode: '',
      );

  factory CurtainModuleStatusModel.fromJson(Map<String, dynamic> json) {
    return CurtainModuleStatusModel(
      control: CurtainModuleControl.values.firstWhere(
        (e) => e.toString() == json['control'] as String,
        orElse: () => CurtainModuleControl.stop,
      ),
      percentControl: json['percent_control'] as int? ?? 0,
      curCalibration: json['cur_calibration'] as String? ?? '',
      trTimeControl: json['tr_timecon'] as int? ?? 0,
      elecMachineryMode: json['elec_machinery_mode'] as String? ?? '',
      controlBack: json['control_back'] as String? ?? '',
    );
  }
}
