mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 14:47:23 +00:00
Created FlushMountedPresenceSensorModel
model.
This commit is contained in:
@ -0,0 +1,99 @@
|
|||||||
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
|
||||||
|
|
||||||
|
class FlushMountedPresenceSensorModel {
|
||||||
|
FlushMountedPresenceSensorModel({
|
||||||
|
required this.presenceState,
|
||||||
|
required this.farDetection,
|
||||||
|
required this.illuminance,
|
||||||
|
required this.sensitivity,
|
||||||
|
required this.occurDistReduce,
|
||||||
|
required this.noneDelay,
|
||||||
|
required this.presenceDelay,
|
||||||
|
required this.nearDetection,
|
||||||
|
required this.sensiReduce,
|
||||||
|
required this.checkingResult,
|
||||||
|
});
|
||||||
|
|
||||||
|
static const String codePresenceState = 'presence_state';
|
||||||
|
static const String codeSensitivity = 'sensitivity';
|
||||||
|
static const String codeNearDetection = 'near_detection';
|
||||||
|
static const String codeFarDetection = 'far_detection';
|
||||||
|
static const String codeCheckingResult = 'checking_result';
|
||||||
|
static const String codePresenceDelay = 'presence_delay';
|
||||||
|
static const String codeNoneDelay = 'none_delay';
|
||||||
|
static const String codeOccurDistReduce = 'occur_dist_reduce';
|
||||||
|
static const String codeIlluminance = 'illum_value';
|
||||||
|
static const String codeSensiReduce = 'sensi_reduce';
|
||||||
|
|
||||||
|
String presenceState;
|
||||||
|
int sensitivity;
|
||||||
|
int nearDetection;
|
||||||
|
int farDetection;
|
||||||
|
String checkingResult;
|
||||||
|
int presenceDelay;
|
||||||
|
int noneDelay;
|
||||||
|
int occurDistReduce;
|
||||||
|
int illuminance;
|
||||||
|
int sensiReduce;
|
||||||
|
|
||||||
|
factory FlushMountedPresenceSensorModel.fromJson(List<Status> jsonList) {
|
||||||
|
String presenceState = 'none';
|
||||||
|
int sensitivity = 0;
|
||||||
|
int nearDetection = 0;
|
||||||
|
int farDetection = 0;
|
||||||
|
String checkingResult = 'none';
|
||||||
|
int presenceDelay = 0;
|
||||||
|
int noneDelay = 0;
|
||||||
|
int occurDistReduce = 0;
|
||||||
|
int illuminance = 0;
|
||||||
|
int sensiReduce = 0;
|
||||||
|
|
||||||
|
for (var status in jsonList) {
|
||||||
|
switch (status.code) {
|
||||||
|
case codePresenceState:
|
||||||
|
presenceState = status.value ?? 'presence';
|
||||||
|
break;
|
||||||
|
case codeSensitivity:
|
||||||
|
sensitivity = status.value ?? 0;
|
||||||
|
break;
|
||||||
|
case codeNearDetection:
|
||||||
|
nearDetection = status.value ?? 0;
|
||||||
|
break;
|
||||||
|
case codeFarDetection:
|
||||||
|
farDetection = status.value ?? 0;
|
||||||
|
break;
|
||||||
|
case codeCheckingResult:
|
||||||
|
checkingResult = status.value ?? 'check_success';
|
||||||
|
break;
|
||||||
|
case codePresenceDelay:
|
||||||
|
presenceDelay = status.value ?? 0;
|
||||||
|
break;
|
||||||
|
case codeNoneDelay:
|
||||||
|
noneDelay = status.value ?? 0;
|
||||||
|
break;
|
||||||
|
case codeOccurDistReduce:
|
||||||
|
occurDistReduce = status.value ?? 0;
|
||||||
|
break;
|
||||||
|
case codeIlluminance:
|
||||||
|
illuminance = status.value ?? 0;
|
||||||
|
break;
|
||||||
|
case codeSensiReduce:
|
||||||
|
sensiReduce = status.value ?? 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FlushMountedPresenceSensorModel(
|
||||||
|
presenceState: presenceState,
|
||||||
|
sensitivity: sensitivity,
|
||||||
|
nearDetection: nearDetection,
|
||||||
|
farDetection: farDetection,
|
||||||
|
checkingResult: checkingResult,
|
||||||
|
presenceDelay: presenceDelay,
|
||||||
|
noneDelay: noneDelay,
|
||||||
|
occurDistReduce: occurDistReduce,
|
||||||
|
illuminance: illuminance,
|
||||||
|
sensiReduce: sensiReduce,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user