diff options
| author | Patrick Venture <venture@google.com> | 2019-02-08 09:30:49 -0800 |
|---|---|---|
| committer | Patrick Venture <venture@google.com> | 2019-02-08 10:24:18 -0800 |
| commit | a510ea2b5a2bba96cc5b2bdc4541b2f68b8cf299 (patch) | |
| tree | eb6bc7ae4d66b0869c9f023bb73917b25a203a46 /sensors | |
| parent | 572c43dab62f9e207781b96e7e48b7b38ca024e5 (diff) | |
| download | phosphor-pid-control-a510ea2b5a2bba96cc5b2bdc4541b2f68b8cf299.tar.gz phosphor-pid-control-a510ea2b5a2bba96cc5b2bdc4541b2f68b8cf299.zip | |
sensors: add method to grab default timeout
Add a central method for grabbing the default timeout for a sensor.
This is required to allow for a configuration to leave out an
unnecessary field.
Change-Id: I29ecd9db67b1eb1e66e60ef49859926cf14a4542
Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'sensors')
| -rw-r--r-- | sensors/sensor.hpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sensors/sensor.hpp b/sensors/sensor.hpp index 6df5aa2..2dbfa30 100644 --- a/sensors/sensor.hpp +++ b/sensors/sensor.hpp @@ -11,6 +11,20 @@ class Sensor { public: + /** + * Given a sensor's type, return the default timeout value. + * A timeout of 0 means there isn't a timeout for this sensor. + * By default a fan sensor isn't checked for a timeout, whereas + * any of sensor is meant to be sampled once per second. By default. + * + * @param[in] type - the sensor type (e.g. fan) + * @return the default timeout for that type (in seconds). + */ + static int64_t getDefaultTimeout(const std::string& type) + { + return (type == "fan") ? 0 : 2; + } + Sensor(const std::string& name, int64_t timeout) : _name(name), _timeout(timeout) { |

