Laelaps  2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
laeThreadWd.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Laelaps
4 //
5 // File: laeThreadWd.h
6 //
7 /*! \file
8  *
9  * $LastChangedDate: 2015-08-07 14:25:35 -0600 (Fri, 07 Aug 2015) $
10  * $Rev: 4051 $
11  *
12  * \brief Laelaps watchdog thread class interface.
13  *
14  * The watchdog thread monitors system health and energy, and provides an
15  * interface to the WatchDog subprocessor.
16  *
17  * \author Robin Knight (robin.knight@roadnarrows.com)
18  *
19  * \par Copyright
20  * \h_copy 2015-2018. RoadNarrows LLC.\n
21  * http://www.roadnarrows.com\n
22  * All Rights Reserved
23  */
24 /*
25  * @EulaBegin@
26  *
27  * Unless otherwise stated explicitly, all materials contained are copyrighted
28  * and may not be used without RoadNarrows LLC's written consent,
29  * except as provided in these terms and conditions or in the copyright
30  * notice (documents and software) or other proprietary notice provided with
31  * the relevant materials.
32  *
33  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY
34  * MEMBERS/EMPLOYEES/CONTRACTORS OF ROADNARROWS OR DISTRIBUTORS OF THIS SOFTWARE
35  * BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
36  * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
37  * DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN
38  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  *
40  * THE AUTHORS AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
41  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
42  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
43  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
44  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
45  *
46  * @EulaEnd@
47  */
48 ////////////////////////////////////////////////////////////////////////////////
49 
50 #ifndef _LAE_THREAD_WD_H
51 #define _LAE_THREAD_WD_H
52 
53 #include <sys/types.h>
54 #include <sys/time.h>
55 #include <time.h>
56 #include <pthread.h>
57 
58 #include <string>
59 
60 #include "rnr/rnrconfig.h"
61 #include "rnr/log.h"
62 
63 #include "Laelaps/laelaps.h"
64 #include "Laelaps/laeUtils.h"
65 #include "Laelaps/laeTune.h"
66 
67 #include "Laelaps/laeGpio.h"
68 #include "Laelaps/laeBatt.h"
69 #include "Laelaps/laeAlarms.h"
70 #include "Laelaps/laeWatchDog.h"
71 #include "Laelaps/laeWd.h"
72 
73 #include "Laelaps/laeThread.h"
74 
75 /*!
76  * \brief The \h_laelaps namespace encapsulates all \h_laelaps related
77  * constructs.
78  */
79 namespace laelaps
80 {
81 
82  //----------------------------------------------------------------------------
83  // LaeThreadWd Class
84  //----------------------------------------------------------------------------
85 
86  /*!
87  * Watchdog thread class.
88  */
89  class LaeThreadWd : public LaeThread
90  {
91  public:
92  static const double ThreadWdPrioDft; ///< default priority
93  static const double ThreadWdHzDft; ///< default run rate
94 
95  /*!
96  * \brief Optimize thread hertz rate given the watchdog timeout value.
97  *
98  * \param fWatchDogTimeout Seconds.
99  *
100  * \return Returns hertz.
101  */
102  static double optimizeHz(const double fWatchDogTimeout);
103 
104  /*!
105  * \brief Default constructor.
106  */
107  LaeThreadWd(LaeWd &hwif);
108 
109  /*!
110  * \brief Destructor.
111  */
112  virtual ~LaeThreadWd();
113 
114  /*!
115  * \brief Reload tunable paramaters.
116  *
117  * This function executes under the lock/unlock mutex.
118  */
119  int reload(const LaeTunes &tunes);
120 
121  protected:
122  LaeWd &m_hwif; ///< hardware interface
123  LaeWatchDogReset m_reset; ///< sub-processor reset
124  LaeBattery m_battery; ///< battery and energy monitor
125  LaeAlarms m_alarms; ///< alarm monitor
126 
127  /*!
128  * \brief Execute watchdog task within scheduled cycle.
129  *
130  * This function executes under the lock/unlock mutex.
131  *
132  * \par Context:
133  * This thread.
134  */
135  virtual void exec();
136  };
137 
138 } // namespace laelaps
139 
140 
141 #endif // _LAE_THREAD_WD_H
Laelaps thread base class interface.
LaeWd & m_hwif
hardware interface
Definition: laeThreadWd.h:122
Laelaps tuning data class.
Definition: laeTune.h:566
Laelaps battery management and energy monitoring class interface.
static const double ThreadWdHzDft
default run rate
Definition: laeThreadWd.h:93
static double optimizeHz(const double fWatchDogTimeout)
Optimize thread hertz rate given the watchdog timeout value.
Definition: laeThreadWd.cxx:79
static const double ThreadWdPrioDft
default priority
Definition: laeThreadWd.h:92
Laelaps WatchDog software class interface.
LaeBattery m_battery
battery and energy monitor
Definition: laeThreadWd.h:124
int reload(const LaeTunes &tunes)
Reload tunable paramaters.
Definition: laeThreadWd.cxx:99
Laelaps Odroid General Purpose I/O class interfaces.
Alarm class.
Definition: laeAlarms.h:167
virtual void exec()
Execute watchdog task within scheduled cycle.
The <b><i>Laelaps</i></b> namespace encapsulates all <b><i>Laelaps</i></b> related constructs...
Definition: laeAlarms.h:64
Laelaps common utilities.
Laelaps tuning.
Battery Management and System Energy Monitoring (BMSEM) Class.
Definition: laeBatt.h:65
LaeAlarms m_alarms
alarm monitor
Definition: laeThreadWd.h:125
Laelaps built-in Arduino sub-processor.
Laelaps alarm monitoring class interface.
Laelaps watchdog sub-processor reset class.
Definition: laeGpio.h:257
virtual ~LaeThreadWd()
Destructor.
Definition: laeThreadWd.cxx:95
LaeThreadWd(LaeWd &hwif)
Default constructor.
Definition: laeThreadWd.cxx:91
LaeWatchDogReset m_reset
sub-processor reset
Definition: laeThreadWd.h:123
Top-level package include file.