forked from vmatare/thinkfan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfans.h
104 lines (81 loc) · 2.86 KB
/
fans.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once
/********************************************************************
* config.h: Config data structures and consistency checking.
* (C) 2015, Victor Mataré
*
* this file is part of thinkfan. See thinkfan.c for further information.
*
* thinkfan is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* thinkfan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with thinkfan. If not, see <http://www.gnu.org/licenses/>.
*
* ******************************************************************/
#include <string>
#include "thinkfan.h"
#include "driver.h"
#include "hwmon.h"
namespace thinkfan {
class Level;
class FanDriver : public Driver {
protected:
FanDriver(bool optional, const unsigned int watchdog_timeout = 120, opt<unsigned int> max_errors = nullopt);
public:
bool is_default() { return path().length() == 0; }
virtual ~FanDriver() noexcept(false);
virtual void set_speed(const Level &level) = 0;
const string ¤t_speed() const;
virtual void ping_watchdog_and_depulse(const Level &) {}
bool operator == (const FanDriver &other) const;
protected:
void set_speed(const string &level);
string initial_state_;
string current_speed_;
seconds watchdog_;
secondsf depulse_;
std::chrono::system_clock::time_point last_watchdog_ping_;
private:
virtual void skip_io_error(const ExpectedError &e) override;
void set_speed_(const string &level);
};
class TpFanDriver : public FanDriver {
public:
TpFanDriver(const string &path, bool optional = false, opt<unsigned int> max_errors = nullopt);
virtual ~TpFanDriver() noexcept(false) override;
void set_watchdog(const unsigned int timeout);
void set_depulse(float duration);
virtual void set_speed(const Level &level) override;
virtual void ping_watchdog_and_depulse(const Level &level) override;
protected:
virtual void init() override;
virtual string lookup() override;
virtual string type_name() const override;
private:
const string path_;
};
class HwmonFanDriver : public FanDriver {
public:
HwmonFanDriver(const string &path);
HwmonFanDriver(
shared_ptr<HwmonInterface<FanDriver>> hwmon_interface,
bool optional,
opt<unsigned int> max_errors = nullopt
);
virtual ~HwmonFanDriver() noexcept(false) override;
virtual void set_speed(const Level &level) override;
protected:
virtual void init() override;
virtual string lookup() override;
virtual string type_name() const override;
private:
shared_ptr<HwmonInterface<FanDriver>> hwmon_interface_;
};
}