mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
opt.: temperature parse
This commit is contained in:
@@ -2,17 +2,9 @@ class Temperatures {
|
|||||||
final Map<String, double> _map = {};
|
final Map<String, double> _map = {};
|
||||||
|
|
||||||
void parse(String type, String value) {
|
void parse(String type, String value) {
|
||||||
const noMatch = "/sys/class/thermal/thermal_zone*/type";
|
|
||||||
// Not support to get CPU temperature
|
|
||||||
if (type.contains(noMatch) || value.isEmpty || type.isEmpty) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final typeSplited = type.split('\n');
|
final typeSplited = type.split('\n');
|
||||||
final valueSplited = value.split('\n');
|
final valueSplited = value.split('\n');
|
||||||
if (typeSplited.length != valueSplited.length) {
|
for (var i = 0; i < typeSplited.length && i < valueSplited.length; i++) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (var i = 0; i < typeSplited.length; i++) {
|
|
||||||
final t = typeSplited[i];
|
final t = typeSplited[i];
|
||||||
final v = valueSplited[i];
|
final v = valueSplited[i];
|
||||||
if (t.isEmpty || v.isEmpty) {
|
if (t.isEmpty || v.isEmpty) {
|
||||||
@@ -27,10 +19,6 @@ class Temperatures {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(String name, double value) {
|
|
||||||
_map[name] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
double? get(String name) {
|
double? get(String name) {
|
||||||
return _map[name];
|
return _map[name];
|
||||||
}
|
}
|
||||||
@@ -56,4 +44,6 @@ class Temperatures {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final cpuTempReg = RegExp(r'(x86_pkg_temp|cpu_thermal)');
|
/// soc: mobile phone
|
||||||
|
/// cpu_thermal / x86_pkg_temp: x86
|
||||||
|
final cpuTempReg = RegExp(r'(x86_pkg_temp|cpu_thermal|soc)');
|
||||||
|
|||||||
Reference in New Issue
Block a user