Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: tools/battor_agent/battor_agent.cc

Issue 1586173002: tools/battor_agent: Prints real BattOr samples instead of raw ones (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@update_eeprom
Patch Set: Fixed size_t build error Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/battor_agent/battor_agent.h ('k') | tools/battor_agent/battor_agent_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/battor_agent/battor_agent.cc
diff --git a/tools/battor_agent/battor_agent.cc b/tools/battor_agent/battor_agent.cc
index 48ab7bd296e502e863ffc762a3f3fc4067b51dea..28ecee8d0a316cea80f05377c4210de83e702f88 100644
--- a/tools/battor_agent/battor_agent.cc
+++ b/tools/battor_agent/battor_agent.cc
@@ -4,9 +4,12 @@
#include "tools/battor_agent/battor_agent.h"
+#include <iomanip>
+
#include "base/bind.h"
#include "base/thread_task_runner_handle.h"
#include "tools/battor_agent/battor_connection_impl.h"
+#include "tools/battor_agent/battor_sample_converter.h"
using std::vector;
@@ -87,16 +90,6 @@ bool ParseSampleFrame(BattOrMessageType type,
return true;
}
-std::string SamplesToString(const vector<RawBattOrSample>& samples) {
- // TODO(charliea): Print the samples in a better trace format.
- std::stringstream trace_stream;
- for (auto sample : samples)
- trace_stream << sample.voltage_raw << "/" << sample.current_raw
- << std::endl;
-
- return trace_stream.str();
-}
-
} // namespace
BattOrAgent::BattOrAgent(
@@ -399,7 +392,7 @@ void BattOrAgent::CompleteCommand(BattOrError error) {
listener_->OnStartTracingComplete(error);
break;
case Command::STOP_TRACING: {
- listener_->OnStopTracingComplete(SamplesToString(samples_), error);
+ listener_->OnStopTracingComplete(SamplesToString(), error);
break;
}
case Command::INVALID:
@@ -413,4 +406,22 @@ void BattOrAgent::CompleteCommand(BattOrError error) {
samples_.clear();
}
+std::string BattOrAgent::SamplesToString() {
+ if (calibration_frame_.empty() || samples_.empty() || !battor_eeprom_)
+ return "";
+
+ BattOrSampleConverter converter(*battor_eeprom_, calibration_frame_);
+
+ std::stringstream trace_stream;
+ trace_stream << std::fixed;
+ for (size_t i = 0; i < samples_.size(); i++) {
+ BattOrSample sample = converter.ToSample(samples_[i], i);
+ trace_stream << std::setprecision(2) << sample.time_ms << " "
+ << std::setprecision(1) << sample.current_mA << " "
+ << sample.voltage_mV << std::endl;
+ }
+
+ return trace_stream.str();
+}
+
} // namespace battor
« no previous file with comments | « tools/battor_agent/battor_agent.h ('k') | tools/battor_agent/battor_agent_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698