diff options
| author | Patrick Venture <venture@google.com> | 2018-08-31 09:42:48 -0700 |
|---|---|---|
| committer | Patrick Venture <venture@google.com> | 2018-08-31 09:53:59 -0700 |
| commit | da4a5dd133b88ebfeb69e89d05b381f81ba70e50 (patch) | |
| tree | aa1b8dcd7ce1432491e20d8a110fe2f762b59908 /experiments | |
| parent | 40be36ac31a4756498a1f297324129fe1271b726 (diff) | |
| download | phosphor-pid-control-da4a5dd133b88ebfeb69e89d05b381f81ba70e50.tar.gz phosphor-pid-control-da4a5dd133b88ebfeb69e89d05b381f81ba70e50.zip | |
add .clang-format
Change-Id: I6627b5569c2e0f730be7331403218b823a2c622f
Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'experiments')
| -rw-r--r-- | experiments/drive.cpp | 68 |
1 files changed, 28 insertions, 40 deletions
diff --git a/experiments/drive.cpp b/experiments/drive.cpp index a6fbd9c..d73148a 100644 --- a/experiments/drive.cpp +++ b/experiments/drive.cpp @@ -14,16 +14,16 @@ * limitations under the License. */ -#include <iostream> -#include <memory> -#include <tuple> - #include "drive.hpp" #include "interfaces.hpp" #include "sensors/pluggable.hpp" -#include "sysfs/sysfswrite.hpp" #include "sysfs/sysfsread.hpp" +#include "sysfs/sysfswrite.hpp" + +#include <iostream> +#include <memory> +#include <tuple> using tstamp = std::chrono::high_resolution_clock::time_point; @@ -32,15 +32,13 @@ using tstamp = std::chrono::high_resolution_clock::time_point; #define DRIVE DRIVE_TIME #define MAX_PWM 255 -static std::unique_ptr<Sensor> Create( - std::string readpath, - std::string writepath) +static std::unique_ptr<Sensor> Create(std::string readpath, + std::string writepath) { return std::make_unique<PluggableSensor>( - readpath, - 0, /* default the timeout to disabled */ - std::make_unique<SysFsRead>(readpath), - std::make_unique<SysFsWrite>(writepath, 0, MAX_PWM)); + readpath, 0, /* default the timeout to disabled */ + std::make_unique<SysFsRead>(readpath), + std::make_unique<SysFsWrite>(writepath, 0, MAX_PWM)); } int64_t getAverage(std::tuple<tstamp, int64_t, int64_t>& values) @@ -68,12 +66,9 @@ bool valueClose(int64_t value, int64_t goal) return false; } -static void driveGoal( - int64_t& seriesCnt, - int64_t setPwm, - int64_t goal, - std::vector<std::tuple<tstamp, int64_t, int64_t>>& series, - std::vector<std::unique_ptr<Sensor>>& fanSensors) +static void driveGoal(int64_t& seriesCnt, int64_t setPwm, int64_t goal, + std::vector<std::tuple<tstamp, int64_t, int64_t>>& series, + std::vector<std::unique_ptr<Sensor>>& fanSensors) { bool reading = true; @@ -132,12 +127,9 @@ static void driveGoal( return; } -static void driveTime( - int64_t& seriesCnt, - int64_t setPwm, - int64_t goal, - std::vector<std::tuple<tstamp, int64_t, int64_t>>& series, - std::vector<std::unique_ptr<Sensor>>& fanSensors) +static void driveTime(int64_t& seriesCnt, int64_t setPwm, int64_t goal, + std::vector<std::tuple<tstamp, int64_t, int64_t>>& series, + std::vector<std::unique_ptr<Sensor>>& fanSensors) { using namespace std::literals::chrono_literals; @@ -162,8 +154,9 @@ static void driveTime( series.push_back(std::make_tuple(t1, n0, n1)); - auto duration = std::chrono::duration_cast<std::chrono::microseconds> - (t1 - t0).count(); + auto duration = + std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0) + .count(); if (duration >= (20000000us).count()) { reading = false; @@ -175,7 +168,8 @@ static void driveTime( int driveMain(void) { - /* Time series of the data, the timestamp after both are read and the values. */ + /* Time series of the data, the timestamp after both are read and the + * values. */ std::vector<std::tuple<tstamp, int64_t, int64_t>> series; int64_t seriesCnt = 0; /* in case vector count isn't constant time */ int drive = DRIVE; @@ -187,17 +181,11 @@ int driveMain(void) * --> 2 | 6 * --> 3 | 7 */ - std::vector<std::string> fans = - { - "/sys/class/hwmon/hwmon0/fan0_input", - "/sys/class/hwmon/hwmon0/fan4_input" - }; + std::vector<std::string> fans = {"/sys/class/hwmon/hwmon0/fan0_input", + "/sys/class/hwmon/hwmon0/fan4_input"}; - std::vector<std::string> pwms = - { - "/sys/class/hwmon/hwmon0/pwm0", - "/sys/class/hwmon/hwmon0/pwm4" - }; + std::vector<std::string> pwms = {"/sys/class/hwmon/hwmon0/pwm0", + "/sys/class/hwmon/hwmon0/pwm4"}; std::vector<std::unique_ptr<Sensor>> fanSensors; @@ -261,8 +249,9 @@ int driveMain(void) int64_t n0 = std::get<1>(t); int64_t n1 = std::get<2>(t); - auto duration = std::chrono::duration_cast<std::chrono::microseconds> - (ts - tp).count(); + auto duration = + std::chrono::duration_cast<std::chrono::microseconds>(ts - tp) + .count(); std::cout << duration << "us, " << n0 << ", " << n1 << "\n"; tp = ts; @@ -270,4 +259,3 @@ int driveMain(void) return 0; } - |

