Implement fan curves and extend serialization logic

This commit is contained in:
2022-09-30 20:58:33 +02:00
parent 981d808004
commit a23563c0be
6 changed files with 56 additions and 19 deletions

View File

@@ -1,12 +1,14 @@
#ifndef SERIALIZER_H_
#define SERIALIZER_H_
#include "fan/HwmonFan.h"
#include <memory>
#include <vector>
#include <nlohmann/json.hpp>
#include <fan/Fan.h>
#include <fan/FanCurve.h>
#include <sensor/Sensor.h>
#define SERIALIZATION_DIR "/etc/fantasize"
@@ -20,10 +22,9 @@ public:
void SerializeFans(std::vector<std::shared_ptr<Fan>> fans);
std::vector<std::shared_ptr<Fan>>
DeserializeFans(std::vector<std::shared_ptr<Sensor>> availableSensors);
void SerializeTempSensors(std::vector<std::shared_ptr<Sensor>> senors);
std::vector<std::shared_ptr<Sensor>>
DeserializeTempSensors(std::vector<std::shared_ptr<Sensor>> availableSensors);
std::vector<std::shared_ptr<FanCurve>>
DeserializeFanCurves(std::vector<std::shared_ptr<Sensor>> availableSensors,
std::vector<std::shared_ptr<Fan>> availableFans);
private:
void WriteJson(json o);

View File

@@ -14,6 +14,10 @@ struct FanStep {
class FanCurve {
public:
FanCurve(std::vector<FanStep> steps,
std::vector<std::shared_ptr<Sensor>> sensors,
std::vector<std::shared_ptr<Fan>> fans);
void DoFanControl();
private:
@@ -21,7 +25,7 @@ private:
std::vector<FanStep> mSteps;
std::vector<std::shared_ptr<Sensor>> mTempSensors;
std::vector<std::shared_ptr<HwmonFan>> mFans;
std::vector<std::shared_ptr<Fan>> mFans;
};
#endif // FANCURVE_H_