Cleanup, more documentation
This commit is contained in:
@@ -23,6 +23,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
std::shared_ptr<PWMControl> mPWMControl;
|
std::shared_ptr<PWMControl> mPWMControl;
|
||||||
std::shared_ptr<Sensor> mRpmSensor;
|
std::shared_ptr<Sensor> mRpmSensor;
|
||||||
|
std::string mLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HWMONFAN_H_
|
#endif // HWMONFAN_H_
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
#ifndef PWMCONTROLFACADE_H_
|
#ifndef PWMCONTROLFACADE_H_
|
||||||
#define PWMCONTROLFACADE_H_
|
#define PWMCONTROLFACADE_H_
|
||||||
|
|
||||||
#include <filesystem>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <regex>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <pwm/PWMControl.h>
|
#include <pwm/PWMControl.h>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ int HwmonFan::rpm() { return mRpmSensor->value(); }
|
|||||||
|
|
||||||
json HwmonFan::toJson() const {
|
json HwmonFan::toJson() const {
|
||||||
json obj;
|
json obj;
|
||||||
obj = {mPWMControl->toJson(), mRpmSensor->toJson()};
|
obj = {mPWMControl->toJson(), mRpmSensor->toJson(), mLabel};
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#include <filesystem>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <FanGenerator.h>
|
#include <FanGenerator.h>
|
||||||
@@ -7,8 +6,6 @@
|
|||||||
#include <pwm/PWMControlFacade.h>
|
#include <pwm/PWMControlFacade.h>
|
||||||
#include <sensor/SensorManager.h>
|
#include <sensor/SensorManager.h>
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
SensorManager sensorManager;
|
SensorManager sensorManager;
|
||||||
auto pwmSensors = sensorManager.RPMSensors();
|
auto pwmSensors = sensorManager.RPMSensors();
|
||||||
@@ -21,12 +18,7 @@ int main() {
|
|||||||
|
|
||||||
std::vector<std::shared_ptr<Fan>> fans;
|
std::vector<std::shared_ptr<Fan>> fans;
|
||||||
|
|
||||||
if (fs::exists(fs::path(SERIALIZATION_DIR) / FANS_JSON_FILENAME)) {
|
|
||||||
fans = s.DeserializeFans(pwmSensors);
|
|
||||||
} else {
|
|
||||||
fans = m.FindFans(pwmSensors, controls);
|
fans = m.FindFans(pwmSensors, controls);
|
||||||
s.SerializeFans(fans);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto f : fans) {
|
for (auto f : fans) {
|
||||||
std::cout << f->toString() << std::endl;
|
std::cout << f->toString() << std::endl;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ interface Sensor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class LMSensor {
|
class LMSensor {
|
||||||
- Identifier: string
|
- string Label
|
||||||
|
|
||||||
+ int Value()
|
+ int Value()
|
||||||
}
|
}
|
||||||
@@ -14,19 +14,23 @@ class GPUSensor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class HWMONFan {
|
class HWMONFan {
|
||||||
- Identifier: string
|
- string Label
|
||||||
- RPMSensor: Sensor
|
- Sensor RPMSensor
|
||||||
- PWMControl: PWMControl
|
- PWMControl PWMControl
|
||||||
|
|
||||||
+ int RPM()
|
+ int RPM()
|
||||||
+ void PWM(value: int)
|
+ void PWMPercent(int value)
|
||||||
}
|
}
|
||||||
|
|
||||||
class PWMControl {
|
class PWMControl {
|
||||||
+ void PWM(value: int)
|
+ void PWMPercent(int value)
|
||||||
+ int PWM()
|
+ int PWM()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PWMControlFacade {
|
||||||
|
+ List<PWMControl> PWMControls()
|
||||||
|
}
|
||||||
|
|
||||||
class LMSensorsFacade
|
class LMSensorsFacade
|
||||||
{
|
{
|
||||||
+ List<Sensor> RPMSensors()
|
+ List<Sensor> RPMSensors()
|
||||||
@@ -52,8 +56,41 @@ class FanGenerator
|
|||||||
+ FanList FindFans(List<RPMSensor>, List<PWMControl>)
|
+ FanList FindFans(List<RPMSensor>, List<PWMControl>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Coordinate
|
||||||
|
{
|
||||||
|
int X
|
||||||
|
int Y
|
||||||
|
}
|
||||||
|
|
||||||
|
enum SensorAggregateFunction
|
||||||
|
{
|
||||||
|
MIN
|
||||||
|
MAX
|
||||||
|
AVG
|
||||||
|
}
|
||||||
|
|
||||||
|
class FanCurve
|
||||||
|
{
|
||||||
|
- List<Coordinate> Steps
|
||||||
|
- List<Sensor> TempSensor
|
||||||
|
- SensorAggregateFunction Fun
|
||||||
|
- HWMONFan Fan
|
||||||
|
|
||||||
|
+ int TargetPWMPercent()
|
||||||
|
}
|
||||||
|
|
||||||
|
class FanController
|
||||||
|
{
|
||||||
|
- List<HWMONFan>
|
||||||
|
|
||||||
|
+ void StartFanControlLoop()
|
||||||
|
}
|
||||||
|
|
||||||
HWMONFan -- Sensor
|
HWMONFan -- Sensor
|
||||||
HWMONFan -- PWMControl
|
HWMONFan -- PWMControl
|
||||||
|
HWMONFan - FanCurve
|
||||||
|
|
||||||
|
PWMControl -- PWMControlFacade
|
||||||
|
|
||||||
Sensor <|-- LMSensor
|
Sensor <|-- LMSensor
|
||||||
Sensor <|-- GPUSensor
|
Sensor <|-- GPUSensor
|
||||||
@@ -68,4 +105,10 @@ GPUSensorsFacade -- SensorManager
|
|||||||
FanGenerator - HWMONFan
|
FanGenerator - HWMONFan
|
||||||
FanGenerator - SensorManager
|
FanGenerator - SensorManager
|
||||||
FanGenerator - PWMControl
|
FanGenerator - PWMControl
|
||||||
|
|
||||||
|
Sensor - FanCurve
|
||||||
|
FanCurve -- Coordinate
|
||||||
|
FanCurve -- SensorAggregateFunction
|
||||||
|
|
||||||
|
FanController -- FanCurve
|
||||||
@enduml
|
@enduml
|
||||||
|
|||||||
Reference in New Issue
Block a user