From 0e75299c201137812f0cb6a73132fc6e4da8acf5 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 27 Sep 2022 22:50:01 +0200 Subject: [PATCH] Cleanup, more documentation --- app/include/fan/HwmonFan.h | 1 + app/include/pwm/PWMControlFacade.h | 2 -- app/src/fan/HwmonFan.cxx | 2 +- app/src/main.cxx | 10 +----- doc/Class.plantuml | 55 ++++++++++++++++++++++++++---- 5 files changed, 52 insertions(+), 18 deletions(-) diff --git a/app/include/fan/HwmonFan.h b/app/include/fan/HwmonFan.h index 0a26e13..49aede9 100644 --- a/app/include/fan/HwmonFan.h +++ b/app/include/fan/HwmonFan.h @@ -23,6 +23,7 @@ public: private: std::shared_ptr mPWMControl; std::shared_ptr mRpmSensor; + std::string mLabel; }; #endif // HWMONFAN_H_ diff --git a/app/include/pwm/PWMControlFacade.h b/app/include/pwm/PWMControlFacade.h index 6776524..1da89ff 100644 --- a/app/include/pwm/PWMControlFacade.h +++ b/app/include/pwm/PWMControlFacade.h @@ -1,9 +1,7 @@ #ifndef PWMCONTROLFACADE_H_ #define PWMCONTROLFACADE_H_ -#include #include -#include #include #include diff --git a/app/src/fan/HwmonFan.cxx b/app/src/fan/HwmonFan.cxx index 6b171eb..9e1c7ae 100644 --- a/app/src/fan/HwmonFan.cxx +++ b/app/src/fan/HwmonFan.cxx @@ -14,7 +14,7 @@ int HwmonFan::rpm() { return mRpmSensor->value(); } json HwmonFan::toJson() const { json obj; - obj = {mPWMControl->toJson(), mRpmSensor->toJson()}; + obj = {mPWMControl->toJson(), mRpmSensor->toJson(), mLabel}; return obj; } diff --git a/app/src/main.cxx b/app/src/main.cxx index 0450d46..7b7bd95 100644 --- a/app/src/main.cxx +++ b/app/src/main.cxx @@ -1,4 +1,3 @@ -#include #include #include @@ -7,8 +6,6 @@ #include #include -namespace fs = std::filesystem; - int main() { SensorManager sensorManager; auto pwmSensors = sensorManager.RPMSensors(); @@ -21,12 +18,7 @@ int main() { std::vector> fans; - if (fs::exists(fs::path(SERIALIZATION_DIR) / FANS_JSON_FILENAME)) { - fans = s.DeserializeFans(pwmSensors); - } else { - fans = m.FindFans(pwmSensors, controls); - s.SerializeFans(fans); - } + fans = m.FindFans(pwmSensors, controls); for (auto f : fans) { std::cout << f->toString() << std::endl; diff --git a/doc/Class.plantuml b/doc/Class.plantuml index 0dbfbac..2bb63ce 100644 --- a/doc/Class.plantuml +++ b/doc/Class.plantuml @@ -4,7 +4,7 @@ interface Sensor { } class LMSensor { - - Identifier: string + - string Label + int Value() } @@ -14,19 +14,23 @@ class GPUSensor { } class HWMONFan { - - Identifier: string - - RPMSensor: Sensor - - PWMControl: PWMControl + - string Label + - Sensor RPMSensor + - PWMControl PWMControl + int RPM() - + void PWM(value: int) + + void PWMPercent(int value) } class PWMControl { - + void PWM(value: int) + + void PWMPercent(int value) + int PWM() } +class PWMControlFacade { + + List PWMControls() +} + class LMSensorsFacade { + List RPMSensors() @@ -52,8 +56,41 @@ class FanGenerator + FanList FindFans(List, List) } +struct Coordinate +{ + int X + int Y +} + +enum SensorAggregateFunction +{ + MIN + MAX + AVG +} + +class FanCurve +{ + - List Steps + - List TempSensor + - SensorAggregateFunction Fun + - HWMONFan Fan + + + int TargetPWMPercent() +} + +class FanController +{ + - List + + + void StartFanControlLoop() +} + HWMONFan -- Sensor HWMONFan -- PWMControl +HWMONFan - FanCurve + +PWMControl -- PWMControlFacade Sensor <|-- LMSensor Sensor <|-- GPUSensor @@ -68,4 +105,10 @@ GPUSensorsFacade -- SensorManager FanGenerator - HWMONFan FanGenerator - SensorManager FanGenerator - PWMControl + +Sensor - FanCurve +FanCurve -- Coordinate +FanCurve -- SensorAggregateFunction + +FanController -- FanCurve @enduml