From df760dd6ecb69aea999aeab891d9abe1c3d78f05 Mon Sep 17 00:00:00 2001 From: Leon Oostrum Date: Mon, 23 Oct 2023 16:38:22 +0200 Subject: [PATCH 1/2] Print sensor pair numbers in psconfig output. Closes #145 --- host/src/psconfig.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/host/src/psconfig.cc b/host/src/psconfig.cc index 396bca8..998b215 100644 --- a/host/src/psconfig.cc +++ b/host/src/psconfig.cc @@ -148,9 +148,10 @@ void print() { // get string values before printing the output so any warnings are readable std::string type = powerSensor->getType(sensor); - std::string pairName = powerSensor->getPairName(sensor / 2); // div by 2 to convert to pair ID + int pair = sensor / 2; // there are 2 sensors per pair + std::string pairName = powerSensor->getPairName(pair); - std::cout << "sensor " << sensor << " (" << sensorType << "): " + std::cout << "sensor " << sensor << ", pair " << pair << " (" << sensorType << "): " "type: " << type << ", " "name: " << pairName << ", " "Vref: " << powerSensor->getVref(sensor) << " V, " << @@ -162,7 +163,7 @@ void print() { for (unsigned int pair = 0; pair < PowerSensor3::MAX_PAIRS; pair++) { double usage = Watt(startState, stopState, pair); totalUsage += usage; - std::cout << "Current usage pair " << pair << ": " << usage << " W" << std::endl; + std::cout << "Current usage pair " << pair << " (sensors " << 2 * pair << ", " << 2 * pair + 1<< "): " << usage << " W" << std::endl; } std::cout << "Total usage: " << totalUsage << " W" << std::endl; } From f0c6e72ffcb29abcd450d296fe65fca7fc53b0b6 Mon Sep 17 00:00:00 2001 From: Leon Oostrum Date: Mon, 23 Oct 2023 16:40:25 +0200 Subject: [PATCH 2/2] Fix linter issue --- host/src/psconfig.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/host/src/psconfig.cc b/host/src/psconfig.cc index 998b215..fd6a2b7 100644 --- a/host/src/psconfig.cc +++ b/host/src/psconfig.cc @@ -163,7 +163,8 @@ void print() { for (unsigned int pair = 0; pair < PowerSensor3::MAX_PAIRS; pair++) { double usage = Watt(startState, stopState, pair); totalUsage += usage; - std::cout << "Current usage pair " << pair << " (sensors " << 2 * pair << ", " << 2 * pair + 1<< "): " << usage << " W" << std::endl; + std::cout << "Current usage pair " << pair << " (sensors " << 2 * pair << ", "; + std::cout << 2 * pair + 1<< "): " << usage << " W" << std::endl; } std::cout << "Total usage: " << totalUsage << " W" << std::endl; }