1abf8da36SMatt Spinler #pragma once
2abf8da36SMatt Spinler 
3*0d0e3554SMatthew Barth #include <fmt/format.h>
4*0d0e3554SMatthew Barth 
5*0d0e3554SMatthew Barth #include <phosphor-logging/log.hpp>
6abf8da36SMatt Spinler #include <sdbusplus/bus.hpp>
7abf8da36SMatt Spinler #include <sdbusplus/server.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.
101f13b42e2SMatt Spinler      *
1021cfc2f11SWilliam A. Kennington III      * @param[in] event - Event loop reference
103abf8da36SMatt Spinler      */
104177fe986SMatthew Barth     TachSensor(Mode mode, sdbusplus::bus::bus& bus, Fan& fan,
105177fe986SMatthew Barth                const std::string& id, bool hasTarget, size_t funcDelay,
106177fe986SMatthew Barth                const std::string& interface, double factor, int64_t offset,
10769f2f48eSJolie Ku                size_t method, size_t threshold, size_t timeout,
10869f2f48eSJolie Ku                const std::optional<size_t>& errorDelay,
109f13b42e2SMatt Spinler                const sdeventplus::Event& event);
110abf8da36SMatt Spinler 
111abf8da36SMatt Spinler     /**
112c8c8ccf3SMatthew Barth      * @brief Reads a property from the input message and stores it in value.
113c8c8ccf3SMatthew Barth      *        T is the value type.
114c8c8ccf3SMatthew Barth      *
115c8c8ccf3SMatthew Barth      *        Note: This can only be called once per message.
116c8c8ccf3SMatthew Barth      *
117c8c8ccf3SMatthew Barth      * @param[in] msg - the dbus message that contains the data
118c8c8ccf3SMatthew Barth      * @param[in] interface - the interface the property is on
119c8c8ccf3SMatthew Barth      * @param[in] propertName - the name of the property
120c8c8ccf3SMatthew Barth      * @param[out] value - the value to store the property value in
121c8c8ccf3SMatthew Barth      */
122c8c8ccf3SMatthew Barth     template <typename T>
123c8c8ccf3SMatthew Barth     static void readPropertyFromMessage(sdbusplus::message::message& msg,
124c8c8ccf3SMatthew Barth                                         const std::string& interface,
125c8c8ccf3SMatthew Barth                                         const std::string& propertyName,
126c8c8ccf3SMatthew Barth                                         T& value)
127c8c8ccf3SMatthew Barth     {
128c8c8ccf3SMatthew Barth         std::string sensor;
129c8c8ccf3SMatthew Barth         std::map<std::string, std::variant<T>> data;
130c8c8ccf3SMatthew Barth         msg.read(sensor, data);
131c8c8ccf3SMatthew Barth 
132c8c8ccf3SMatthew Barth         if (sensor.compare(interface) == 0)
133c8c8ccf3SMatthew Barth         {
134c8c8ccf3SMatthew Barth             auto propertyMap = data.find(propertyName);
135c8c8ccf3SMatthew Barth             if (propertyMap != data.end())
136c8c8ccf3SMatthew Barth             {
137c8c8ccf3SMatthew Barth                 value = std::get<T>(propertyMap->second);
138c8c8ccf3SMatthew Barth             }
139c8c8ccf3SMatthew Barth         }
140c8c8ccf3SMatthew Barth     }
141c8c8ccf3SMatthew Barth 
142c8c8ccf3SMatthew Barth     /**
143abf8da36SMatt Spinler      * @brief Returns the target speed value
144abf8da36SMatt Spinler      */
145f552ea5cSMatthew Barth     uint64_t getTarget() const;
146abf8da36SMatt Spinler 
147abf8da36SMatt Spinler     /**
148abf8da36SMatt Spinler      * @brief Returns the input speed value
149abf8da36SMatt Spinler      */
1500891e3b3SMatthew Barth     inline double getInput() const
151abf8da36SMatt Spinler     {
152abf8da36SMatt Spinler         return _tachInput;
153abf8da36SMatt Spinler     }
154abf8da36SMatt Spinler 
155abf8da36SMatt Spinler     /**
156abf8da36SMatt Spinler      * @brief Returns true if sensor has a target
157abf8da36SMatt Spinler      */
158abf8da36SMatt Spinler     inline bool hasTarget() const
159abf8da36SMatt Spinler     {
160abf8da36SMatt Spinler         return _hasTarget;
161abf8da36SMatt Spinler     }
162abf8da36SMatt Spinler 
163abf8da36SMatt Spinler     /**
16480f271b2SLei YU      * @brief Returns the interface of the sensor target
16580f271b2SLei YU      */
16680f271b2SLei YU     inline std::string getInterface() const
16780f271b2SLei YU     {
16880f271b2SLei YU         return _interface;
16980f271b2SLei YU     }
17080f271b2SLei YU 
17180f271b2SLei YU     /**
1728e5d197bSLei YU      * @brief Returns the factor of the sensor target
1738e5d197bSLei YU      */
1745e7298c5SMatthew Barth     inline double getFactor() const
1758e5d197bSLei YU     {
1768e5d197bSLei YU         return _factor;
1778e5d197bSLei YU     }
1788e5d197bSLei YU 
1798e5d197bSLei YU     /**
1808e5d197bSLei YU      * @brief Returns the offset of the sensor target
1818e5d197bSLei YU      */
1824eac3cf9SLei YU     inline int64_t getOffset() const
1838e5d197bSLei YU     {
1848e5d197bSLei YU         return _offset;
1858e5d197bSLei YU     }
1868e5d197bSLei YU 
1878e5d197bSLei YU     /**
18869f2f48eSJolie Ku      * @brief Returns the method of out of range
18969f2f48eSJolie Ku      */
19069f2f48eSJolie Ku     inline size_t getMethod() const
19169f2f48eSJolie Ku     {
19269f2f48eSJolie Ku         return _method;
19369f2f48eSJolie Ku     }
19469f2f48eSJolie Ku 
19569f2f48eSJolie Ku     /**
19669f2f48eSJolie Ku      * @brief Returns the threshold of count method
19769f2f48eSJolie Ku      */
19869f2f48eSJolie Ku     inline size_t getThreshold() const
19969f2f48eSJolie Ku     {
20069f2f48eSJolie Ku         return _threshold;
20169f2f48eSJolie Ku     }
20269f2f48eSJolie Ku 
20369f2f48eSJolie Ku     /**
20469f2f48eSJolie Ku      * Set the sensor faulted counter
20569f2f48eSJolie Ku      */
20669f2f48eSJolie Ku     void setCounter(bool count);
20769f2f48eSJolie Ku 
20869f2f48eSJolie Ku     /**
20969f2f48eSJolie Ku      * @brief Returns the sensor faulted count
21069f2f48eSJolie Ku      */
21169f2f48eSJolie Ku     inline size_t getCounter() const
21269f2f48eSJolie Ku     {
21369f2f48eSJolie Ku         return _counter;
21469f2f48eSJolie Ku     }
21569f2f48eSJolie Ku 
21669f2f48eSJolie Ku     /**
217abf8da36SMatt Spinler      * Returns true if the hardware behind this
218abf8da36SMatt Spinler      * sensor is considered working OK/functional.
219abf8da36SMatt Spinler      */
220abf8da36SMatt Spinler     inline bool functional() const
221abf8da36SMatt Spinler     {
222abf8da36SMatt Spinler         return _functional;
223abf8da36SMatt Spinler     }
224abf8da36SMatt Spinler 
225abf8da36SMatt Spinler     /**
226d199dcdfSMatthew Barth      * Set the functional status and update inventory to match
227abf8da36SMatt Spinler      */
228d199dcdfSMatthew Barth     void setFunctional(bool functional);
229abf8da36SMatt Spinler 
230a9406a77SMatt Spinler     /**
2316fa181c7SMatt Spinler      * @brief Says if the timer is running or not
2326fa181c7SMatt Spinler      *
2336fa181c7SMatt Spinler      * @return bool - if timer is currently running
234a9406a77SMatt Spinler      */
2356fa181c7SMatt Spinler     inline bool timerRunning()
236a9406a77SMatt Spinler     {
2378fd879fbSWilliam A. Kennington III         return _timer.isEnabled();
2386fa181c7SMatt Spinler     }
2396fa181c7SMatt Spinler 
2406fa181c7SMatt Spinler     /**
2413800ae71SMatthew Barth      * @brief Stops the timer when the given mode differs and starts
2423800ae71SMatthew Barth      * the associated timer for the mode given if not already running
2433800ae71SMatthew Barth      *
2443800ae71SMatthew Barth      * @param[in] mode - mode of timer to start
2456fa181c7SMatt Spinler      */
2463800ae71SMatthew Barth     void startTimer(TimerMode mode);
2476fa181c7SMatt Spinler 
2486fa181c7SMatt Spinler     /**
2496fa181c7SMatt Spinler      * @brief Stops the timer
2506fa181c7SMatt Spinler      */
2516fa181c7SMatt Spinler     inline void stopTimer()
2526fa181c7SMatt Spinler     {
253*0d0e3554SMatthew Barth         phosphor::logging::log<phosphor::logging::level::INFO>(
254*0d0e3554SMatthew Barth             fmt::format("Stop running timer on tach sensor {}.", _name)
255*0d0e3554SMatthew Barth                 .c_str());
2568fd879fbSWilliam A. Kennington III         _timer.setEnabled(false);
257a9406a77SMatt Spinler     }
258a9406a77SMatt Spinler 
259a9406a77SMatt Spinler     /**
2603800ae71SMatthew Barth      * @brief Return the given timer mode's delay time
2613800ae71SMatthew Barth      *
2623800ae71SMatthew Barth      * @param[in] mode - mode of timer to get delay time for
263a9406a77SMatt Spinler      */
2643800ae71SMatthew Barth     std::chrono::microseconds getDelay(TimerMode mode);
265a9406a77SMatt Spinler 
266ce75b511SMatt Spinler     /**
267ce75b511SMatt Spinler      * Returns the sensor name
268ce75b511SMatt Spinler      */
269ce75b511SMatt Spinler     inline const std::string& name() const
270ce75b511SMatt Spinler     {
271ce75b511SMatt Spinler         return _name;
272ce75b511SMatt Spinler     };
273ce75b511SMatt Spinler 
274f13b42e2SMatt Spinler     /**
275f13b42e2SMatt Spinler      * @brief Says if the error timer is running
276f13b42e2SMatt Spinler      *
277f13b42e2SMatt Spinler      * @return bool - If the timer is running
278f13b42e2SMatt Spinler      */
279f13b42e2SMatt Spinler     bool errorTimerRunning() const
280f13b42e2SMatt Spinler     {
281f13b42e2SMatt Spinler         if (_errorTimer && _errorTimer->isEnabled())
282f13b42e2SMatt Spinler         {
283f13b42e2SMatt Spinler             return true;
284f13b42e2SMatt Spinler         }
285f13b42e2SMatt Spinler         return false;
286f13b42e2SMatt Spinler     }
287f13b42e2SMatt Spinler 
2887c23a049SMatthew Barth     /**
2897c23a049SMatthew Barth      * @brief Get the current allowed range of speeds
2907c23a049SMatthew Barth      *
2917c23a049SMatthew Barth      * @param[in] deviation - The configured deviation(in percent) allowed
2927c23a049SMatthew Barth      *
2937c23a049SMatthew Barth      * @return pair - Min/Max range of speeds allowed
2947c23a049SMatthew Barth      */
2957c23a049SMatthew Barth     std::pair<uint64_t, uint64_t> getRange(const size_t deviation) const;
2967c23a049SMatthew Barth 
297abf8da36SMatt Spinler   private:
298abf8da36SMatt Spinler     /**
299ebaae611SMatt Spinler      * @brief Returns the match string to use for matching
300ebaae611SMatt Spinler      *        on a properties changed signal.
301ebaae611SMatt Spinler      */
302ebaae611SMatt Spinler     std::string getMatchString(const std::string& interface);
303ebaae611SMatt Spinler 
304ebaae611SMatt Spinler     /**
305ebaae611SMatt Spinler      * @brief Reads the Target property and stores in _tachTarget.
306ebaae611SMatt Spinler      *        Also calls Fan::tachChanged().
307ebaae611SMatt Spinler      *
308ebaae611SMatt Spinler      * @param[in] msg - the dbus message
309ebaae611SMatt Spinler      */
310771659fcSBrad Bishop     void handleTargetChange(sdbusplus::message::message& msg);
311ebaae611SMatt Spinler 
312ebaae611SMatt Spinler     /**
313ebaae611SMatt Spinler      * @brief Reads the Value property and stores in _tachInput.
314ebaae611SMatt Spinler      *        Also calls Fan::tachChanged().
315ebaae611SMatt Spinler      *
316ebaae611SMatt Spinler      * @param[in] msg - the dbus message
317ebaae611SMatt Spinler      */
318771659fcSBrad Bishop     void handleTachChange(sdbusplus::message::message& msg);
319ebaae611SMatt Spinler 
3204d982856SMatthew Barth     /**
3214d982856SMatthew Barth      * @brief Updates the Functional property in the inventory
3224d982856SMatthew Barth      *        for this tach sensor based on the value passed in.
3234d982856SMatthew Barth      *
3244d982856SMatthew Barth      * @param[in] functional - If the Functional property should
3254d982856SMatthew Barth      *                         be set to true or false.
3264d982856SMatthew Barth      */
3274d982856SMatthew Barth     void updateInventory(bool functional);
328ebaae611SMatt Spinler 
329ebaae611SMatt Spinler     /**
330abf8da36SMatt Spinler      * @brief the dbus object
331abf8da36SMatt Spinler      */
332abf8da36SMatt Spinler     sdbusplus::bus::bus& _bus;
333abf8da36SMatt Spinler 
334abf8da36SMatt Spinler     /**
335abf8da36SMatt Spinler      * @brief Reference to the parent Fan object
336abf8da36SMatt Spinler      */
337abf8da36SMatt Spinler     Fan& _fan;
338abf8da36SMatt Spinler 
339abf8da36SMatt Spinler     /**
340abf8da36SMatt Spinler      * @brief The name of the sensor, including the full path
341abf8da36SMatt Spinler      *
342abf8da36SMatt Spinler      * For example /xyz/openbmc_project/sensors/fan_tach/fan0
343abf8da36SMatt Spinler      */
344abf8da36SMatt Spinler     const std::string _name;
345abf8da36SMatt Spinler 
346abf8da36SMatt Spinler     /**
3474d982856SMatthew Barth      * @brief The inventory name of the sensor, including the full path
3484d982856SMatthew Barth      */
3494d982856SMatthew Barth     const std::string _invName;
3504d982856SMatthew Barth 
3514d982856SMatthew Barth     /**
352abf8da36SMatt Spinler      * @brief If functional (not too slow).  The parent
353abf8da36SMatt Spinler      *        fan object sets this.
354abf8da36SMatt Spinler      */
355d199dcdfSMatthew Barth     bool _functional;
356abf8da36SMatt Spinler 
357abf8da36SMatt Spinler     /**
358abf8da36SMatt Spinler      * @brief If the sensor has a Target property (can set speed)
359abf8da36SMatt Spinler      */
360abf8da36SMatt Spinler     const bool _hasTarget;
361abf8da36SMatt Spinler 
362abf8da36SMatt Spinler     /**
3639396bcc3SMatthew Barth      * @brief Amount of time to delay updating to functional
3649396bcc3SMatthew Barth      */
3659396bcc3SMatthew Barth     const size_t _funcDelay;
3669396bcc3SMatthew Barth 
3679396bcc3SMatthew Barth     /**
36880f271b2SLei YU      * @brief The interface that the target implements
36980f271b2SLei YU      */
37080f271b2SLei YU     const std::string _interface;
37180f271b2SLei YU 
37280f271b2SLei YU     /**
3738e5d197bSLei YU      * @brief The factor of target to get fan rpm
3748e5d197bSLei YU      */
3755e7298c5SMatthew Barth     const double _factor;
3768e5d197bSLei YU 
3778e5d197bSLei YU     /**
3788e5d197bSLei YU      * @brief The offset of target to get fan rpm
3798e5d197bSLei YU      */
3804eac3cf9SLei YU     const int64_t _offset;
3818e5d197bSLei YU 
3828e5d197bSLei YU     /**
38369f2f48eSJolie Ku      * @brief The method of out of range
38469f2f48eSJolie Ku      */
38569f2f48eSJolie Ku     const size_t _method;
38669f2f48eSJolie Ku 
38769f2f48eSJolie Ku     /**
38869f2f48eSJolie Ku      * @brief The threshold for count method
38969f2f48eSJolie Ku      */
39069f2f48eSJolie Ku     const size_t _threshold;
39169f2f48eSJolie Ku 
39269f2f48eSJolie Ku     /**
39369f2f48eSJolie Ku      * @brief The counter for count method
39469f2f48eSJolie Ku      */
39569f2f48eSJolie Ku     size_t _counter = 0;
39669f2f48eSJolie Ku 
39769f2f48eSJolie Ku     /**
398abf8da36SMatt Spinler      * @brief The input speed, from the Value dbus property
399abf8da36SMatt Spinler      */
4000891e3b3SMatthew Barth     double _tachInput = 0;
401abf8da36SMatt Spinler 
402abf8da36SMatt Spinler     /**
403abf8da36SMatt Spinler      * @brief The current target speed, from the Target dbus property
404abf8da36SMatt Spinler      *        (if applicable)
405abf8da36SMatt Spinler      */
406abf8da36SMatt Spinler     uint64_t _tachTarget = 0;
407abf8da36SMatt Spinler 
408abf8da36SMatt Spinler     /**
409abf8da36SMatt Spinler      * @brief The timeout value to use
410abf8da36SMatt Spinler      */
411abf8da36SMatt Spinler     const size_t _timeout;
412ebaae611SMatt Spinler 
413ebaae611SMatt Spinler     /**
4143800ae71SMatthew Barth      * @brief Mode that current timer is in
4153800ae71SMatthew Barth      */
4163800ae71SMatthew Barth     TimerMode _timerMode;
4173800ae71SMatthew Barth 
4183800ae71SMatthew Barth     /**
419a9406a77SMatt Spinler      * The timer object
420a9406a77SMatt Spinler      */
4218fd879fbSWilliam A. Kennington III     sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> _timer;
422a9406a77SMatt Spinler 
423a9406a77SMatt Spinler     /**
424ebaae611SMatt Spinler      * @brief The match object for the Value properties changed signal
425ebaae611SMatt Spinler      */
426ebaae611SMatt Spinler     std::unique_ptr<sdbusplus::server::match::match> tachSignal;
427ebaae611SMatt Spinler 
428ebaae611SMatt Spinler     /**
429ebaae611SMatt Spinler      * @brief The match object for the Target properties changed signal
430ebaae611SMatt Spinler      */
431ebaae611SMatt Spinler     std::unique_ptr<sdbusplus::server::match::match> targetSignal;
432f13b42e2SMatt Spinler 
433f13b42e2SMatt Spinler     /**
434f13b42e2SMatt Spinler      * @brief The number of seconds to wait between a sensor being set
435f13b42e2SMatt Spinler      *        to nonfunctional and creating an error for it.
436f13b42e2SMatt Spinler      *
437f13b42e2SMatt Spinler      * If std::nullopt, no errors will be created.
438f13b42e2SMatt Spinler      */
439f13b42e2SMatt Spinler     const std::optional<size_t> _errorDelay;
440f13b42e2SMatt Spinler 
441f13b42e2SMatt Spinler     /**
442f13b42e2SMatt Spinler      * @brief The timer that uses _errorDelay.  When it expires an error
443f13b42e2SMatt Spinler      *        will be created for a faulted fan sensor (rotor).
444f13b42e2SMatt Spinler      *
445f13b42e2SMatt Spinler      * If _errorDelay is std::nullopt, then this won't be created.
446f13b42e2SMatt Spinler      */
447f13b42e2SMatt Spinler     std::unique_ptr<
448f13b42e2SMatt Spinler         sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>
449f13b42e2SMatt Spinler         _errorTimer;
450abf8da36SMatt Spinler };
451abf8da36SMatt Spinler 
452177fe986SMatthew Barth } // namespace monitor
453177fe986SMatthew Barth } // namespace fan
454177fe986SMatthew Barth } // namespace phosphor
455