mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
Refactor CPS functions to implement operational value generation with min, max, and step parameters.
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
extension _Helper on String {
|
||||
extension _Helper on String {
|
||||
String get correct => this;
|
||||
String get wrong => this;
|
||||
}
|
||||
@ -93,7 +93,6 @@ final class CpsSensitivityFunction extends CpsFunctions {
|
||||
}) : min = 1,
|
||||
max = 10,
|
||||
step = 1,
|
||||
scale = 0,
|
||||
super(
|
||||
code: 'sensitivity'.correct,
|
||||
operationName: 'Sensitivity',
|
||||
@ -103,7 +102,6 @@ final class CpsSensitivityFunction extends CpsFunctions {
|
||||
final int min;
|
||||
final int max;
|
||||
final int step;
|
||||
final int scale;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
@ -126,14 +124,29 @@ final class CpsMovingSpeedFunction extends CpsFunctions {
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
}) : min = 0,
|
||||
max = 32,
|
||||
step = 1,
|
||||
super(
|
||||
code: 'moving_speed',
|
||||
operationName: 'Moving Speed',
|
||||
icon: Assets.speedoMeter,
|
||||
);
|
||||
|
||||
final int min;
|
||||
final int max;
|
||||
final int step;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
return [];
|
||||
return List.generate(
|
||||
(max - min) ~/ step + 1,
|
||||
(index) => CpsOperationalValue(
|
||||
icon: Assets.speedoMeter,
|
||||
description: '${min + (index * step)}',
|
||||
value: min + (index * step),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,15 +155,29 @@ final class CpsSpatialStaticValueFunction extends CpsFunctions {
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
}) : min = 0,
|
||||
max = 255,
|
||||
step = 1,
|
||||
super(
|
||||
code: 'space_static_val'.correct,
|
||||
operationName: 'Spacial Static Value',
|
||||
icon: Assets.spatialStaticValue,
|
||||
);
|
||||
|
||||
final int min;
|
||||
final int max;
|
||||
final int step;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
// TODO: implement getOperationalValues
|
||||
throw UnimplementedError();
|
||||
return List.generate(
|
||||
(max - min) ~/ step + 1,
|
||||
(index) => CpsOperationalValue(
|
||||
icon: Assets.spatialStaticValue,
|
||||
description: '${min + (index * step)}',
|
||||
value: min + (index * step),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,15 +186,29 @@ final class CpsSpatialMotionValueFunction extends CpsFunctions {
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
}) : min = 0,
|
||||
max = 255,
|
||||
step = 1,
|
||||
super(
|
||||
code: 'space_move_val'.correct,
|
||||
operationName: 'Spatial Motion Value',
|
||||
icon: Assets.spatialMotionValue,
|
||||
);
|
||||
|
||||
final int min;
|
||||
final int max;
|
||||
final int step;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
// TODO: implement getOperationalValues
|
||||
throw UnimplementedError();
|
||||
return List.generate(
|
||||
(max - min) ~/ step + 1,
|
||||
(index) => CpsOperationalValue(
|
||||
icon: Assets.spatialMotionValue,
|
||||
description: '${min + (index * step)}',
|
||||
value: min + (index * step),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,15 +217,33 @@ final class CpsMaxDistanceOfDetectionFunction extends CpsFunctions {
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'moving_max_dis'.correct,
|
||||
}) : min = 0.0,
|
||||
max = 10.0,
|
||||
step = 0.5,
|
||||
super(
|
||||
code: 'moving_max_dis'.correct,
|
||||
operationName: 'Maximum Distance Of Detection',
|
||||
icon: Assets.currentDistanceIcon,
|
||||
);
|
||||
|
||||
final double min;
|
||||
final double max;
|
||||
final double step;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
// TODO: implement getOperationalValues
|
||||
throw UnimplementedError();
|
||||
final count = ((max - min) / step).round() + 1;
|
||||
return List.generate(
|
||||
count,
|
||||
(index) {
|
||||
final value = (min + (index * step));
|
||||
return CpsOperationalValue(
|
||||
icon: Assets.currentDistanceIcon,
|
||||
description: '${value.toStringAsFixed(1)}M',
|
||||
value: value,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,15 +252,33 @@ final class CpsMaxDistanceOfStaticDetectionFunction extends CpsFunctions {
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
}) : min = 0.0,
|
||||
max = 10.0,
|
||||
step = 0.5,
|
||||
super(
|
||||
code: 'static_max_dis'.correct,
|
||||
operationName: 'Maximum Distance Of Static Detection',
|
||||
icon: Assets.currentDistanceIcon,
|
||||
);
|
||||
|
||||
final double min;
|
||||
final double max;
|
||||
final double step;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
// TODO: implement getOperationalValues
|
||||
throw UnimplementedError();
|
||||
final count = ((max - min) / step).round() + 1;
|
||||
return List.generate(
|
||||
count,
|
||||
(index) {
|
||||
final value = (min + (index * step));
|
||||
return CpsOperationalValue(
|
||||
icon: Assets.currentDistanceIcon,
|
||||
description: '${value.toStringAsFixed(1)}M',
|
||||
value: value,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,15 +287,33 @@ final class CpsDetectionRangeFunction extends CpsFunctions {
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
}) : min = 0.0,
|
||||
max = 25.5,
|
||||
step = 0.1,
|
||||
super(
|
||||
code: 'moving_range'.correct,
|
||||
operationName: 'Detection Range',
|
||||
icon: Assets.farDetection,
|
||||
);
|
||||
|
||||
final double min;
|
||||
final double max;
|
||||
final double step;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
// TODO: implement getOperationalValues
|
||||
throw UnimplementedError();
|
||||
final count = ((max - min) / step).round() + 1;
|
||||
return List.generate(
|
||||
count,
|
||||
(index) {
|
||||
final value = (min + (index * step));
|
||||
return CpsOperationalValue(
|
||||
icon: Assets.farDetection,
|
||||
description: '${value.toStringAsFixed(1)}M',
|
||||
value: value,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,15 +322,33 @@ final class CpsDistanceOfMovingObjectsFunction extends CpsFunctions {
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
}) : min = 0.0,
|
||||
max = 25.5,
|
||||
step = 0.1,
|
||||
super(
|
||||
code: 'presence_range'.correct,
|
||||
operationName: 'Distance Of Moving Objects',
|
||||
icon: Assets.currentDistanceIcon,
|
||||
);
|
||||
|
||||
final double min;
|
||||
final double max;
|
||||
final double step;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
// TODO: implement getOperationalValues
|
||||
throw UnimplementedError();
|
||||
final count = ((max - min) / step).round() + 1;
|
||||
return List.generate(
|
||||
count,
|
||||
(index) {
|
||||
final value = (min + (index * step));
|
||||
return CpsOperationalValue(
|
||||
icon: Assets.currentDistanceIcon,
|
||||
description: '${value.toStringAsFixed(1)}M',
|
||||
value: value,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,15 +357,29 @@ final class CpsPresenceJudgementThrsholdFunction extends CpsFunctions {
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
}) : min = 0,
|
||||
max = 255,
|
||||
step = 5,
|
||||
super(
|
||||
code: 'presence_judgement_threshold'.wrong,
|
||||
operationName: 'Presence Judgement Threshold',
|
||||
icon: Assets.presenceJudgementThrshold,
|
||||
);
|
||||
|
||||
final int min;
|
||||
final int max;
|
||||
final int step;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
// TODO: implement getOperationalValues
|
||||
throw UnimplementedError();
|
||||
return List.generate(
|
||||
(max - min) ~/ step + 1,
|
||||
(index) => CpsOperationalValue(
|
||||
icon: Assets.presenceJudgementThrshold,
|
||||
description: '${min + (index * step)}',
|
||||
value: min + (index * step),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,15 +388,29 @@ final class CpsMotionAmplitudeTriggerThresholdFunction extends CpsFunctions {
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
}) : min = 0,
|
||||
max = 255,
|
||||
step = 5,
|
||||
super(
|
||||
code: 'motion_amplitude_trigger_threshold'.wrong,
|
||||
operationName: 'Motion Amplitude Trigger Threshold',
|
||||
icon: Assets.presenceJudgementThrshold,
|
||||
);
|
||||
|
||||
final int min;
|
||||
final int max;
|
||||
final int step;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
// TODO: implement getOperationalValues
|
||||
throw UnimplementedError();
|
||||
return List.generate(
|
||||
(max - min) ~/ step + 1,
|
||||
(index) => CpsOperationalValue(
|
||||
icon: Assets.presenceJudgementThrshold,
|
||||
description: '${min + (index * step)}',
|
||||
value: min + (index * step),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,15 +419,33 @@ final class CpsPerpetualBoundaryFunction extends CpsFunctions {
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
}) : min = 0.00,
|
||||
max = 5.00,
|
||||
step = 0.50,
|
||||
super(
|
||||
code: 'perceptual_boundary'.correct,
|
||||
operationName: 'Perpetual Boundary',
|
||||
icon: Assets.boundary,
|
||||
);
|
||||
|
||||
final double min;
|
||||
final double max;
|
||||
final double step;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
// TODO: implement getOperationalValues
|
||||
throw UnimplementedError();
|
||||
final count = ((max - min) / step).round() + 1;
|
||||
return List.generate(
|
||||
count,
|
||||
(index) {
|
||||
final value = (min + (index * step));
|
||||
return CpsOperationalValue(
|
||||
icon: Assets.boundary,
|
||||
description: '${value.toStringAsFixed(1)}M',
|
||||
value: value,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -295,15 +454,33 @@ final class CpsMotionTriggerBoundaryFunction extends CpsFunctions {
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
}) : min = 0.0,
|
||||
max = 5.0,
|
||||
step = 0.5,
|
||||
super(
|
||||
code: 'moving_boundary'.correct,
|
||||
operationName: 'Motion Trigger Boundary',
|
||||
icon: Assets.motionMeter,
|
||||
);
|
||||
|
||||
final double min;
|
||||
final double max;
|
||||
final double step;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
// TODO: implement getOperationalValues
|
||||
throw UnimplementedError();
|
||||
final count = ((max - min) / step).round() + 1;
|
||||
return List.generate(
|
||||
count,
|
||||
(index) {
|
||||
final value = (min + (index * step));
|
||||
return CpsOperationalValue(
|
||||
icon: Assets.motionMeter,
|
||||
description: '${value.toStringAsFixed(1)}M',
|
||||
value: value,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,15 +489,33 @@ final class CpsMotionTriggerTimeFunction extends CpsFunctions {
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
}) : min = 0.0,
|
||||
max = 2.0,
|
||||
step = 0.1,
|
||||
super(
|
||||
code: 'moving_rigger_time'.correct,
|
||||
operationName: 'Motion Trigger Time',
|
||||
icon: Assets.motionMeter,
|
||||
);
|
||||
|
||||
final double min;
|
||||
final double max;
|
||||
final double step;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
// TODO: implement getOperationalValues
|
||||
throw UnimplementedError();
|
||||
final count = ((max - min) / step).round() + 1;
|
||||
return List.generate(
|
||||
count,
|
||||
(index) {
|
||||
final value = (min + (index * step));
|
||||
return CpsOperationalValue(
|
||||
icon: Assets.motionMeter,
|
||||
description: '${value.toStringAsFixed(3)}sec',
|
||||
value: value,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -329,15 +524,33 @@ final class CpsMotionToStaticTimeFunction extends CpsFunctions {
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
}) : min = 0.0,
|
||||
max = 50.0,
|
||||
step = 1.0,
|
||||
super(
|
||||
code: 'moving_static_time'.correct,
|
||||
operationName: 'Motion To Static Time',
|
||||
icon: Assets.motionMeter,
|
||||
);
|
||||
|
||||
final double min;
|
||||
final double max;
|
||||
final double step;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
// TODO: implement getOperationalValues
|
||||
throw UnimplementedError();
|
||||
final count = ((max - min) / step).round() + 1;
|
||||
return List.generate(
|
||||
count,
|
||||
(index) {
|
||||
final value = (min + (index * step));
|
||||
return CpsOperationalValue(
|
||||
icon: Assets.motionMeter,
|
||||
description: '${value.toStringAsFixed(0)}s',
|
||||
value: value,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,15 +559,33 @@ final class CpsEnteringNoBodyStateTimeFunction extends CpsFunctions {
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
}) : min = 0.0,
|
||||
max = 300.0,
|
||||
step = 5.0,
|
||||
super(
|
||||
code: 'none_body_time',
|
||||
operationName: 'Entering Nobody State Time',
|
||||
icon: Assets.motionMeter,
|
||||
);
|
||||
|
||||
final double min;
|
||||
final double max;
|
||||
final double step;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
// TODO: implement getOperationalValues
|
||||
throw UnimplementedError();
|
||||
final count = ((max - min) / step).round() + 1;
|
||||
return List.generate(
|
||||
count,
|
||||
(index) {
|
||||
final value = (min + (index * step));
|
||||
return CpsOperationalValue(
|
||||
icon: Assets.motionMeter,
|
||||
description: '${value.toStringAsFixed(0)}sec',
|
||||
value: value,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -489,7 +720,7 @@ final class CpsMovementFunctions extends CpsFunctions {
|
||||
CpsOperationalValue(
|
||||
description: 'Close To',
|
||||
icon: Assets.closeToMotion,
|
||||
value: 'parlour',
|
||||
value: 'close_to',
|
||||
),
|
||||
CpsOperationalValue(
|
||||
description: 'Far Away',
|
||||
@ -618,14 +849,32 @@ final class CpsSportsParaFunction extends CpsFunctions {
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
}) : min = 1,
|
||||
max = 100,
|
||||
step = 1,
|
||||
super(
|
||||
code: 'sports_para'.correct,
|
||||
operationName: 'Sports Para',
|
||||
icon: Assets.sportsPara,
|
||||
);
|
||||
|
||||
final double min;
|
||||
final double max;
|
||||
final double step;
|
||||
|
||||
@override
|
||||
List<CpsOperationalValue> getOperationalValues() {
|
||||
// TODO: implement getOperationalValues
|
||||
throw UnimplementedError();
|
||||
final count = ((max - min) / step).round() + 1;
|
||||
return List.generate(
|
||||
count,
|
||||
(index) {
|
||||
final value = (min + (index * step));
|
||||
return CpsOperationalValue(
|
||||
icon: Assets.motionMeter,
|
||||
description: value.toStringAsFixed(0),
|
||||
value: value,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user