Refactoring, housekeeping, documentation
Add a class diagram. Still needs some details. Refactor to better respect SOLID principles. Housekeeping, move and rename classes/files.
This commit is contained in:
@@ -5,12 +5,12 @@
|
||||
#include <memory>
|
||||
|
||||
#include <fan/Fan.h>
|
||||
#include <fan/PwmControl.h>
|
||||
#include <pwm/PWMControl.h>
|
||||
#include <sensor/Sensor.h>
|
||||
|
||||
class HwmonFan : public Fan {
|
||||
public:
|
||||
HwmonFan(std::shared_ptr<PwmControl> pwmControl,
|
||||
HwmonFan(std::shared_ptr<PWMControl> pwmControl,
|
||||
std::shared_ptr<Sensor> rpmSensor);
|
||||
|
||||
void pwm(int percent) override;
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
const std::string toString() const override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<PwmControl> mPwmControl;
|
||||
std::shared_ptr<PWMControl> mPWMControl;
|
||||
std::shared_ptr<Sensor> mRpmSensor;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
#ifndef PWM_H_
|
||||
#define PWM_H_
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
enum class PWM_CONTROL_PROPERTY { CONTROL, ENABLE, MODE };
|
||||
|
||||
struct PWM_CONTROL {
|
||||
std::string controlPath;
|
||||
std::string enablePath;
|
||||
std::string modePath;
|
||||
|
||||
std::string initialEnable;
|
||||
std::string initialMode;
|
||||
};
|
||||
|
||||
enum class PWM_ENABLE { FULL_SPEED = 0, MANUAL_CONTROL };
|
||||
enum class PWM_MODE { DC = 0, PWM };
|
||||
|
||||
class PWM {
|
||||
public:
|
||||
PWM();
|
||||
void dumpValues();
|
||||
|
||||
std::vector<PWM_CONTROL> getControls();
|
||||
int readValue(PWM_CONTROL control, PWM_CONTROL_PROPERTY property);
|
||||
|
||||
void setEnable(PWM_CONTROL control, PWM_ENABLE value);
|
||||
void setMode(PWM_CONTROL control, PWM_MODE mode);
|
||||
void setValuePwm(PWM_CONTROL control, int pwm);
|
||||
void setValuePercent(PWM_CONTROL control, int percentage);
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, PWM_CONTROL> mPwmControls;
|
||||
};
|
||||
|
||||
#endif // PWM_H_
|
||||
@@ -1,40 +0,0 @@
|
||||
#ifndef PWMCONTROL_H_
|
||||
#define PWMCONTROL_H_
|
||||
|
||||
#include <boost/json/object.hpp>
|
||||
#include <string>
|
||||
|
||||
#include <Printable.h>
|
||||
#include <Serializable.h>
|
||||
|
||||
enum class PWM_CONTROL_PROPERTY { CONTROL, ENABLE, MODE };
|
||||
enum class PWM_ENABLE { FULL_SPEED = 0, MANUAL_CONTROL };
|
||||
enum class PWM_MODE { DC = 0, PWM };
|
||||
|
||||
class PwmControl : public Printable, public Serializable {
|
||||
public:
|
||||
PwmControl(std::string controlPath);
|
||||
~PwmControl();
|
||||
|
||||
void pwm(int percent);
|
||||
int pwm();
|
||||
|
||||
void EnableManualControl();
|
||||
void Reset();
|
||||
|
||||
const std::string toString() const override;
|
||||
|
||||
json toJson() const override;
|
||||
|
||||
private:
|
||||
int readValue(std::string path);
|
||||
|
||||
std::string mControlPath;
|
||||
std::string mEnablePath;
|
||||
std::string mModePath;
|
||||
|
||||
std::string mInitialEnable;
|
||||
std::string mInitialMode;
|
||||
};
|
||||
|
||||
#endif // PWMCONTROL_H_
|
||||
Reference in New Issue
Block a user