Compare commits
1 Commits
v0.2.1
...
OptionalLi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4e234f307 |
12
PKGBUILD
12
PKGBUILD
@@ -1,21 +1,19 @@
|
|||||||
pkgname=fantasize
|
pkgname=fantasize
|
||||||
pkgver=0.2.0
|
pkgver=0.1.7
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc='C++ fan control for Linux'
|
pkgdesc='C++ fan control for Linux'
|
||||||
url='https://github.com/Tabascl/fantasize.git'
|
url='https://github.com/Tabascl/fantasize.git'
|
||||||
source=("$pkgname-$pkgver.tar.gz::https://github.com/Tabascl/fantasize/archive/refs/tags/v$pkgver.tar.gz")
|
source=("$pkgname-$pkgver.tar.gz::https://github.com/Tabascl/fantasize/archive/refs/tags/v$pkgver.tar.gz")
|
||||||
arch=('x86_64')
|
arch=('x86_64')
|
||||||
license=('GPL3')
|
license=('GPL3')
|
||||||
makedepends=('git' 'meson' 'nlohmann-json' 'boost')
|
makedepends=('git' 'cmake' 'nlohmann-json' 'boost' 'cuda')
|
||||||
sha256sums=('SKIP')
|
sha256sums=('SKIP')
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
meson setup build "$pkgname-$pkgver/app" -Dbuildtype=Release
|
cmake -S "$pkgname-$pkgver/app" -B build -DCMAKE_BUILD_TYPE=Release
|
||||||
cd build
|
cmake --build build
|
||||||
meson compile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
cd build
|
cmake --install build --prefix "$pkgdir/" --verbose
|
||||||
meson install
|
|
||||||
}
|
}
|
||||||
|
|||||||
1
app/.clang-format
Normal file
1
app/.clang-format
Normal file
@@ -0,0 +1 @@
|
|||||||
|
BasedOnStyle: Google
|
||||||
51
app/CMakeLists.txt
Normal file
51
app/CMakeLists.txt
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
|
||||||
|
project(fantasize VERSION 0.1.7)
|
||||||
|
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
find_package(nlohmann_json 3.7 REQUIRED)
|
||||||
|
find_package(Boost 1.80 COMPONENTS program_options log log_setup date_time REQUIRED)
|
||||||
|
|
||||||
|
find_library(NVML_LIB nvidia-ml)
|
||||||
|
|
||||||
|
set(ADDITIONAL_LIBS)
|
||||||
|
|
||||||
|
if (NVML_LIB)
|
||||||
|
set(HAVE_NVML)
|
||||||
|
|
||||||
|
add_library(nvidia-sensor-lib STATIC
|
||||||
|
src/sensor/NvidiaSensor.cxx
|
||||||
|
src/sensor/GPUSensorsFacade.cxx)
|
||||||
|
|
||||||
|
target_link_libraries(nvidia-sensor-lib PUBLIC NVML_LIB)
|
||||||
|
|
||||||
|
list(APPEND ADDITIONAL_LIBS nvidia-sensor-lib)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_executable(${PROJECT_NAME}
|
||||||
|
src/main.cxx
|
||||||
|
src/sensor/LMSensorsFacade.cxx
|
||||||
|
src/sensor/Sensor.cxx
|
||||||
|
src/sensor/LMSensor.cxx
|
||||||
|
src/pwm/PWMControl.cxx
|
||||||
|
src/pwm/PWMControlFacade.cxx
|
||||||
|
src/fan/HwmonFan.cxx
|
||||||
|
src/fan/FanCurve.cxx
|
||||||
|
src/fan/FanLabeler.cxx
|
||||||
|
src/FanGenerator.cxx
|
||||||
|
src/Serializer.cxx
|
||||||
|
src/sensor/SensorManager.cxx
|
||||||
|
src/Controller.cxx
|
||||||
|
src/Settings.cxx
|
||||||
|
src/App.cxx
|
||||||
|
)
|
||||||
|
|
||||||
|
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT_NAME} PUBLIC include /opt/cuda)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME} PUBLIC sensors nlohmann_json::nlohmann_json tbb ${Boost_LIBRARIES} ${ADDITIONAL_LIBS})
|
||||||
|
|
||||||
|
install(TARGETS ${PROJECT_NAME} DESTINATION usr/local/bin)
|
||||||
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/unit/fantasize.service DESTINATION usr/lib/systemd/system)
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include <Settings.h>
|
#include <Settings.h>
|
||||||
#include <fan/Aggregators.h>
|
|
||||||
#include <fan/Fan.h>
|
#include <fan/Fan.h>
|
||||||
#include <fan/FanCurve.h>
|
#include <fan/FanCurve.h>
|
||||||
#include <sensor/Sensor.h>
|
#include <sensor/Sensor.h>
|
||||||
@@ -17,22 +16,20 @@
|
|||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
class Serializer
|
class Serializer {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
Serializer();
|
Serializer();
|
||||||
void SerializeFans(std::vector<std::shared_ptr<Fan>> fans);
|
void SerializeFans(std::vector<std::shared_ptr<Fan>> fans);
|
||||||
std::vector<std::shared_ptr<Fan>> DeserializeFans(
|
std::vector<std::shared_ptr<Fan>>
|
||||||
std::vector<std::shared_ptr<Sensor>> availableSensors);
|
DeserializeFans(std::vector<std::shared_ptr<Sensor>> availableSensors);
|
||||||
std::vector<std::shared_ptr<FanCurve>> DeserializeFanCurves(
|
std::vector<std::shared_ptr<FanCurve>>
|
||||||
std::vector<std::shared_ptr<Sensor>> availableSensors,
|
DeserializeFanCurves(std::vector<std::shared_ptr<Sensor>> availableSensors,
|
||||||
std::vector<std::shared_ptr<Fan>> availableFans);
|
std::vector<std::shared_ptr<Fan>> availableFans);
|
||||||
std::shared_ptr<Settings> DeserializeSettings();
|
std::shared_ptr<Settings> DeserializeSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void WriteJson(json o);
|
void WriteJson(json o);
|
||||||
json ReadJson();
|
json ReadJson();
|
||||||
std::unique_ptr<Aggregator> aggregatorFromString(std::string str) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SERIALIZER_H_
|
#endif // SERIALIZER_H_
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
#ifndef AGGREGATORS_H_
|
|
||||||
#define AGGREGATORS_H_
|
|
||||||
|
|
||||||
#include <sensor/Sensor.h>
|
|
||||||
|
|
||||||
class Aggregator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual int aggregate(std::vector<std::shared_ptr<Sensor>> sensors) const = 0;
|
|
||||||
virtual const std::string toString() const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class AverageAggregator : public Aggregator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int aggregate(std::vector<std::shared_ptr<Sensor>> sensors) const override;
|
|
||||||
const std::string toString() const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MaxAggregator : public Aggregator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int aggregate(std::vector<std::shared_ptr<Sensor>> sensors) const override;
|
|
||||||
const std::string toString() const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // AGGERGATORS_H_
|
|
||||||
@@ -17,9 +17,6 @@ public:
|
|||||||
virtual void StartPWM(int value) = 0;
|
virtual void StartPWM(int value) = 0;
|
||||||
virtual int StartPWM() = 0;
|
virtual int StartPWM() = 0;
|
||||||
|
|
||||||
virtual void ZeroFanModeSupported(bool value) = 0;
|
|
||||||
virtual bool ZeroFanModeSupported() = 0;
|
|
||||||
|
|
||||||
virtual void FindPWMLimits() = 0;
|
virtual void FindPWMLimits() = 0;
|
||||||
virtual void AdjustPWMLimits() = 0;
|
virtual void AdjustPWMLimits() = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,23 +4,19 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <fan/Aggregators.h>
|
|
||||||
#include <fan/HwmonFan.h>
|
#include <fan/HwmonFan.h>
|
||||||
#include <sensor/Sensor.h>
|
#include <sensor/Sensor.h>
|
||||||
|
|
||||||
struct FanStep
|
struct FanStep {
|
||||||
{
|
|
||||||
int Temp;
|
int Temp;
|
||||||
int Percent;
|
int Percent;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FanCurve
|
class FanCurve {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
FanCurve(std::vector<FanStep> steps,
|
FanCurve(std::vector<FanStep> steps,
|
||||||
std::vector<std::shared_ptr<Sensor>> sensors,
|
std::vector<std::shared_ptr<Sensor>> sensors,
|
||||||
std::vector<std::shared_ptr<Fan>> fans,
|
std::vector<std::shared_ptr<Fan>> fans);
|
||||||
std::unique_ptr<Aggregator> aggregator);
|
|
||||||
|
|
||||||
void DoFanControl();
|
void DoFanControl();
|
||||||
|
|
||||||
@@ -31,7 +27,6 @@ private:
|
|||||||
std::vector<FanStep> mSteps;
|
std::vector<FanStep> mSteps;
|
||||||
std::vector<std::shared_ptr<Sensor>> mTempSensors;
|
std::vector<std::shared_ptr<Sensor>> mTempSensors;
|
||||||
std::vector<std::shared_ptr<Fan>> mFans;
|
std::vector<std::shared_ptr<Fan>> mFans;
|
||||||
std::unique_ptr<Aggregator> mAggregator;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FANCURVE_H_
|
#endif // FANCURVE_H_
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include <boost/json/object.hpp>
|
||||||
|
|
||||||
#include <fan/Fan.h>
|
#include <fan/Fan.h>
|
||||||
#include <pwm/PWMControl.h>
|
#include <pwm/PWMControl.h>
|
||||||
#include <sensor/Sensor.h>
|
#include <sensor/Sensor.h>
|
||||||
@@ -24,9 +26,6 @@ public:
|
|||||||
void StartPWM(int value) override;
|
void StartPWM(int value) override;
|
||||||
int StartPWM() override;
|
int StartPWM() override;
|
||||||
|
|
||||||
void ZeroFanModeSupported(bool value) override;
|
|
||||||
bool ZeroFanModeSupported() override;
|
|
||||||
|
|
||||||
void FindPWMLimits() override;
|
void FindPWMLimits() override;
|
||||||
void AdjustPWMLimits() override;
|
void AdjustPWMLimits() override;
|
||||||
|
|
||||||
@@ -39,9 +38,8 @@ private:
|
|||||||
std::shared_ptr<Sensor> mRpmSensor;
|
std::shared_ptr<Sensor> mRpmSensor;
|
||||||
std::string mLabel;
|
std::string mLabel;
|
||||||
|
|
||||||
int mMinPWM = 0;
|
int mMinPWM;
|
||||||
int mStartPWM = 0;
|
int mStartPWM;
|
||||||
bool mZeroFanModeSupported = false;
|
|
||||||
std::chrono::time_point<std::chrono::steady_clock> mLastAdjustmentTime;
|
std::chrono::time_point<std::chrono::steady_clock> mLastAdjustmentTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef PWMCONTROL_H_
|
#ifndef PWMCONTROL_H_
|
||||||
#define PWMCONTROL_H_
|
#define PWMCONTROL_H_
|
||||||
|
|
||||||
|
#include <boost/json/object.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <Printable.h>
|
#include <Printable.h>
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
project('fantasize', 'cpp', version : '0.2.1', default_options : ['cpp_std=c++20'])
|
|
||||||
|
|
||||||
src = [
|
|
||||||
'src/main.cxx',
|
|
||||||
'src/sensor/LMSensorsFacade.cxx',
|
|
||||||
'src/sensor/Sensor.cxx',
|
|
||||||
'src/sensor/LMSensor.cxx',
|
|
||||||
'src/pwm/PWMControl.cxx',
|
|
||||||
'src/pwm/PWMControlFacade.cxx',
|
|
||||||
'src/fan/HwmonFan.cxx',
|
|
||||||
'src/fan/FanCurve.cxx',
|
|
||||||
'src/fan/FanLabeler.cxx',
|
|
||||||
'src/fan/Aggregators.cxx',
|
|
||||||
'src/FanGenerator.cxx',
|
|
||||||
'src/Serializer.cxx',
|
|
||||||
'src/sensor/SensorManager.cxx',
|
|
||||||
'src/Controller.cxx',
|
|
||||||
'src/Settings.cxx',
|
|
||||||
'src/App.cxx'
|
|
||||||
]
|
|
||||||
|
|
||||||
deps = [
|
|
||||||
dependency('nlohmann_json'),
|
|
||||||
dependency('boost', modules : ['program_options', 'log', 'log_setup', 'date_time', 'thread']),
|
|
||||||
dependency('tbb'),
|
|
||||||
meson.get_compiler('cpp').find_library('sensors')
|
|
||||||
]
|
|
||||||
|
|
||||||
inc = include_directories('include')
|
|
||||||
|
|
||||||
exe = executable('fantasize',
|
|
||||||
src,
|
|
||||||
dependencies: deps,
|
|
||||||
install: true,
|
|
||||||
include_directories: inc)
|
|
||||||
|
|
||||||
install_data('unit/fantasize.service', install_dir : 'usr/lib/systemd/system')
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "Settings.h"
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -8,7 +9,6 @@
|
|||||||
#include <fan/HwmonFan.h>
|
#include <fan/HwmonFan.h>
|
||||||
#include <pwm/PWMControl.h>
|
#include <pwm/PWMControl.h>
|
||||||
#include <sensor/LMSensor.h>
|
#include <sensor/LMSensor.h>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
namespace fs = filesystem;
|
namespace fs = filesystem;
|
||||||
@@ -48,13 +48,11 @@ Serializer::DeserializeFans(vector<shared_ptr<Sensor>> availableSensors) {
|
|||||||
int minPWM = el.value()["MinPWM"];
|
int minPWM = el.value()["MinPWM"];
|
||||||
int startPWM = el.value()["StartPWM"];
|
int startPWM = el.value()["StartPWM"];
|
||||||
string label = el.value()["Label"];
|
string label = el.value()["Label"];
|
||||||
bool zeroFan = el.value()["ZeroFan"];
|
|
||||||
|
|
||||||
auto fan = make_shared<HwmonFan>(pwmControl, rpmSensor);
|
auto fan = make_shared<HwmonFan>(pwmControl, rpmSensor);
|
||||||
fan->MinPWM(minPWM);
|
fan->MinPWM(minPWM);
|
||||||
fan->StartPWM(startPWM);
|
fan->StartPWM(startPWM);
|
||||||
fan->Label(label);
|
fan->Label(label);
|
||||||
fan->ZeroFanModeSupported(zeroFan);
|
|
||||||
|
|
||||||
fans.push_back(fan);
|
fans.push_back(fan);
|
||||||
}
|
}
|
||||||
@@ -120,24 +118,12 @@ vector<shared_ptr<FanCurve>> Serializer::DeserializeFanCurves(
|
|||||||
fans.push_back(fanMap[fan.value()]);
|
fans.push_back(fanMap[fan.value()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Aggregator> aggregator =
|
curves.push_back(make_shared<FanCurve>(steps, sensors, fans));
|
||||||
aggregatorFromString(el.value()["AggregateFunction"]);
|
|
||||||
|
|
||||||
curves.push_back(
|
|
||||||
make_shared<FanCurve>(steps, sensors, fans, std::move(aggregator)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return curves;
|
return curves;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Aggregator>
|
|
||||||
Serializer::aggregatorFromString(std::string str) const {
|
|
||||||
if (str == "max")
|
|
||||||
return std::make_unique<MaxAggregator>();
|
|
||||||
else
|
|
||||||
return std::make_unique<AverageAggregator>();
|
|
||||||
}
|
|
||||||
|
|
||||||
shared_ptr<Settings> Serializer::DeserializeSettings() {
|
shared_ptr<Settings> Serializer::DeserializeSettings() {
|
||||||
int frequency = FREQUENCY_DEFAULT;
|
int frequency = FREQUENCY_DEFAULT;
|
||||||
|
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
#include <climits>
|
|
||||||
#include <fan/Aggregators.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
AverageAggregator::aggregate(std::vector<std::shared_ptr<Sensor>> sensors) const
|
|
||||||
{
|
|
||||||
int sum = 0;
|
|
||||||
|
|
||||||
for (auto sensor : sensors) {
|
|
||||||
sum += sensor->value();
|
|
||||||
}
|
|
||||||
|
|
||||||
return sum / sensors.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string
|
|
||||||
AverageAggregator::toString() const
|
|
||||||
{
|
|
||||||
return "Average";
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
MaxAggregator::aggregate(std::vector<std::shared_ptr<Sensor>> sensors) const
|
|
||||||
{
|
|
||||||
int max = INT_MIN;
|
|
||||||
|
|
||||||
for (auto sensor : sensors) {
|
|
||||||
if (sensor->value() > max)
|
|
||||||
max = sensor->value();
|
|
||||||
}
|
|
||||||
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string
|
|
||||||
MaxAggregator::toString() const
|
|
||||||
{
|
|
||||||
return "Max";
|
|
||||||
}
|
|
||||||
@@ -1,19 +1,15 @@
|
|||||||
#include <boost/log/attributes/named_scope.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <boost/log/trivial.hpp>
|
|
||||||
|
|
||||||
#include <fan/FanCurve.h>
|
#include <fan/FanCurve.h>
|
||||||
#include <memory>
|
|
||||||
|
#include <boost/log/attributes/named_scope.hpp>
|
||||||
|
#include <boost/log/trivial.hpp>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
FanCurve::FanCurve(std::vector<FanStep> steps,
|
FanCurve::FanCurve(std::vector<FanStep> steps,
|
||||||
std::vector<std::shared_ptr<Sensor>> sensors,
|
std::vector<std::shared_ptr<Sensor>> sensors,
|
||||||
std::vector<std::shared_ptr<Fan>> fans,
|
std::vector<std::shared_ptr<Fan>> fans)
|
||||||
std::unique_ptr<Aggregator> aggregator)
|
: mSteps(steps), mTempSensors(sensors), mFans(fans) {
|
||||||
: mSteps(steps), mTempSensors(sensors), mFans(fans),
|
|
||||||
mAggregator(std::move(aggregator)) {
|
|
||||||
PrintInfo();
|
PrintInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,7 +18,7 @@ void FanCurve::DoFanControl() {
|
|||||||
|
|
||||||
int temp = AggregateTemperature();
|
int temp = AggregateTemperature();
|
||||||
|
|
||||||
int t0 = 0, t1 = 0, p0 = 0, p1 = 0;
|
int t0, t1, p0, p1;
|
||||||
int targetFanPower;
|
int targetFanPower;
|
||||||
|
|
||||||
if (temp <= mSteps[0].Temp) {
|
if (temp <= mSteps[0].Temp) {
|
||||||
@@ -30,7 +26,7 @@ void FanCurve::DoFanControl() {
|
|||||||
} else if (temp > mSteps[mSteps.size() - 1].Temp) {
|
} else if (temp > mSteps[mSteps.size() - 1].Temp) {
|
||||||
targetFanPower = mSteps[mSteps.size() - 1].Percent;
|
targetFanPower = mSteps[mSteps.size() - 1].Percent;
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < (int)mSteps.size(); i++) {
|
for (int i = 0; i < mSteps.size(); i++) {
|
||||||
if (temp > mSteps[i].Temp) {
|
if (temp > mSteps[i].Temp) {
|
||||||
t0 = mSteps[i].Temp;
|
t0 = mSteps[i].Temp;
|
||||||
p0 = mSteps[i].Percent;
|
p0 = mSteps[i].Percent;
|
||||||
@@ -44,7 +40,7 @@ void FanCurve::DoFanControl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto f : mFans) {
|
for (auto f : mFans) {
|
||||||
if (!f->ZeroFanModeSupported() && f->RPM() <= 0) {
|
if (f->RPM() <= 0) {
|
||||||
BOOST_LOG_TRIVIAL(warning) << "Fan stopped completely!";
|
BOOST_LOG_TRIVIAL(warning) << "Fan stopped completely!";
|
||||||
f->PWM(f->StartPWM());
|
f->PWM(f->StartPWM());
|
||||||
f->AdjustPWMLimits();
|
f->AdjustPWMLimits();
|
||||||
@@ -54,8 +50,14 @@ void FanCurve::DoFanControl() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dummy Implementation using AVG
|
||||||
int FanCurve::AggregateTemperature() {
|
int FanCurve::AggregateTemperature() {
|
||||||
return mAggregator->aggregate(mTempSensors);
|
int sum = 0;
|
||||||
|
for (auto s : mTempSensors) {
|
||||||
|
sum += s->value();
|
||||||
|
}
|
||||||
|
|
||||||
|
return sum / mTempSensors.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FanCurve::PrintInfo() {
|
void FanCurve::PrintInfo() {
|
||||||
@@ -87,10 +89,4 @@ void FanCurve::PrintInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(info) << sStream.str();
|
BOOST_LOG_TRIVIAL(info) << sStream.str();
|
||||||
|
|
||||||
sStream.str(string());
|
|
||||||
|
|
||||||
sStream << "Aggregate function: " << mAggregator->toString();
|
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(info) << sStream.str();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,12 +39,6 @@ void HwmonFan::StartPWM(int value) { mStartPWM = value; }
|
|||||||
|
|
||||||
int HwmonFan::StartPWM() { return mStartPWM; }
|
int HwmonFan::StartPWM() { return mStartPWM; }
|
||||||
|
|
||||||
void HwmonFan::ZeroFanModeSupported(bool value) {
|
|
||||||
mZeroFanModeSupported = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HwmonFan::ZeroFanModeSupported() { return mZeroFanModeSupported; }
|
|
||||||
|
|
||||||
void HwmonFan::FindPWMLimits() {
|
void HwmonFan::FindPWMLimits() {
|
||||||
cout << "Looking for minimal PWM" << endl;
|
cout << "Looking for minimal PWM" << endl;
|
||||||
int minPWM = 0;
|
int minPWM = 0;
|
||||||
@@ -101,9 +95,11 @@ void HwmonFan::AdjustPWMLimits() {
|
|||||||
|
|
||||||
json HwmonFan::toJson() const {
|
json HwmonFan::toJson() const {
|
||||||
json obj;
|
json obj;
|
||||||
obj = {mPWMControl->toJson(), mRpmSensor->toJson(),
|
obj = {mPWMControl->toJson(),
|
||||||
{"Label", mLabel}, {"MinPWM", mMinPWM},
|
mRpmSensor->toJson(),
|
||||||
{"StartPWM", mStartPWM}, {"ZeroFan", mZeroFanModeSupported}};
|
{"Label", mLabel},
|
||||||
|
{"MinPWM", mMinPWM},
|
||||||
|
{"StartPWM", mStartPWM}};
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <App.h>
|
#include <App.h>
|
||||||
|
|
||||||
#define PROJECT_VERSION "v0.2.1"
|
#define PROJECT_VERSION "v0.1.6"
|
||||||
|
|
||||||
namespace po = boost::program_options;
|
namespace po = boost::program_options;
|
||||||
namespace logging = boost::log;
|
namespace logging = boost::log;
|
||||||
|
|||||||
@@ -15,9 +15,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
namespace fs = filesystem;
|
namespace fs = filesystem;
|
||||||
|
|
||||||
PWMControl::PWMControl(string controlPath)
|
PWMControl::PWMControl(string controlPath) : mControlPath(controlPath) {
|
||||||
: mControlPath(controlPath)
|
|
||||||
{
|
|
||||||
fs::path pathEnable(mControlPath + PWM_POSTFIX_ENABLE);
|
fs::path pathEnable(mControlPath + PWM_POSTFIX_ENABLE);
|
||||||
fs::path pathMode(mControlPath + PWM_POSTFIX_MODE);
|
fs::path pathMode(mControlPath + PWM_POSTFIX_MODE);
|
||||||
|
|
||||||
@@ -37,24 +35,21 @@ PWMControl::PWMControl(string controlPath)
|
|||||||
istrm.close();
|
istrm.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
PWMControl::~PWMControl()
|
PWMControl::~PWMControl() {
|
||||||
{
|
|
||||||
BOOST_LOG_FUNCTION();
|
BOOST_LOG_FUNCTION();
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(trace) << "Cleanup";
|
BOOST_LOG_TRIVIAL(trace) << "Cleanup";
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void PWMControl::Power(int percent) {
|
||||||
PWMControl::Power(int percent)
|
|
||||||
{
|
|
||||||
BOOST_LOG_FUNCTION();
|
BOOST_LOG_FUNCTION();
|
||||||
|
|
||||||
int pwmValue = (PWM_MAX_VALUE * percent) / 100;
|
int pwmValue = (PWM_MAX_VALUE * percent) / 100;
|
||||||
|
|
||||||
if (percent != mCurrentValue) {
|
if (percent != mCurrentValue) {
|
||||||
BOOST_LOG_TRIVIAL(trace) << "Updating control value of " << toString()
|
BOOST_LOG_TRIVIAL(trace)
|
||||||
<< " to " << percent << "% (" << pwmValue << ")";
|
<< "Updating control value to " << percent << "% (" << pwmValue << ")";
|
||||||
ofstream ostrm(mControlPath, ios::trunc);
|
ofstream ostrm(mControlPath, ios::trunc);
|
||||||
ostrm << pwmValue;
|
ostrm << pwmValue;
|
||||||
ostrm.close();
|
ostrm.close();
|
||||||
@@ -63,9 +58,7 @@ PWMControl::Power(int percent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int PWMControl::Power() {
|
||||||
PWMControl::Power()
|
|
||||||
{
|
|
||||||
int value;
|
int value;
|
||||||
ifstream istrm;
|
ifstream istrm;
|
||||||
|
|
||||||
@@ -75,17 +68,13 @@ PWMControl::Power()
|
|||||||
return (value * 100) / PWM_MAX_VALUE;
|
return (value * 100) / PWM_MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void PWMControl::EnableManualControl() {
|
||||||
PWMControl::EnableManualControl()
|
|
||||||
{
|
|
||||||
ofstream ostrm(mEnablePath, ios::trunc);
|
ofstream ostrm(mEnablePath, ios::trunc);
|
||||||
ostrm << static_cast<int>(PWM_ENABLE::MANUAL_CONTROL);
|
ostrm << static_cast<int>(PWM_ENABLE::MANUAL_CONTROL);
|
||||||
ostrm.close();
|
ostrm.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void PWMControl::Reset() {
|
||||||
PWMControl::Reset()
|
|
||||||
{
|
|
||||||
ofstream ostrm(mEnablePath, ios::trunc);
|
ofstream ostrm(mEnablePath, ios::trunc);
|
||||||
|
|
||||||
ostrm << mInitialEnable;
|
ostrm << mInitialEnable;
|
||||||
@@ -97,15 +86,11 @@ PWMControl::Reset()
|
|||||||
ostrm.close();
|
ostrm.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
const string
|
const string PWMControl::toString() const {
|
||||||
PWMControl::toString() const
|
|
||||||
{
|
|
||||||
return fs::path(mControlPath).filename();
|
return fs::path(mControlPath).filename();
|
||||||
}
|
}
|
||||||
|
|
||||||
json
|
json PWMControl::toJson() const {
|
||||||
PWMControl::toJson() const
|
json obj = {"PWMControl", mControlPath};
|
||||||
{
|
|
||||||
json obj = { "PWMControl", mControlPath };
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <boost/json/kind.hpp>
|
#include <boost/json/kind.hpp>
|
||||||
#include <sensor/LMSensor.h>
|
#include <sensor/LMSensor.h>
|
||||||
#include <sensors/sensors.h>
|
#include <sensors/sensors.h>
|
||||||
@@ -19,9 +17,7 @@ int LMSensor::value() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const string LMSensor::toString() const {
|
const string LMSensor::toString() const {
|
||||||
ostringstream os;
|
return sensors_get_label(mChipName, mFeature);
|
||||||
os << mChipName->prefix << "." << sensors_get_label(mChipName, mFeature);
|
|
||||||
return os.str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
json LMSensor::toJson() const {
|
json LMSensor::toJson() const {
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
#include <include/nvml.h>
|
#ifdef HAVE_NVML
|
||||||
|
|
||||||
|
#include <include/nvml.h>
|
||||||
#include <sensor/NvidiaSensor.h>
|
#include <sensor/NvidiaSensor.h>
|
||||||
|
|
||||||
|
#include <boost/json/object.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
NvidiaSensor::NvidiaSensor() { nvmlInit_v2(); }
|
NvidiaSensor::NvidiaSensor() { nvmlInit_v2(); }
|
||||||
@@ -24,3 +27,5 @@ json NvidiaSensor::toJson() const {
|
|||||||
json obj = {"NvidiaSensor", toString()};
|
json obj = {"NvidiaSensor", toString()};
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -3,21 +3,26 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
SensorManager::SensorManager()
|
SensorManager::SensorManager()
|
||||||
: mLMSensorsFacade(make_unique<LMSensorsFacade>()),
|
: mLMSensorsFacade(make_unique<LMSensorsFacade>())
|
||||||
mGPUSensorsFacade(make_unique<GPUSensorsFacade>()) {}
|
, mGPUSensorsFacade(make_unique<GPUSensorsFacade>())
|
||||||
|
{
|
||||||
vector<shared_ptr<Sensor>> SensorManager::TemperatureSensors() {
|
|
||||||
vector<shared_ptr<Sensor>> tempSensors;
|
|
||||||
|
|
||||||
tempSensors = mLMSensorsFacade->TemperatureSensors();
|
|
||||||
|
|
||||||
// auto gpuSensors = mGPUSensorsFacade->TemperatureSensors();
|
|
||||||
// tempSensors.insert(tempSensors.end(), gpuSensors.begin(),
|
|
||||||
// gpuSensors.end());
|
|
||||||
|
|
||||||
return tempSensors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<shared_ptr<Sensor>> SensorManager::RPMSensors() {
|
vector<shared_ptr<Sensor>> SensorManager::TemperatureSensors()
|
||||||
return mLMSensorsFacade->RPMSensors();
|
{
|
||||||
|
vector<shared_ptr<Sensor>> tempSensors;
|
||||||
|
|
||||||
|
tempSensors = mLMSensorsFacade->TemperatureSensors();
|
||||||
|
|
||||||
|
#ifdef HAVE_NVML
|
||||||
|
auto gpuSensors = mGPUSensorsFacade->TemperatureSensors();
|
||||||
|
tempSensors.insert(tempSensors.end(), gpuSensors.begin(), gpuSensors.end());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return tempSensors;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<shared_ptr<Sensor>> SensorManager::RPMSensors()
|
||||||
|
{
|
||||||
|
return mLMSensorsFacade->RPMSensors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,4 +7,4 @@ ExecStart=/usr/local/bin/fantasize
|
|||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=graphical.target
|
WantedBy=multi-user.target
|
||||||
|
|||||||
Reference in New Issue
Block a user