1abf8da36SMatt Spinler #pragma once 2abf8da36SMatt Spinler 30d0e3554SMatthew Barth #include <fmt/format.h> 40d0e3554SMatthew Barth 50d0e3554SMatthew Barth #include <phosphor-logging/log.hpp> 6abf8da36SMatt Spinler #include <sdbusplus/bus.hpp> 7*3ea9ec2bSPatrick Williams #include <sdbusplus/bus/match.hpp> 88fd879fbSWilliam A. Kennington III #include <sdeventplus/clock.hpp> 91cfc2f11SWilliam A. Kennington III #include <sdeventplus/event.hpp> 108fd879fbSWilliam A. Kennington III #include <sdeventplus/utility/timer.hpp> 11abf8da36SMatt Spinler 12177fe986SMatthew Barth #include <chrono> 137c23a049SMatthew Barth #include <utility> 14177fe986SMatthew Barth 15abf8da36SMatt Spinler namespace phosphor 16abf8da36SMatt Spinler { 17abf8da36SMatt Spinler namespace fan 18abf8da36SMatt Spinler { 19abf8da36SMatt Spinler namespace monitor 20abf8da36SMatt Spinler { 21abf8da36SMatt Spinler 22abf8da36SMatt Spinler class Fan; 23abf8da36SMatt Spinler 2478689dd7SMatt Spinler constexpr auto FAN_SENSOR_PATH = "/xyz/openbmc_project/sensors/fan_tach/"; 25abf8da36SMatt Spinler 26abf8da36SMatt Spinler /** 270a9fe160SMatthew Barth * The mode fan monitor will run in: 280a9fe160SMatthew Barth * - init - only do the initialization steps 290a9fe160SMatthew Barth * - monitor - run normal monitoring algorithm 300a9fe160SMatthew Barth */ 310a9fe160SMatthew Barth enum class Mode 320a9fe160SMatthew Barth { 330a9fe160SMatthew Barth init, 340a9fe160SMatthew Barth monitor 350a9fe160SMatthew Barth }; 360a9fe160SMatthew Barth 370a9fe160SMatthew Barth /** 383800ae71SMatthew Barth * The mode that the timer is running in: 393800ae71SMatthew Barth * - func - Transition to functional state timer 403800ae71SMatthew Barth * - nonfunc - Transition to nonfunctional state timer 413800ae71SMatthew Barth */ 423800ae71SMatthew Barth enum class TimerMode 433800ae71SMatthew Barth { 443800ae71SMatthew Barth func, 453800ae71SMatthew Barth nonfunc 463800ae71SMatthew Barth }; 473800ae71SMatthew Barth 483800ae71SMatthew Barth /** 4969f2f48eSJolie Ku * The mode that the method is running in: 5069f2f48eSJolie Ku * - time - Use a percentage based deviation 5169f2f48eSJolie Ku * - count - Run up/down count fault detection 5269f2f48eSJolie Ku */ 5369f2f48eSJolie Ku enum MethodMode 5469f2f48eSJolie Ku { 5569f2f48eSJolie Ku timebased = 0, 5669f2f48eSJolie Ku count 5769f2f48eSJolie Ku }; 5869f2f48eSJolie Ku 5969f2f48eSJolie Ku /** 60abf8da36SMatt Spinler * @class TachSensor 61abf8da36SMatt Spinler * 62abf8da36SMatt Spinler * This class represents the sensor that reads a tach value. 63abf8da36SMatt Spinler * It may also support a Target, which is the property used to 64abf8da36SMatt Spinler * set a speed. Since it doesn't necessarily have a Target, it 65abf8da36SMatt Spinler * won't for sure know if it is running too slow, so it leaves 66abf8da36SMatt Spinler * that determination to other code. 67abf8da36SMatt Spinler * 68abf8da36SMatt Spinler * This class has a parent Fan object that knows about all 69abf8da36SMatt Spinler * sensors for that fan. 70abf8da36SMatt Spinler */ 71abf8da36SMatt Spinler class TachSensor 72abf8da36SMatt Spinler { 73abf8da36SMatt Spinler public: 74abf8da36SMatt Spinler TachSensor() = delete; 75abf8da36SMatt Spinler TachSensor(const TachSensor&) = delete; 76fa0766e3SBrad Bishop // TachSensor is not moveable since the this pointer is used as systemd 77fa0766e3SBrad Bishop // callback context. 78fa0766e3SBrad Bishop TachSensor(TachSensor&&) = delete; 79abf8da36SMatt Spinler TachSensor& operator=(const TachSensor&) = delete; 80fa0766e3SBrad Bishop TachSensor& operator=(TachSensor&&) = delete; 81abf8da36SMatt Spinler ~TachSensor() = default; 82abf8da36SMatt Spinler 83abf8da36SMatt Spinler /** 84abf8da36SMatt Spinler * @brief Constructor 85abf8da36SMatt Spinler * 860a9fe160SMatthew Barth * @param[in] mode - mode of fan monitor 87abf8da36SMatt Spinler * @param[in] bus - the dbus object 88abf8da36SMatt Spinler * @param[in] fan - the parent fan object 89abf8da36SMatt Spinler * @param[in] id - the id of the sensor 90abf8da36SMatt Spinler * @param[in] hasTarget - if the sensor supports 91abf8da36SMatt Spinler * setting the speed 929396bcc3SMatthew Barth * @param[in] funcDelay - Delay to mark functional 9380f271b2SLei YU * @param[in] interface - the interface of the target 948e5d197bSLei YU * @param[in] factor - the factor of the sensor target 958e5d197bSLei YU * @param[in] offset - the offset of the sensor target 9669f2f48eSJolie Ku * @param[in] method - the method of out of range 9769f2f48eSJolie Ku * @param[in] threshold - the threshold of counter method 98abf8da36SMatt Spinler * @param[in] timeout - Normal timeout value to use 99f13b42e2SMatt Spinler * @param[in] errorDelay - Delay in seconds before creating an error 100f13b42e2SMatt Spinler * or std::nullopt if no errors. 101fdfcc679SMatt Spinler * @param[in] countInterval - In count mode interval 102f13b42e2SMatt Spinler * 1031cfc2f11SWilliam A. Kennington III * @param[in] event - Event loop reference 104abf8da36SMatt Spinler */ 105177fe986SMatthew Barth TachSensor(Mode mode, sdbusplus::bus::bus& bus, Fan& fan, 106177fe986SMatthew Barth const std::string& id, bool hasTarget, size_t funcDelay, 107177fe986SMatthew Barth const std::string& interface, double factor, int64_t offset, 10869f2f48eSJolie Ku size_t method, size_t threshold, size_t timeout, 109fdfcc679SMatt Spinler const std::optional<size_t>& errorDelay, size_t countInterval, 110f13b42e2SMatt Spinler const sdeventplus::Event& event); 111abf8da36SMatt Spinler 112abf8da36SMatt Spinler /** 113c8c8ccf3SMatthew Barth * @brief Reads a property from the input message and stores it in value. 114c8c8ccf3SMatthew Barth * T is the value type. 115c8c8ccf3SMatthew Barth * 116c8c8ccf3SMatthew Barth * Note: This can only be called once per message. 117c8c8ccf3SMatthew Barth * 118c8c8ccf3SMatthew Barth * @param[in] msg - the dbus message that contains the data 119c8c8ccf3SMatthew Barth * @param[in] interface - the interface the property is on 120c8c8ccf3SMatthew Barth * @param[in] propertName - the name of the property 121c8c8ccf3SMatthew Barth * @param[out] value - the value to store the property value in 122c8c8ccf3SMatthew Barth */ 123c8c8ccf3SMatthew Barth template <typename T> 124c8c8ccf3SMatthew Barth static void readPropertyFromMessage(sdbusplus::message::message& msg, 125c8c8ccf3SMatthew Barth const std::string& interface, 126c8c8ccf3SMatthew Barth const std::string& propertyName, 127c8c8ccf3SMatthew Barth T& value) 128c8c8ccf3SMatthew Barth { 129c8c8ccf3SMatthew Barth std::string sensor; 130c8c8ccf3SMatthew Barth std::map<std::string, std::variant<T>> data; 131c8c8ccf3SMatthew Barth msg.read(sensor, data); 132c8c8ccf3SMatthew Barth 133c8c8ccf3SMatthew Barth if (sensor.compare(interface) == 0) 134c8c8ccf3SMatthew Barth { 135c8c8ccf3SMatthew Barth auto propertyMap = data.find(propertyName); 136c8c8ccf3SMatthew Barth if (propertyMap != data.end()) 137c8c8ccf3SMatthew Barth { 138c8c8ccf3SMatthew Barth value = std::get<T>(propertyMap->second); 139c8c8ccf3SMatthew Barth } 140c8c8ccf3SMatthew Barth } 141c8c8ccf3SMatthew Barth } 142c8c8ccf3SMatthew Barth 143c8c8ccf3SMatthew Barth /** 144abf8da36SMatt Spinler * @brief Returns the target speed value 145abf8da36SMatt Spinler */ 146f552ea5cSMatthew Barth uint64_t getTarget() const; 147abf8da36SMatt Spinler 148abf8da36SMatt Spinler /** 149abf8da36SMatt Spinler * @brief Returns the input speed value 150abf8da36SMatt Spinler */ 1510891e3b3SMatthew Barth inline double getInput() const 152abf8da36SMatt Spinler { 153abf8da36SMatt Spinler return _tachInput; 154abf8da36SMatt Spinler } 155abf8da36SMatt Spinler 156abf8da36SMatt Spinler /** 157abf8da36SMatt Spinler * @brief Returns true if sensor has a target 158abf8da36SMatt Spinler */ 159abf8da36SMatt Spinler inline bool hasTarget() const 160abf8da36SMatt Spinler { 161abf8da36SMatt Spinler return _hasTarget; 162abf8da36SMatt Spinler } 163abf8da36SMatt Spinler 164abf8da36SMatt Spinler /** 16580f271b2SLei YU * @brief Returns the interface of the sensor target 16680f271b2SLei YU */ 16780f271b2SLei YU inline std::string getInterface() const 16880f271b2SLei YU { 16980f271b2SLei YU return _interface; 17080f271b2SLei YU } 17180f271b2SLei YU 17280f271b2SLei YU /** 173fdcd5db3SMike Capps * @brief Returns true if sensor has a D-Bus owner 174fdcd5db3SMike Capps */ 175fdcd5db3SMike Capps inline bool hasOwner() const 176fdcd5db3SMike Capps { 177fdcd5db3SMike Capps return _hasOwner; 178fdcd5db3SMike Capps } 179fdcd5db3SMike Capps 180fdcd5db3SMike Capps /** 181fdcd5db3SMike Capps * @brief sets D-Bus owner status 182fdcd5db3SMike Capps * 183fdcd5db3SMike Capps * @param[in] val - new owner status 184fdcd5db3SMike Capps */ 185fdcd5db3SMike Capps inline void setOwner(bool val) 186fdcd5db3SMike Capps { 187fdcd5db3SMike Capps _hasOwner = val; 188fdcd5db3SMike Capps } 189fdcd5db3SMike Capps 190fdcd5db3SMike Capps /** 1918e5d197bSLei YU * @brief Returns the factor of the sensor target 1928e5d197bSLei YU */ 1935e7298c5SMatthew Barth inline double getFactor() const 1948e5d197bSLei YU { 1958e5d197bSLei YU return _factor; 1968e5d197bSLei YU } 1978e5d197bSLei YU 1988e5d197bSLei YU /** 199fdcd5db3SMike Capps * @brief Returns a reference to the sensor's Fan object 200fdcd5db3SMike Capps */ 201fdcd5db3SMike Capps inline Fan& getFan() const 202fdcd5db3SMike Capps { 203fdcd5db3SMike Capps return _fan; 204fdcd5db3SMike Capps } 205fdcd5db3SMike Capps 206fdcd5db3SMike Capps /** 2078e5d197bSLei YU * @brief Returns the offset of the sensor target 2088e5d197bSLei YU */ 2094eac3cf9SLei YU inline int64_t getOffset() const 2108e5d197bSLei YU { 2118e5d197bSLei YU return _offset; 2128e5d197bSLei YU } 2138e5d197bSLei YU 2148e5d197bSLei YU /** 21569f2f48eSJolie Ku * @brief Returns the method of out of range 21669f2f48eSJolie Ku */ 21769f2f48eSJolie Ku inline size_t getMethod() const 21869f2f48eSJolie Ku { 21969f2f48eSJolie Ku return _method; 22069f2f48eSJolie Ku } 22169f2f48eSJolie Ku 22269f2f48eSJolie Ku /** 22369f2f48eSJolie Ku * @brief Returns the threshold of count method 22469f2f48eSJolie Ku */ 22569f2f48eSJolie Ku inline size_t getThreshold() const 22669f2f48eSJolie Ku { 22769f2f48eSJolie Ku return _threshold; 22869f2f48eSJolie Ku } 22969f2f48eSJolie Ku 23069f2f48eSJolie Ku /** 23169f2f48eSJolie Ku * Set the sensor faulted counter 23269f2f48eSJolie Ku */ 23369f2f48eSJolie Ku void setCounter(bool count); 23469f2f48eSJolie Ku 23569f2f48eSJolie Ku /** 23669f2f48eSJolie Ku * @brief Returns the sensor faulted count 23769f2f48eSJolie Ku */ 23869f2f48eSJolie Ku inline size_t getCounter() const 23969f2f48eSJolie Ku { 24069f2f48eSJolie Ku return _counter; 24169f2f48eSJolie Ku } 24269f2f48eSJolie Ku 24369f2f48eSJolie Ku /** 244abf8da36SMatt Spinler * Returns true if the hardware behind this 245abf8da36SMatt Spinler * sensor is considered working OK/functional. 246abf8da36SMatt Spinler */ 247abf8da36SMatt Spinler inline bool functional() const 248abf8da36SMatt Spinler { 249abf8da36SMatt Spinler return _functional; 250abf8da36SMatt Spinler } 251abf8da36SMatt Spinler 252abf8da36SMatt Spinler /** 253d199dcdfSMatthew Barth * Set the functional status and update inventory to match 254abf8da36SMatt Spinler */ 255d199dcdfSMatthew Barth void setFunctional(bool functional); 256abf8da36SMatt Spinler 257a9406a77SMatt Spinler /** 2586fa181c7SMatt Spinler * @brief Says if the timer is running or not 2596fa181c7SMatt Spinler * 2606fa181c7SMatt Spinler * @return bool - if timer is currently running 261a9406a77SMatt Spinler */ 2626fa181c7SMatt Spinler inline bool timerRunning() 263a9406a77SMatt Spinler { 2648fd879fbSWilliam A. Kennington III return _timer.isEnabled(); 2656fa181c7SMatt Spinler } 2666fa181c7SMatt Spinler 2676fa181c7SMatt Spinler /** 2683800ae71SMatthew Barth * @brief Stops the timer when the given mode differs and starts 2693800ae71SMatthew Barth * the associated timer for the mode given if not already running 2703800ae71SMatthew Barth * 2713800ae71SMatthew Barth * @param[in] mode - mode of timer to start 2726fa181c7SMatt Spinler */ 2733800ae71SMatthew Barth void startTimer(TimerMode mode); 2746fa181c7SMatt Spinler 2756fa181c7SMatt Spinler /** 2766fa181c7SMatt Spinler * @brief Stops the timer 2776fa181c7SMatt Spinler */ 2786fa181c7SMatt Spinler inline void stopTimer() 2796fa181c7SMatt Spinler { 2801d7379eaSMatt Spinler phosphor::logging::log<phosphor::logging::level::DEBUG>( 2810d0e3554SMatthew Barth fmt::format("Stop running timer on tach sensor {}.", _name) 2820d0e3554SMatthew Barth .c_str()); 2838fd879fbSWilliam A. Kennington III _timer.setEnabled(false); 284a9406a77SMatt Spinler } 285a9406a77SMatt Spinler 286a9406a77SMatt Spinler /** 287fdfcc679SMatt Spinler * @brief Says if the count timer is running 288fdfcc679SMatt Spinler * 289fdfcc679SMatt Spinler * @return bool - If count timer running 290fdfcc679SMatt Spinler */ 291fdfcc679SMatt Spinler inline bool countTimerRunning() const 292fdfcc679SMatt Spinler { 293fdfcc679SMatt Spinler return _countTimer && _countTimer->isEnabled(); 294fdfcc679SMatt Spinler } 295fdfcc679SMatt Spinler 296fdfcc679SMatt Spinler /** 297fdfcc679SMatt Spinler * @brief Stops the count timer 298fdfcc679SMatt Spinler */ 299fdfcc679SMatt Spinler void stopCountTimer(); 300fdfcc679SMatt Spinler 301fdfcc679SMatt Spinler /** 302fdfcc679SMatt Spinler * @brief Starts the count timer 303fdfcc679SMatt Spinler */ 304fdfcc679SMatt Spinler void startCountTimer(); 305fdfcc679SMatt Spinler 306fdfcc679SMatt Spinler /** 3073800ae71SMatthew Barth * @brief Return the given timer mode's delay time 3083800ae71SMatthew Barth * 3093800ae71SMatthew Barth * @param[in] mode - mode of timer to get delay time for 310a9406a77SMatt Spinler */ 3113800ae71SMatthew Barth std::chrono::microseconds getDelay(TimerMode mode); 312a9406a77SMatt Spinler 313ce75b511SMatt Spinler /** 314ce75b511SMatt Spinler * Returns the sensor name 315ce75b511SMatt Spinler */ 316ce75b511SMatt Spinler inline const std::string& name() const 317ce75b511SMatt Spinler { 318ce75b511SMatt Spinler return _name; 319ce75b511SMatt Spinler }; 320ce75b511SMatt Spinler 321f13b42e2SMatt Spinler /** 322f13b42e2SMatt Spinler * @brief Says if the error timer is running 323f13b42e2SMatt Spinler * 324f13b42e2SMatt Spinler * @return bool - If the timer is running 325f13b42e2SMatt Spinler */ 326f13b42e2SMatt Spinler bool errorTimerRunning() const 327f13b42e2SMatt Spinler { 328f13b42e2SMatt Spinler if (_errorTimer && _errorTimer->isEnabled()) 329f13b42e2SMatt Spinler { 330f13b42e2SMatt Spinler return true; 331f13b42e2SMatt Spinler } 332f13b42e2SMatt Spinler return false; 333f13b42e2SMatt Spinler } 334f13b42e2SMatt Spinler 3357c23a049SMatthew Barth /** 3367c23a049SMatthew Barth * @brief Get the current allowed range of speeds 3377c23a049SMatthew Barth * 3387c23a049SMatthew Barth * @param[in] deviation - The configured deviation(in percent) allowed 3397c23a049SMatthew Barth * 3407c23a049SMatthew Barth * @return pair - Min/Max range of speeds allowed 3417c23a049SMatthew Barth */ 3427c23a049SMatthew Barth std::pair<uint64_t, uint64_t> getRange(const size_t deviation) const; 3437c23a049SMatthew Barth 344fcb0dbcbSMatthew Barth /** 345fcb0dbcbSMatthew Barth * @brief Processes the current state of the sensor 346fcb0dbcbSMatthew Barth */ 347fcb0dbcbSMatthew Barth void processState(); 348fcb0dbcbSMatthew Barth 349fcb0dbcbSMatthew Barth /** 350fcb0dbcbSMatthew Barth * @brief Resets the monitoring method of the sensor 351fcb0dbcbSMatthew Barth */ 352fcb0dbcbSMatthew Barth void resetMethod(); 353fcb0dbcbSMatthew Barth 3544283c5d5SMatt Spinler /** 3554283c5d5SMatt Spinler * @brief Refreshes the tach input and target values by 3564283c5d5SMatt Spinler * reading them from D-Bus. 3574283c5d5SMatt Spinler */ 3584283c5d5SMatt Spinler void updateTachAndTarget(); 3594283c5d5SMatt Spinler 360abf8da36SMatt Spinler private: 361abf8da36SMatt Spinler /** 362ebaae611SMatt Spinler * @brief Returns the match string to use for matching 363ebaae611SMatt Spinler * on a properties changed signal. 364ebaae611SMatt Spinler */ 365ebaae611SMatt Spinler std::string getMatchString(const std::string& interface); 366ebaae611SMatt Spinler 367ebaae611SMatt Spinler /** 368ebaae611SMatt Spinler * @brief Reads the Target property and stores in _tachTarget. 369ebaae611SMatt Spinler * Also calls Fan::tachChanged(). 370ebaae611SMatt Spinler * 371ebaae611SMatt Spinler * @param[in] msg - the dbus message 372ebaae611SMatt Spinler */ 373771659fcSBrad Bishop void handleTargetChange(sdbusplus::message::message& msg); 374ebaae611SMatt Spinler 375ebaae611SMatt Spinler /** 376ebaae611SMatt Spinler * @brief Reads the Value property and stores in _tachInput. 377ebaae611SMatt Spinler * Also calls Fan::tachChanged(). 378ebaae611SMatt Spinler * 379ebaae611SMatt Spinler * @param[in] msg - the dbus message 380ebaae611SMatt Spinler */ 381771659fcSBrad Bishop void handleTachChange(sdbusplus::message::message& msg); 382ebaae611SMatt Spinler 3834d982856SMatthew Barth /** 3844d982856SMatthew Barth * @brief Updates the Functional property in the inventory 3854d982856SMatthew Barth * for this tach sensor based on the value passed in. 3864d982856SMatthew Barth * 3874d982856SMatthew Barth * @param[in] functional - If the Functional property should 3884d982856SMatthew Barth * be set to true or false. 3894d982856SMatthew Barth */ 3904d982856SMatthew Barth void updateInventory(bool functional); 391ebaae611SMatt Spinler 392ebaae611SMatt Spinler /** 393abf8da36SMatt Spinler * @brief the dbus object 394abf8da36SMatt Spinler */ 395abf8da36SMatt Spinler sdbusplus::bus::bus& _bus; 396abf8da36SMatt Spinler 397abf8da36SMatt Spinler /** 398abf8da36SMatt Spinler * @brief Reference to the parent Fan object 399abf8da36SMatt Spinler */ 400abf8da36SMatt Spinler Fan& _fan; 401abf8da36SMatt Spinler 402abf8da36SMatt Spinler /** 403abf8da36SMatt Spinler * @brief The name of the sensor, including the full path 404abf8da36SMatt Spinler * 405abf8da36SMatt Spinler * For example /xyz/openbmc_project/sensors/fan_tach/fan0 406abf8da36SMatt Spinler */ 407abf8da36SMatt Spinler const std::string _name; 408abf8da36SMatt Spinler 409abf8da36SMatt Spinler /** 4104d982856SMatthew Barth * @brief The inventory name of the sensor, including the full path 4114d982856SMatthew Barth */ 4124d982856SMatthew Barth const std::string _invName; 4134d982856SMatthew Barth 4144d982856SMatthew Barth /** 415abf8da36SMatt Spinler * @brief If functional (not too slow). The parent 416abf8da36SMatt Spinler * fan object sets this. 417abf8da36SMatt Spinler */ 418d199dcdfSMatthew Barth bool _functional; 419abf8da36SMatt Spinler 420abf8da36SMatt Spinler /** 421abf8da36SMatt Spinler * @brief If the sensor has a Target property (can set speed) 422abf8da36SMatt Spinler */ 423abf8da36SMatt Spinler const bool _hasTarget; 424abf8da36SMatt Spinler 425abf8da36SMatt Spinler /** 426fdcd5db3SMike Capps * @brief If the sensor has a D-Bus owner 427fdcd5db3SMike Capps */ 428fdcd5db3SMike Capps bool _hasOwner = true; 429fdcd5db3SMike Capps 430fdcd5db3SMike Capps /** 4319396bcc3SMatthew Barth * @brief Amount of time to delay updating to functional 4329396bcc3SMatthew Barth */ 4339396bcc3SMatthew Barth const size_t _funcDelay; 4349396bcc3SMatthew Barth 4359396bcc3SMatthew Barth /** 43680f271b2SLei YU * @brief The interface that the target implements 43780f271b2SLei YU */ 43880f271b2SLei YU const std::string _interface; 43980f271b2SLei YU 44080f271b2SLei YU /** 4418e5d197bSLei YU * @brief The factor of target to get fan rpm 4428e5d197bSLei YU */ 4435e7298c5SMatthew Barth const double _factor; 4448e5d197bSLei YU 4458e5d197bSLei YU /** 4468e5d197bSLei YU * @brief The offset of target to get fan rpm 4478e5d197bSLei YU */ 4484eac3cf9SLei YU const int64_t _offset; 4498e5d197bSLei YU 4508e5d197bSLei YU /** 45169f2f48eSJolie Ku * @brief The method of out of range 45269f2f48eSJolie Ku */ 45369f2f48eSJolie Ku const size_t _method; 45469f2f48eSJolie Ku 45569f2f48eSJolie Ku /** 45669f2f48eSJolie Ku * @brief The threshold for count method 45769f2f48eSJolie Ku */ 45869f2f48eSJolie Ku const size_t _threshold; 45969f2f48eSJolie Ku 46069f2f48eSJolie Ku /** 46169f2f48eSJolie Ku * @brief The counter for count method 46269f2f48eSJolie Ku */ 46369f2f48eSJolie Ku size_t _counter = 0; 46469f2f48eSJolie Ku 46569f2f48eSJolie Ku /** 466abf8da36SMatt Spinler * @brief The input speed, from the Value dbus property 467abf8da36SMatt Spinler */ 4680891e3b3SMatthew Barth double _tachInput = 0; 469abf8da36SMatt Spinler 470abf8da36SMatt Spinler /** 471abf8da36SMatt Spinler * @brief The current target speed, from the Target dbus property 472abf8da36SMatt Spinler * (if applicable) 473abf8da36SMatt Spinler */ 474abf8da36SMatt Spinler uint64_t _tachTarget = 0; 475abf8da36SMatt Spinler 476abf8da36SMatt Spinler /** 477abf8da36SMatt Spinler * @brief The timeout value to use 478abf8da36SMatt Spinler */ 479abf8da36SMatt Spinler const size_t _timeout; 480ebaae611SMatt Spinler 481ebaae611SMatt Spinler /** 4823800ae71SMatthew Barth * @brief Mode that current timer is in 4833800ae71SMatthew Barth */ 4843800ae71SMatthew Barth TimerMode _timerMode; 4853800ae71SMatthew Barth 4863800ae71SMatthew Barth /** 487a9406a77SMatt Spinler * The timer object 488a9406a77SMatt Spinler */ 4898fd879fbSWilliam A. Kennington III sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> _timer; 490a9406a77SMatt Spinler 491a9406a77SMatt Spinler /** 492ebaae611SMatt Spinler * @brief The match object for the Value properties changed signal 493ebaae611SMatt Spinler */ 494*3ea9ec2bSPatrick Williams std::unique_ptr<sdbusplus::bus::match_t> tachSignal; 495ebaae611SMatt Spinler 496ebaae611SMatt Spinler /** 497ebaae611SMatt Spinler * @brief The match object for the Target properties changed signal 498ebaae611SMatt Spinler */ 499*3ea9ec2bSPatrick Williams std::unique_ptr<sdbusplus::bus::match_t> targetSignal; 500f13b42e2SMatt Spinler 501f13b42e2SMatt Spinler /** 502f13b42e2SMatt Spinler * @brief The number of seconds to wait between a sensor being set 503f13b42e2SMatt Spinler * to nonfunctional and creating an error for it. 504f13b42e2SMatt Spinler * 505f13b42e2SMatt Spinler * If std::nullopt, no errors will be created. 506f13b42e2SMatt Spinler */ 507f13b42e2SMatt Spinler const std::optional<size_t> _errorDelay; 508f13b42e2SMatt Spinler 509f13b42e2SMatt Spinler /** 510f13b42e2SMatt Spinler * @brief The timer that uses _errorDelay. When it expires an error 511f13b42e2SMatt Spinler * will be created for a faulted fan sensor (rotor). 512f13b42e2SMatt Spinler * 513f13b42e2SMatt Spinler * If _errorDelay is std::nullopt, then this won't be created. 514f13b42e2SMatt Spinler */ 515f13b42e2SMatt Spinler std::unique_ptr< 516f13b42e2SMatt Spinler sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>> 517f13b42e2SMatt Spinler _errorTimer; 518fdfcc679SMatt Spinler 519fdfcc679SMatt Spinler /** 520fdfcc679SMatt Spinler * @brief The interval, in seconds, to use for the timer that runs 521fdfcc679SMatt Spinler * the checks when using the 'count' method. 522fdfcc679SMatt Spinler */ 523fdfcc679SMatt Spinler size_t _countInterval; 524fdfcc679SMatt Spinler 525fdfcc679SMatt Spinler /** 526fdfcc679SMatt Spinler * @brief The timer used by the 'count' method for determining 527fdfcc679SMatt Spinler * functional status. 528fdfcc679SMatt Spinler */ 529fdfcc679SMatt Spinler std::unique_ptr< 530fdfcc679SMatt Spinler sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>> 531fdfcc679SMatt Spinler _countTimer; 532abf8da36SMatt Spinler }; 533abf8da36SMatt Spinler 534177fe986SMatthew Barth } // namespace monitor 535177fe986SMatthew Barth } // namespace fan 536177fe986SMatthew Barth } // namespace phosphor 537