gs201: powerstats: Update for BP3A

Fix build after 1d0f96f0b1d3533ea2378d62559d1d73482c9d12

Change-Id: I9855f7b0e91f1f3d6b3e47354ec9617e5b3be277
This commit is contained in:
Michael Bestas
2025-11-21 19:02:13 +02:00
parent 775b886a3e
commit e77f34cf32

View File

@@ -69,17 +69,20 @@ class PlaceholderEnergyConsumer : public PowerStats::IEnergyConsumer {
}
std::pair<EnergyConsumerType, std::string> getInfo() override { return {kType, kName}; }
std::optional<EnergyConsumerResult> getEnergyConsumed() override {
std::optional<EnergyConsumerResult> getEnergyConsumed(
const std::vector<EnergyMeasurement> &energyData) override {
int64_t totalEnergyUWs = 0;
int64_t timestampMs = 0;
if (mChannelId != -1) {
std::vector<EnergyMeasurement> measurements;
if (mPowerStats->readEnergyMeter({mChannelId}, &measurements).isOk()) {
for (const auto &m : measurements) {
totalEnergyUWs += m.energyUWs;
timestampMs = m.timestampMs;
int found = 0;
for (const auto &e : energyData) {
if (mChannelId == e.id) {
totalEnergyUWs += e.energyUWs;
timestampMs = e.timestampMs;
found++;
}
} else {
}
if (found == 0) {
LOG(ERROR) << "Failed to read energy meter";
return {};
}