Laelaps  2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
laeAlarms.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Laelaps
4 //
5 // File: laeAlarms.h
6 //
7 /*! \file
8  *
9  * $LastChangedDate: 2016-01-18 10:01:31 -0700 (Mon, 18 Jan 2016) $
10  * $Rev: 4262 $
11  *
12  * \brief Laelaps alarm monitoring class interface.
13  *
14  * A single instance of this class executing in a thread will monitor, raise,
15  * and clear system and subsystem alarms. It will publish to the Laelaps
16  * real-time database.
17  *
18  * \author Robin Knight (robin.knight@roadnarrows.com)
19  *
20  * \par Copyright
21  * \h_copy 2016-2017. RoadNarrows LLC.\n
22  * http://www.roadnarrows.com\n
23  * All Rights Reserved
24  */
25 /*
26  * @EulaBegin@
27  *
28  * Unless otherwise stated explicitly, all materials contained are copyrighted
29  * and may not be used without RoadNarrows LLC's written consent,
30  * except as provided in these terms and conditions or in the copyright
31  * notice (documents and software) or other proprietary notice provided with
32  * the relevant materials.
33  *
34  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY
35  * MEMBERS/EMPLOYEES/CONTRACTORS OF ROADNARROWS OR DISTRIBUTORS OF THIS SOFTWARE
36  * BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
37  * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
38  * DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN
39  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * THE AUTHORS AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
42  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
43  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
44  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
45  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
46  *
47  * @EulaEnd@
48  */
49 ////////////////////////////////////////////////////////////////////////////////
50 
51 #ifndef _LAE_ALARMS_H
52 #define _LAE_ALARMS_H
53 
54 #include "rnr/rnrconfig.h"
55 
56 #include "Laelaps/laelaps.h"
57 #include "Laelaps/laeSysDev.h"
58 #include "Laelaps/laeMotor.h"
59 
60 /*!
61  * \brief The \h_laelaps namespace encapsulates all \h_laelaps related
62  * constructs.
63  */
64 namespace laelaps
65 {
66  /*!
67  * \ingroup laelaps_h
68  * \defgroup lae_alarms Laelaps Alarms and Warnings
69  *
70  * Laelaps package-wide alarm and warning codes.
71  *
72  * \{
73  */
74  static const u32_t LAE_ALARM_NONE = 0x00000000; ///< no alarms
75 
76  //
77  // Common alarms.
78  //
79  static const u32_t LAE_ALARM_GEN = 0x00000001; ///< general alarm
80  static const u32_t LAE_ALARM_ESTOP = 0x00000002; ///< emergency stop
81  static const u32_t LAE_ALARM_BATT = 0x00000004; ///< battery low alarm
82  static const u32_t LAE_ALARM_TEMP = 0x00000008; ///< temperature alarm
83  static const u32_t LAE_ALARM_NO_RSRC = 0x00000010; ///< resource not found
84  static const u32_t LAE_ALARM_SUBSYS = 0x00000020; ///< 1+ subsystem alarms
85 
86  //
87  // Motor controller specific alarms.
88  //
89  static const u32_t LAE_ALARM_MOTCTLR_BATT_V_HIGH = 0x00000100;
90  ///< motor controller battery input over voltage alarm
91  static const u32_t LAE_ALARM_MOTCTLR_LOGIC_V_HIGH = 0x00000400;
92  ///< motor controller logic over voltage alarm
93  static const u32_t LAE_ALARM_MOTCTLR_LOGIC_V_LOW = 0x00000800;
94  ///< motor contorller logic under voltage alarm
95 
96  //
97  // Motor specific alarms.
98  //
99  static const u32_t LAE_ALARM_MOT_OVER_CUR = 0x00001000;
100  ///< motor over current alarm
101  static const u32_t LAE_ALARM_MOT_FAULT = 0x00002000;
102  ///< motor drive fault alarm
103 
104  //
105  // Sensor specific alarms.
106  //
107  static const u32_t LAE_ALARM_IMU = 0x00010000; ///< imu alarm
108  static const u32_t LAE_ALARM_RANGE = 0x00020000; ///< range alarm
109  static const u32_t LAE_ALARM_FCAM = 0x00040000; ///< front camera alarm
110 
111  /*!
112  * \brief The [sub]sytem warnings.
113  */
114  static const u32_t LAE_WARN_NONE = 0x00000000; ///< no warnings
115 
116  //
117  // Common warnings.
118  //
119  static const u32_t LAE_WARN_BATT = 0x00000004; ///< battery low warning
120  static const u32_t LAE_WARN_TEMP = 0x00000008; ///< temperature warning
121  static const u32_t LAE_WARN_SUBSYS = 0x00000020; ///< 1+ subsystem warnings
122 
123  //
124  // Motor controller specific warnings.
125  //
126  static const u32_t LAE_WARN_MOTCTLR_BATT_V_HIGH = 0x00000100;
127  ///< motor controller battery input over voltage warning
128  static const u32_t LAE_WARN_MOTCTLR_BATT_V_LOW = 0x00000200;
129  ///< motor controller battery input under voltage warn
130 
131  //
132  // Motor specific warnings.
133  //
134  static const u32_t LAE_WARN_MOT_OVER_CUR = 0x00001000;
135  ///< motor over current warning
136 
137 
138  /*!
139  * \brief Alarm thresholds, criticalities, etc.
140  */
141  static const double LAE_WARN_BATT_SOC = 20.0;
142  ///< battery warning state of charge threshold
143  static const double LAE_CRIT_BATT_SOC = 5.0;
144  ///< battery critical state of charge threshold
145 
147  ///< critical alarms for motor controller subsystem
148 
149  static const u32_t LAE_CRIT_MOT = LAE_ALARM_MOT_FAULT;
150  ///< critacal alarms for motor subsystem
151 
152  /*! \} */
153 
154  /*!
155  * \brief Alarm information state structure.
156  */
158  {
159  bool m_bIsCritical; ///< is [not] critical alarm
160  u32_t m_uAlarms; ///< alarm or'ed bits
161  u32_t m_uWarnings; ///< warning or'ed bits
162  }; // struct LaeAlarmInfo
163 
164  /*!
165  * \brief Alarm class.
166  */
167  class LaeAlarms
168  {
169  public:
170  /*!
171  * \brief Default contructor.
172  */
173  LaeAlarms();
174 
175  /*!
176  * \brief Destructor.
177  */
178  virtual ~LaeAlarms();
179 
180  /*!
181  * \brief Test if critcal alarms exist.
182  *
183  * The determination is made solely on the real-time database current state.
184  * No subsystems are queried.
185  *
186  * \return Returns true or false.
187  */
188  static bool isCritical();
189 
190  /*!
191  * \brief Test if battery critcal alarms exist.
192  *
193  * The determination is made solely on the real-time database current state.
194  * No subsystems are queried.
195  *
196  * \return Returns true or false.
197  */
198  static bool isBatteryCritical();
199 
200  /*!
201  * \brief Test if robot is safe to operate given the current alarm state.
202  *
203  * The determination is made solely on the real-time database current state.
204  * No subsystems are queried.
205  *
206  * \return Returns true or false.
207  */
208  static bool isSafeToOperate();
209 
210  /*!
211  * \brief Clear alarm information state.
212  *
213  * \param [in,out] info Alarm state.
214  */
215  static void clearAlarms(LaeAlarmInfo &info);
216 
217  /*!
218  * \brief Copy alarm state.
219  *
220  * \param [in] src Source alarm state.
221  * \param [out] dst Destination alarm state.
222  */
223  static void copyAlarms(const LaeAlarmInfo &src, LaeAlarmInfo &dst);
224 
225  /*!
226  * \brief Update alarm and warning state.
227  *
228  * Status, alarms, and erros from all monitored subsystems are processed to
229  * provide a unified alarm framework. The alarm state is written to the
230  * Laelaps real-time database.
231  */
232  virtual void update();
233 
234  protected:
235  /*!
236  * \brief Update system alarm state from subsystem alarm state.
237  *
238  * \param [in] subsys Subsystem alarm state.
239  * \param [out] sys System alarm state.
240  */
241  virtual void updateSysAlarms(const LaeAlarmInfo &subsys, LaeAlarmInfo &sys);
242 
243  }; // LaeAlarms
244 
245 } // namespace laelaps
246 
247 
248 #endif // _LAE_ALARMS_H
static const u32_t LAE_WARN_NONE
The [sub]sytem warnings.
Definition: laeAlarms.h:114
static const u32_t LAE_WARN_MOT_OVER_CUR
motor over current warning
Definition: laeAlarms.h:134
u32_t m_uWarnings
warning or&#39;ed bits
Definition: laeAlarms.h:161
Alarm information state structure.
Definition: laeAlarms.h:157
static const u32_t LAE_ALARM_NONE
no alarms
Definition: laeAlarms.h:74
static const u32_t LAE_WARN_MOTCTLR_BATT_V_LOW
motor controller battery input under voltage warn
Definition: laeAlarms.h:128
static const double LAE_WARN_BATT_SOC
Alarm thresholds, criticalities, etc.
Definition: laeAlarms.h:141
static const u32_t LAE_ALARM_MOTCTLR_BATT_V_HIGH
motor controller battery input over voltage alarm
Definition: laeAlarms.h:89
bool m_bIsCritical
is [not] critical alarm
Definition: laeAlarms.h:159
static const u32_t LAE_WARN_TEMP
temperature warning
Definition: laeAlarms.h:120
Alarm class.
Definition: laeAlarms.h:167
static const u32_t LAE_ALARM_RANGE
range alarm
Definition: laeAlarms.h:108
static const u32_t LAE_ALARM_SUBSYS
1+ subsystem alarms
Definition: laeAlarms.h:84
static const u32_t LAE_ALARM_MOT_OVER_CUR
motor over current alarm
Definition: laeAlarms.h:99
The <b><i>Laelaps</i></b> namespace encapsulates all <b><i>Laelaps</i></b> related constructs...
Definition: laeAlarms.h:64
static const u32_t LAE_WARN_BATT
battery low warning
Definition: laeAlarms.h:119
static const u32_t LAE_ALARM_TEMP
temperature alarm
Definition: laeAlarms.h:82
static const u32_t LAE_ALARM_FCAM
front camera alarm
Definition: laeAlarms.h:109
static const u32_t LAE_ALARM_MOTCTLR_LOGIC_V_HIGH
motor controller logic over voltage alarm
Definition: laeAlarms.h:91
static const u32_t LAE_ALARM_MOT_FAULT
motor drive fault alarm
Definition: laeAlarms.h:101
static const u32_t LAE_WARN_SUBSYS
1+ subsystem warnings
Definition: laeAlarms.h:121
u32_t m_uAlarms
alarm or&#39;ed bits
Definition: laeAlarms.h:160
static const u32_t LAE_WARN_MOTCTLR_BATT_V_HIGH
motor controller battery input over voltage warning
Definition: laeAlarms.h:126
Laelaps system devices.
static const u32_t LAE_ALARM_NO_RSRC
resource not found
Definition: laeAlarms.h:83
static const u32_t LAE_ALARM_ESTOP
emergency stop
Definition: laeAlarms.h:80
static const u32_t LAE_ALARM_GEN
general alarm
Definition: laeAlarms.h:79
Laelaps motors, encoder, and controllers hardware abstraction interfaces.
static const u32_t LAE_CRIT_MOT
critacal alarms for motor subsystem
Definition: laeAlarms.h:149
static const u32_t LAE_ALARM_BATT
battery low alarm
Definition: laeAlarms.h:81
static const u32_t LAE_ALARM_IMU
imu alarm
Definition: laeAlarms.h:107
static const u32_t LAE_CRIT_MOTCTLR
critical alarms for motor controller subsystem
Definition: laeAlarms.h:146
static const double LAE_CRIT_BATT_SOC
battery critical state of charge threshold
Definition: laeAlarms.h:143
static const u32_t LAE_ALARM_MOTCTLR_LOGIC_V_LOW
motor contorller logic under voltage alarm
Definition: laeAlarms.h:93
Top-level package include file.