add step parameter in onTapFunction.

Add dialogType parameter in WaterHeaterPresenceSensor and CeilingSensorDialog.
Update step parameter in FlushValueSelectorWidget.
Update step parameter in FunctionBloc and WaterHeaterFunctions.
Update step, unit, min, and max parameters in ACFunction subclasses.
This commit is contained in:
mohammad
2025-05-19 11:22:15 +03:00
parent 7f9d044f7e
commit 0d45a155e3
22 changed files with 938 additions and 728 deletions

View File

@ -14,6 +14,10 @@ abstract class ACFunction extends DeviceFunction<AcStatusModel> {
required super.operationName,
required super.icon,
required this.type,
super.step,
super.unit,
super.max,
super.min,
});
List<ACOperationalValue> getOperationalValues();
@ -75,26 +79,24 @@ class ModeFunction extends ACFunction {
}
class TempSetFunction extends ACFunction {
final int min;
final int max;
final int step;
TempSetFunction(
{required super.deviceId, required super.deviceName, required type})
: min = 160,
max = 300,
step = 1,
super(
TempSetFunction({
required super.deviceId,
required super.deviceName,
required super.type,
}) : super(
code: 'temp_set',
operationName: 'Set Temperature',
icon: Assets.assetsTempreture,
type: type,
min: 200,
max: 300,
step: 1,
unit: "°C",
);
@override
List<ACOperationalValue> getOperationalValues() {
List<ACOperationalValue> values = [];
for (int temp = min; temp <= max; temp += step) {
for (int temp = min!.toInt(); temp <= max!; temp += step!.toInt()) {
values.add(ACOperationalValue(
icon: Assets.assetsTempreture,
description: "${temp / 10}°C",
@ -104,7 +106,6 @@ class TempSetFunction extends ACFunction {
return values;
}
}
class LevelFunction extends ACFunction {
LevelFunction(
{required super.deviceId, required super.deviceName, required type})
@ -166,9 +167,10 @@ class ChildLockFunction extends ACFunction {
}
class CurrentTempFunction extends ACFunction {
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
final String unit = "°C";
CurrentTempFunction(
{required super.deviceId, required super.deviceName, required type})
@ -185,7 +187,7 @@ class CurrentTempFunction extends ACFunction {
@override
List<ACOperationalValue> getOperationalValues() {
List<ACOperationalValue> values = [];
for (int temp = min; temp <= max; temp += step) {
for (int temp = min.toInt(); temp <= max; temp += step.toInt()) {
values.add(ACOperationalValue(
icon: Assets.currentTemp,
description: "${temp / 10}°C",

View File

@ -6,10 +6,12 @@ class CpsOperationalValue {
final String description;
final dynamic value;
CpsOperationalValue({
required this.icon,
required this.description,
required this.value,
});
}
@ -94,9 +96,9 @@ final class CpsSensitivityFunction extends CpsFunctions {
icon: Assets.sensitivity,
);
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
static const _images = <String>[
Assets.sensitivityFeature1,
@ -115,10 +117,10 @@ final class CpsSensitivityFunction extends CpsFunctions {
@override
List<CpsOperationalValue> getOperationalValues() {
final values = <CpsOperationalValue>[];
for (var value = min; value <= max; value += step) {
for (var value = min; value <= max; value += step.toInt()) {
values.add(
CpsOperationalValue(
icon: _images[value],
icon: _images[value.toInt()],
description: '$value',
value: value,
),
@ -142,9 +144,9 @@ final class CpsMovingSpeedFunction extends CpsFunctions {
icon: Assets.speedoMeter,
);
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
@override
List<CpsOperationalValue> getOperationalValues() {
@ -173,9 +175,9 @@ final class CpsSpatialStaticValueFunction extends CpsFunctions {
icon: Assets.spatialStaticValue,
);
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
@override
List<CpsOperationalValue> getOperationalValues() {
@ -204,9 +206,9 @@ final class CpsSpatialMotionValueFunction extends CpsFunctions {
icon: Assets.spatialMotionValue,
);
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
@override
List<CpsOperationalValue> getOperationalValues() {
@ -375,9 +377,9 @@ final class CpsPresenceJudgementThrsholdFunction extends CpsFunctions {
icon: Assets.presenceJudgementThrshold,
);
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
@override
List<CpsOperationalValue> getOperationalValues() {
@ -406,9 +408,9 @@ final class CpsMotionAmplitudeTriggerThresholdFunction extends CpsFunctions {
icon: Assets.presenceJudgementThrshold,
);
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
@override
List<CpsOperationalValue> getOperationalValues() {

View File

@ -4,6 +4,11 @@ abstract class DeviceFunction<T> {
final String code;
final String operationName;
final String icon;
final double? step;
final String? unit;
final double? max;
final double? min;
DeviceFunction({
required this.deviceId,
@ -11,6 +16,10 @@ abstract class DeviceFunction<T> {
required this.code,
required this.operationName,
required this.icon,
this.step,
this.unit,
this.max,
this.min,
});
}
@ -22,6 +31,10 @@ class DeviceFunctionData {
final dynamic value;
final String? condition;
final String? valueDescription;
final double? step;
final String? unit;
final double? max;
final double? min;
DeviceFunctionData({
required this.entityId,
@ -31,6 +44,10 @@ class DeviceFunctionData {
required this.value,
this.condition,
this.valueDescription,
this.step,
this.unit,
this.max,
this.min,
});
Map<String, dynamic> toJson() {
@ -42,6 +59,10 @@ class DeviceFunctionData {
'value': value,
if (condition != null) 'condition': condition,
if (valueDescription != null) 'valueDescription': valueDescription,
if (step != null) 'step': step,
if (unit != null) 'unit': unit,
if (max != null) 'max': max,
if (min != null) 'min': min,
};
}
@ -54,6 +75,10 @@ class DeviceFunctionData {
value: json['value'],
condition: json['condition'],
valueDescription: json['valueDescription'],
step: json['step']?.toDouble(),
unit: json['unit'],
max: json['max']?.toDouble(),
min: json['min']?.toDouble(),
);
}
@ -68,7 +93,11 @@ class DeviceFunctionData {
other.operationName == operationName &&
other.value == value &&
other.condition == condition &&
other.valueDescription == valueDescription;
other.valueDescription == valueDescription &&
other.step == step &&
other.unit == unit &&
other.max == max &&
other.min == min;
}
@override
@ -79,6 +108,10 @@ class DeviceFunctionData {
operationName.hashCode ^
value.hashCode ^
condition.hashCode ^
valueDescription.hashCode;
valueDescription.hashCode ^
step.hashCode ^
unit.hashCode ^
max.hashCode ^
min.hashCode;
}
}

View File

@ -20,12 +20,11 @@ abstract class FlushFunctions
}
class FlushPresenceDelayFunction extends FlushFunctions {
final int min;
FlushPresenceDelayFunction({
required super.deviceId,
required super.deviceName,
required super.type,
}) : min = 0,
}) :
super(
code: FlushMountedPresenceSensorModel.codePresenceState,
operationName: 'Presence State',
@ -50,9 +49,9 @@ class FlushPresenceDelayFunction extends FlushFunctions {
}
class FlushSensiReduceFunction extends FlushFunctions {
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
FlushSensiReduceFunction({
required super.deviceId,
@ -80,8 +79,8 @@ class FlushSensiReduceFunction extends FlushFunctions {
}
class FlushNoneDelayFunction extends FlushFunctions {
final int min;
final int max;
final double min;
final double max;
final String unit;
FlushNoneDelayFunction({
@ -110,9 +109,9 @@ class FlushNoneDelayFunction extends FlushFunctions {
}
class FlushIlluminanceFunction extends FlushFunctions {
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
FlushIlluminanceFunction({
required super.deviceId,
@ -130,7 +129,7 @@ class FlushIlluminanceFunction extends FlushFunctions {
@override
List<FlushOperationalValue> getOperationalValues() {
List<FlushOperationalValue> values = [];
for (int lux = min; lux <= max; lux += step) {
for (int lux = min.toInt(); lux <= max; lux += step.toInt()) {
values.add(FlushOperationalValue(
icon: Assets.IlluminanceIcon,
description: "$lux Lux",
@ -142,9 +141,9 @@ class FlushIlluminanceFunction extends FlushFunctions {
}
class FlushOccurDistReduceFunction extends FlushFunctions {
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
FlushOccurDistReduceFunction({
required super.deviceId,
@ -173,9 +172,9 @@ class FlushOccurDistReduceFunction extends FlushFunctions {
// ==== then functions ====
class FlushSensitivityFunction extends FlushFunctions {
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
FlushSensitivityFunction({
required super.deviceId,
@ -203,9 +202,9 @@ class FlushSensitivityFunction extends FlushFunctions {
}
class FlushNearDetectionFunction extends FlushFunctions {
final int min;
final double min;
final double max;
final int step;
final double step;
final String unit;
FlushNearDetectionFunction({
@ -225,7 +224,7 @@ class FlushNearDetectionFunction extends FlushFunctions {
@override
List<FlushOperationalValue> getOperationalValues() {
final values = <FlushOperationalValue>[];
for (var value = min; value <= max; value += step) {
for (var value = min.toDouble(); value <= max; value += step) {
values.add(FlushOperationalValue(
icon: Assets.nobodyTime,
description: '$value $unit',
@ -237,9 +236,9 @@ class FlushNearDetectionFunction extends FlushFunctions {
}
class FlushMaxDetectDistFunction extends FlushFunctions {
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
final String unit;
FlushMaxDetectDistFunction({
@ -259,7 +258,7 @@ class FlushMaxDetectDistFunction extends FlushFunctions {
@override
List<FlushOperationalValue> getOperationalValues() {
final values = <FlushOperationalValue>[];
for (var value = min; value <= max; value += step) {
for (var value = min; value <= max; value += step.toInt()) {
values.add(FlushOperationalValue(
icon: Assets.nobodyTime,
description: '$value $unit',
@ -271,9 +270,9 @@ class FlushMaxDetectDistFunction extends FlushFunctions {
}
class FlushTargetConfirmTimeFunction extends FlushFunctions {
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
final String unit;
FlushTargetConfirmTimeFunction({
@ -293,7 +292,7 @@ class FlushTargetConfirmTimeFunction extends FlushFunctions {
@override
List<FlushOperationalValue> getOperationalValues() {
final values = <FlushOperationalValue>[];
for (var value = min; value <= max; value += step) {
for (var value = min.toDouble(); value <= max; value += step) {
values.add(FlushOperationalValue(
icon: Assets.nobodyTime,
description: '$value $unit',
@ -305,9 +304,9 @@ class FlushTargetConfirmTimeFunction extends FlushFunctions {
}
class FlushDisappeDelayFunction extends FlushFunctions {
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
final String unit;
FlushDisappeDelayFunction({
@ -327,7 +326,7 @@ class FlushDisappeDelayFunction extends FlushFunctions {
@override
List<FlushOperationalValue> getOperationalValues() {
final values = <FlushOperationalValue>[];
for (var value = min; value <= max; value += step) {
for (var value = min.toDouble(); value <= max; value += step) {
values.add(FlushOperationalValue(
icon: Assets.nobodyTime,
description: '$value $unit',
@ -339,9 +338,9 @@ class FlushDisappeDelayFunction extends FlushFunctions {
}
class FlushIndentLevelFunction extends FlushFunctions {
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
final String unit;
FlushIndentLevelFunction({
@ -361,7 +360,7 @@ class FlushIndentLevelFunction extends FlushFunctions {
@override
List<FlushOperationalValue> getOperationalValues() {
final values = <FlushOperationalValue>[];
for (var value = min; value <= max; value += step) {
for (var value = min.toDouble(); value <= max; value += step) {
values.add(FlushOperationalValue(
icon: Assets.nobodyTime,
description: '$value $unit',
@ -373,9 +372,9 @@ class FlushIndentLevelFunction extends FlushFunctions {
}
class FlushTriggerLevelFunction extends FlushFunctions {
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
final String unit;
FlushTriggerLevelFunction({
@ -395,7 +394,7 @@ class FlushTriggerLevelFunction extends FlushFunctions {
@override
List<FlushOperationalValue> getOperationalValues() {
final values = <FlushOperationalValue>[];
for (var value = min; value <= max; value += step) {
for (var value = min.toDouble(); value <= max; value += step) {
values.add(FlushOperationalValue(
icon: Assets.nobodyTime,
description: '$value $unit',

View File

@ -20,17 +20,16 @@ abstract class WaterHeaterFunctions
}
class WHRestartStatusFunction extends WaterHeaterFunctions {
final int min;
WHRestartStatusFunction({
required super.deviceId,
required super.deviceName,
required super.type,
}) : min = 0,
super(
}) : super(
code: 'relay_status',
operationName: 'Restart Status',
icon: Assets.refreshStatusIcon,
);
@override
List<WaterHeaterOperationalValue> getOperationalValues() {
@ -55,13 +54,11 @@ class WHRestartStatusFunction extends WaterHeaterFunctions {
}
class WHSwitchFunction extends WaterHeaterFunctions {
final int min;
WHSwitchFunction({
required super.deviceId,
required super.deviceName,
required super.type,
}) : min = 0,
super(
}) : super(
code: 'switch_1',
operationName: 'Switch',
icon: Assets.assetsAcPower,
@ -104,12 +101,11 @@ class TimerConfirmTimeFunction extends WaterHeaterFunctions {
}
class BacklightFunction extends WaterHeaterFunctions {
final int min;
BacklightFunction({
required super.deviceId,
required super.deviceName,
required super.type,
}) : min = 0,
}) :
super(
code: 'switch_backlight',
operationName: 'Backlight',

View File

@ -4,7 +4,7 @@ import 'package:syncrow_web/pages/routines/models/wps/wps_operational_value.dart
import 'package:syncrow_web/utils/constants/assets.dart';
abstract class WpsFunctions extends DeviceFunction<WallSensorModel> {
final String type;
final String type;
WpsFunctions({
required super.deviceId,
@ -13,6 +13,10 @@ abstract class WpsFunctions extends DeviceFunction<WallSensorModel> {
required super.operationName,
required super.icon,
required this.type,
super.step,
super.unit,
super.max,
super.min,
});
List<WpsOperationalValue> getOperationalValues();
@ -20,9 +24,13 @@ abstract class WpsFunctions extends DeviceFunction<WallSensorModel> {
// For far_detection (75-600cm in 75cm steps)
class FarDetectionFunction extends WpsFunctions {
final int min;
final int max;
final int step;
final double min;
@override
final double max;
@override
final double step;
@override
final String unit;
FarDetectionFunction(
@ -41,7 +49,7 @@ class FarDetectionFunction extends WpsFunctions {
@override
List<WpsOperationalValue> getOperationalValues() {
final values = <WpsOperationalValue>[];
for (var value = min; value <= max; value += step) {
for (var value = min; value <= max; value += step.toInt()) {
values.add(WpsOperationalValue(
icon: Assets.currentDistanceIcon,
description: '$value $unit',
@ -54,9 +62,9 @@ class FarDetectionFunction extends WpsFunctions {
// For presence_time (0-65535 minutes)
class PresenceTimeFunction extends WpsFunctions {
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
final String unit;
PresenceTimeFunction(
@ -86,9 +94,9 @@ class PresenceTimeFunction extends WpsFunctions {
// For motion_sensitivity_value (1-5 levels)
class MotionSensitivityFunction extends WpsFunctions {
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
MotionSensitivityFunction(
{required super.deviceId, required super.deviceName, required type})
@ -116,9 +124,9 @@ class MotionSensitivityFunction extends WpsFunctions {
}
class MotionLessSensitivityFunction extends WpsFunctions {
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
MotionLessSensitivityFunction(
{required super.deviceId, required super.deviceName, required type})
@ -171,8 +179,8 @@ class IndicatorFunction extends WpsFunctions {
}
class NoOneTimeFunction extends WpsFunctions {
final int min;
final int max;
final double min;
final double max;
final String unit;
NoOneTimeFunction(
@ -225,9 +233,9 @@ class PresenceStateFunction extends WpsFunctions {
}
class CurrentDistanceFunction extends WpsFunctions {
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
CurrentDistanceFunction(
{required super.deviceId, required super.deviceName, required type})
@ -244,11 +252,10 @@ class CurrentDistanceFunction extends WpsFunctions {
@override
List<WpsOperationalValue> getOperationalValues() {
List<WpsOperationalValue> values = [];
for (int cm = min; cm <= max; cm += step) {
for (int cm = min.toInt(); cm <= max; cm += step.toInt()) {
values.add(WpsOperationalValue(
icon: Assets.assetsTempreture,
description: "${cm}CM",
value: cm,
));
}
@ -257,9 +264,9 @@ class CurrentDistanceFunction extends WpsFunctions {
}
class IlluminanceValueFunction extends WpsFunctions {
final int min;
final int max;
final int step;
final double min;
final double max;
final double step;
IlluminanceValueFunction({
required super.deviceId,
@ -277,7 +284,7 @@ class IlluminanceValueFunction extends WpsFunctions {
@override
List<WpsOperationalValue> getOperationalValues() {
List<WpsOperationalValue> values = [];
for (int lux = min; lux <= max; lux += step) {
for (int lux = min.toInt(); lux <= max; lux += step.toInt()) {
values.add(WpsOperationalValue(
icon: Assets.IlluminanceIcon,
description: "$lux Lux",