mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 01:56:24 +00:00
finished ac devices
This commit is contained in:
@ -1,25 +1,17 @@
|
||||
import 'package:syncrow_web/pages/device_managment/ac/model/ac_model.dart';
|
||||
import 'package:syncrow_web/pages/routiens/models/ac/ac_operational_value.dart';
|
||||
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
abstract class ACFunction extends DeviceFunction<AcStatusModel> {
|
||||
ACFunction({
|
||||
required String deviceId,
|
||||
required String deviceName,
|
||||
required String code,
|
||||
required String operationName,
|
||||
required String icon,
|
||||
}) : super(
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
code: code,
|
||||
operationName: operationName,
|
||||
icon: icon,
|
||||
);
|
||||
|
||||
@override
|
||||
AcStatusModel execute(AcStatusModel currentStatus, dynamic newValue);
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.code,
|
||||
required super.operationName,
|
||||
required super.icon,
|
||||
});
|
||||
|
||||
List<ACOperationalValue> getOperationalValues();
|
||||
}
|
||||
@ -32,11 +24,6 @@ class SwitchFunction extends ACFunction {
|
||||
icon: Assets.assetsAcPower,
|
||||
);
|
||||
|
||||
@override
|
||||
AcStatusModel execute(AcStatusModel currentStatus, dynamic newValue) {
|
||||
return currentStatus.copyWith(acSwitch: newValue as bool);
|
||||
}
|
||||
|
||||
@override
|
||||
List<ACOperationalValue> getOperationalValues() => [
|
||||
ACOperationalValue(
|
||||
@ -60,27 +47,22 @@ class ModeFunction extends ACFunction {
|
||||
icon: Assets.assetsFreezing,
|
||||
);
|
||||
|
||||
@override
|
||||
AcStatusModel execute(AcStatusModel currentStatus, dynamic newValue) {
|
||||
return currentStatus.copyWith(modeString: (newValue as TempModes).toString().split('.').last);
|
||||
}
|
||||
|
||||
@override
|
||||
List<ACOperationalValue> getOperationalValues() => [
|
||||
ACOperationalValue(
|
||||
icon: Assets.assetsAcCooling,
|
||||
description: "Cooling",
|
||||
value: TempModes.cold,
|
||||
value: TempModes.cold.name,
|
||||
),
|
||||
ACOperationalValue(
|
||||
icon: Assets.assetsAcHeating,
|
||||
description: "Heating",
|
||||
value: TempModes.hot,
|
||||
value: TempModes.hot.name,
|
||||
),
|
||||
ACOperationalValue(
|
||||
icon: Assets.assetsFanSpeed,
|
||||
description: "Ventilation",
|
||||
value: TempModes.wind,
|
||||
value: TempModes.wind.name,
|
||||
),
|
||||
];
|
||||
}
|
||||
@ -100,11 +82,6 @@ class TempSetFunction extends ACFunction {
|
||||
icon: Assets.assetsTempreture,
|
||||
);
|
||||
|
||||
@override
|
||||
AcStatusModel execute(AcStatusModel currentStatus, dynamic newValue) {
|
||||
return currentStatus.copyWith(tempSet: newValue as int);
|
||||
}
|
||||
|
||||
@override
|
||||
List<ACOperationalValue> getOperationalValues() {
|
||||
List<ACOperationalValue> values = [];
|
||||
@ -127,32 +104,27 @@ class LevelFunction extends ACFunction {
|
||||
icon: Assets.assetsFanSpeed,
|
||||
);
|
||||
|
||||
@override
|
||||
AcStatusModel execute(AcStatusModel currentStatus, dynamic newValue) {
|
||||
return currentStatus.copyWith(fanSpeedsString: (newValue as FanSpeeds).toString().split('.').last);
|
||||
}
|
||||
|
||||
@override
|
||||
List<ACOperationalValue> getOperationalValues() => [
|
||||
ACOperationalValue(
|
||||
icon: Assets.assetsAcFanLow,
|
||||
description: "LOW",
|
||||
value: FanSpeeds.low,
|
||||
value: FanSpeeds.low.name,
|
||||
),
|
||||
ACOperationalValue(
|
||||
icon: Assets.assetsAcFanMiddle,
|
||||
description: "MIDDLE",
|
||||
value: FanSpeeds.middle,
|
||||
value: FanSpeeds.middle.name,
|
||||
),
|
||||
ACOperationalValue(
|
||||
icon: Assets.assetsAcFanHigh,
|
||||
description: "HIGH",
|
||||
value: FanSpeeds.high,
|
||||
value: FanSpeeds.high.name,
|
||||
),
|
||||
ACOperationalValue(
|
||||
icon: Assets.assetsAcFanAuto,
|
||||
description: "AUTO",
|
||||
value: FanSpeeds.auto,
|
||||
value: FanSpeeds.auto.name,
|
||||
),
|
||||
];
|
||||
}
|
||||
@ -165,11 +137,6 @@ class ChildLockFunction extends ACFunction {
|
||||
icon: Assets.assetsChildLock,
|
||||
);
|
||||
|
||||
@override
|
||||
AcStatusModel execute(AcStatusModel currentStatus, dynamic newValue) {
|
||||
return currentStatus.copyWith(childLock: newValue as bool);
|
||||
}
|
||||
|
||||
@override
|
||||
List<ACOperationalValue> getOperationalValues() => [
|
||||
ACOperationalValue(
|
||||
@ -184,32 +151,3 @@ class ChildLockFunction extends ACFunction {
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
final deviceId = 'AC001';
|
||||
final deviceName = 'Living Room AC';
|
||||
|
||||
// Initial AC status
|
||||
var acStatus = AcStatusModel(
|
||||
uuid: deviceId,
|
||||
acSwitch: false,
|
||||
modeString: 'cold',
|
||||
tempSet: 220,
|
||||
currentTemp: 250,
|
||||
fanSpeedsString: 'auto',
|
||||
childLock: false,
|
||||
);
|
||||
|
||||
// Get all AC functions
|
||||
final acFunctions = getACFunctions(deviceId, deviceName);
|
||||
|
||||
// Example: Turn on the AC
|
||||
final switchFunction = acFunctions.firstWhere((f) => f is SwitchFunction) as SwitchFunction;
|
||||
acStatus = switchFunction.execute(acStatus, true);
|
||||
|
||||
// Example: Change mode to heat
|
||||
final modeFunction = acFunctions.firstWhere((f) => f is ModeFunction) as ModeFunction;
|
||||
acStatus = modeFunction.execute(acStatus, TempModes.hot);
|
||||
|
||||
*/
|
||||
|
Reference in New Issue
Block a user