getHistory method
Gets history of type
('rate' or 'charge').
Implementation
Future<List<UPowerDeviceHistoryRecord>> getHistory(
String type, int resolution,
{int timespan = 0}) async {
var result = await _object.callMethod(
'org.freedesktop.UPower.Device',
'GetHistory',
[DBusString(type), DBusUint32(timespan), DBusUint32(resolution)],
replySignature: DBusSignature('a(udu)'));
var records = <UPowerDeviceHistoryRecord>[];
var children = (result.returnValues[0] as DBusArray)
.children
.map((e) => e as DBusStruct);
for (var child in children) {
var values = child.children.toList();
var time = (values[0] as DBusUint32).value;
var value = (values[1] as DBusDouble).value;
var state = UPowerDeviceState.values[(values[2] as DBusUint32).value];
records.add(UPowerDeviceHistoryRecord(time, value, state));
}
return records;
}