Change some variable names, add stubs for sensor interface and an implementation
This commit is contained in:
11
app/include/HwmonTemperatureSensor.h
Normal file
11
app/include/HwmonTemperatureSensor.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#ifndef HWMONTEMPERATURESENSOR_H_
|
||||||
|
#define HWMONTEMPERATURESENSOR_H_
|
||||||
|
|
||||||
|
#include <TemperatureSensor.h>
|
||||||
|
|
||||||
|
class HwmonTemperatureSensor : public TemperatureSensor {
|
||||||
|
public:
|
||||||
|
int getTemperature() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // HWMONTEMPERATURESENSOR_H_
|
||||||
@@ -8,9 +8,9 @@
|
|||||||
enum class PWM_CONTROL_PROPERTY { CONTROL, ENABLE, MODE };
|
enum class PWM_CONTROL_PROPERTY { CONTROL, ENABLE, MODE };
|
||||||
|
|
||||||
struct PWM_CONTROL {
|
struct PWM_CONTROL {
|
||||||
std::string control;
|
std::string controlPath;
|
||||||
std::string enable;
|
std::string enablePath;
|
||||||
std::string mode;
|
std::string modePath;
|
||||||
|
|
||||||
std::string initialEnable;
|
std::string initialEnable;
|
||||||
std::string initialMode;
|
std::string initialMode;
|
||||||
|
|||||||
9
app/include/TemperatureSensor.h
Normal file
9
app/include/TemperatureSensor.h
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#ifndef TEMPERATURESENSOR_H_
|
||||||
|
#define TEMPERATURESENSOR_H_
|
||||||
|
|
||||||
|
class TemperatureSensor {
|
||||||
|
public:
|
||||||
|
virtual int getTemperature() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TEMPERATURESENSOR_H_
|
||||||
@@ -51,8 +51,8 @@ PWM::PWM() {
|
|||||||
|
|
||||||
void PWM::dumpValues() {
|
void PWM::dumpValues() {
|
||||||
for (auto control : mPwmControls) {
|
for (auto control : mPwmControls) {
|
||||||
cout << control.second.control << ", " << control.second.enable << ": "
|
cout << control.second.controlPath << ", " << control.second.enablePath
|
||||||
<< control.second.mode << endl;
|
<< ": " << control.second.modePath << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +67,8 @@ vector<PWM_CONTROL> PWM::getControls() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PWM::setEnable(PWM_CONTROL control, PWM_ENABLE value) {
|
void PWM::setEnable(PWM_CONTROL control, PWM_ENABLE value) {
|
||||||
cout << control.control << endl;
|
cout << control.controlPath << endl;
|
||||||
ofstream ostrm(control.enable, ios::trunc);
|
ofstream ostrm(control.enablePath, ios::trunc);
|
||||||
ostrm << static_cast<int>(value);
|
ostrm << static_cast<int>(value);
|
||||||
ostrm.close();
|
ostrm.close();
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ void PWM::setValuePwm(PWM_CONTROL control, int pwm) {
|
|||||||
if (pwm < 0 || pwm > 255)
|
if (pwm < 0 || pwm > 255)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ofstream ostrm(control.control, ios::trunc);
|
ofstream ostrm(control.controlPath, ios::trunc);
|
||||||
ostrm << pwm;
|
ostrm << pwm;
|
||||||
ostrm.close();
|
ostrm.close();
|
||||||
}
|
}
|
||||||
@@ -88,15 +88,15 @@ int PWM::readValue(PWM_CONTROL control, PWM_CONTROL_PROPERTY property) {
|
|||||||
|
|
||||||
switch (property) {
|
switch (property) {
|
||||||
case PWM_CONTROL_PROPERTY::CONTROL:
|
case PWM_CONTROL_PROPERTY::CONTROL:
|
||||||
istrm.open(control.control, ios::in);
|
istrm.open(control.controlPath, ios::in);
|
||||||
istrm >> result;
|
istrm >> result;
|
||||||
break;
|
break;
|
||||||
case PWM_CONTROL_PROPERTY::ENABLE:
|
case PWM_CONTROL_PROPERTY::ENABLE:
|
||||||
istrm.open(control.enable, ios::in);
|
istrm.open(control.enablePath, ios::in);
|
||||||
istrm >> result;
|
istrm >> result;
|
||||||
break;
|
break;
|
||||||
case PWM_CONTROL_PROPERTY::MODE:
|
case PWM_CONTROL_PROPERTY::MODE:
|
||||||
istrm.open(control.mode, ios::in);
|
istrm.open(control.modePath, ios::in);
|
||||||
istrm >> result;
|
istrm >> result;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user