fromJson static method
Returns a new AssetsMetricModbusTCP instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static AssetsMetricModbusTCP? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key),
'Required key "AssetsMetricModbusTCP[$key]" is missing from JSON.');
assert(json[key] != null,
'Required key "AssetsMetricModbusTCP[$key]" has a null value in JSON.');
});
return true;
}());
return AssetsMetricModbusTCP(
name: mapValueOfType<String>(json, r'name')!,
interval: mapValueOfType<int>(json, r'interval'),
topic: mapValueOfType<String>(json, r'topic')!,
retPolicy: RetPolicy.fromJson(json[r'ret_policy']) ?? RetPolicy.noagg6m,
memoryArea:
AssetsMetricModbusTCPMemoryAreaEnum.fromJson(json[r'memoryArea'])!,
dataType:
AssetsMetricModbusTCPDataTypeEnum.fromJson(json[r'dataType'])!,
memoryAddress: num.parse('${json[r'memoryAddress']}'),
permissions: MetricPermission.fromJson(json[r'permissions'])!,
accessLevel: AccessLevel.fromJson(json[r'accessLevel'])!,
category: MetricCategory.listFromJson(json[r'category']),
description: mapValueOfType<String>(json, r'description'),
byteOrder:
AssetsMetricModbusTCPByteOrderEnum.fromJson(json[r'byteOrder']),
min: json[r'min'] == null ? null : num.parse('${json[r'min']}'),
max: json[r'max'] == null ? null : num.parse('${json[r'max']}'),
unit: Unit.fromJson(json[r'unit']),
tags: Tags.fromJson(json[r'tags']),
activationEdge: AssetsMetricModbusTCPActivationEdgeEnum.fromJson(
json[r'activation_edge']),
timeout:
json[r'timeout'] == null ? null : num.parse('${json[r'timeout']}'),
priority: mapValueOfType<int>(json, r'priority'),
scale: json[r'scale'] == null ? null : num.parse('${json[r'scale']}'),
offset:
json[r'offset'] == null ? null : num.parse('${json[r'offset']}'),
);
}
return null;
}