mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
85 lines
2.2 KiB
Dart
85 lines
2.2 KiB
Dart
abstract class DeviceFunction<T> {
|
|
final String deviceId;
|
|
final String deviceName;
|
|
final String code;
|
|
final String operationName;
|
|
final String icon;
|
|
|
|
DeviceFunction({
|
|
required this.deviceId,
|
|
required this.deviceName,
|
|
required this.code,
|
|
required this.operationName,
|
|
required this.icon,
|
|
});
|
|
}
|
|
|
|
class DeviceFunctionData {
|
|
final String entityId;
|
|
final String actionExecutor;
|
|
final String functionCode;
|
|
final String operationName;
|
|
final dynamic value;
|
|
final String? condition;
|
|
final String? valueDescription;
|
|
|
|
DeviceFunctionData({
|
|
required this.entityId,
|
|
this.actionExecutor = 'device_issue',
|
|
required this.functionCode,
|
|
required this.operationName,
|
|
required this.value,
|
|
this.condition,
|
|
this.valueDescription,
|
|
});
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'entityId': entityId,
|
|
'actionExecutor': actionExecutor,
|
|
'function': functionCode,
|
|
'operationName': operationName,
|
|
'value': value,
|
|
if (condition != null) 'condition': condition,
|
|
if (valueDescription != null) 'valueDescription': valueDescription,
|
|
};
|
|
}
|
|
|
|
factory DeviceFunctionData.fromJson(Map<String, dynamic> json) {
|
|
return DeviceFunctionData(
|
|
entityId: json['entityId'],
|
|
actionExecutor: json['actionExecutor'] ?? 'function',
|
|
functionCode: json['function'],
|
|
operationName: json['operationName'],
|
|
value: json['value'],
|
|
condition: json['condition'],
|
|
valueDescription: json['valueDescription'],
|
|
);
|
|
}
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
if (identical(this, other)) return true;
|
|
|
|
return other is DeviceFunctionData &&
|
|
other.entityId == entityId &&
|
|
other.actionExecutor == actionExecutor &&
|
|
other.functionCode == functionCode &&
|
|
other.operationName == operationName &&
|
|
other.value == value &&
|
|
other.condition == condition &&
|
|
other.valueDescription == valueDescription;
|
|
}
|
|
|
|
@override
|
|
int get hashCode {
|
|
return entityId.hashCode ^
|
|
actionExecutor.hashCode ^
|
|
functionCode.hashCode ^
|
|
operationName.hashCode ^
|
|
value.hashCode ^
|
|
condition.hashCode ^
|
|
valueDescription.hashCode;
|
|
}
|
|
}
|