47 #ifndef _MIRA_STATUS_H_ 48 #define _MIRA_STATUS_H_ 54 #include <boost/optional.hpp> 59 #include <serialization/adapters/std/map> 90 const std::string& iTrText,
const std::string& iMessage) :
105 template <
typename Reflector>
108 r.member(
"Mode",
mode,
"Status mode");
109 r.member(
"Category",
category,
"Category");
110 r.member(
"TranslatedText",
trText,
"Translated text");
111 r.member(
"Message",
message,
"Message");
195 void bootup(
const std::string& message,
const std::string& trText=
"");
213 void recover(
const std::string& message,
const std::string& trText=
"");
219 void ok(
const std::string& category=
"");
227 bool warning(
const std::string& category,
const std::string& message,
228 const std::string& trText=
"");
236 bool error(
const std::string& category,
const std::string& message,
237 const std::string& trText=
"");
253 const std::string& message,
const std::string& trText=
"");
297 StatusMap::const_iterator end)
300 for(
auto i = start; i != end; ++i)
302 if (mostSevereMode < i->second.mode)
303 mostSevereMode = i->second.mode;
305 return mostSevereMode;
360 template <
typename Reflector>
366 typedef std::map<std::string, DiagnosticsModulePtr> ModuleMap;
368 std::vector<std::string> mModuleOrder;
369 mutable boost::mutex mModuleMutex;
void recover(const std::string &message, const std::string &trText="")
Signal that the module is recovering.
Manages the status of one or multiple modules inheriting from DiagnosticsModule.
Definition: Status.h:289
void registerDiagnostics(const std::string &name, DiagnosticsModulePtr ptr)
Register a new diagnostics module by specifying a name and a pointer to the module.
Status()
Definition: Status.h:84
void setHeartbeatInterval(const Duration &interval)
Set the watchdog interval.
Definition: Status.h:151
Status(StatusMode iMode, const std::string &iCategory, const std::string &iTrText, const std::string &iMessage)
Construct a new status with given mode, category and text.
Definition: Status.h:89
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
StatusMap mStatusMap
Definition: Status.h:277
Time and Duration wrapper class.
std::string category
category of that status
Definition: Status.h:120
void bootupFinished()
Signal that the module has finished booting up (There can still be errors but booting up is finished)...
boost::optional< Status > mRecoverStatus
Definition: Status.h:274
std::multimap< std::string, Status > StatusMap
Definition: Status.h:293
virtual ~DiagnosticsModule()
Definition: Status.h:146
Provides MIRA_CLASS_SERIALIZATION macro and includes the major headers of the serialization framework...
StatusMap getStatusMap() const
Gets the current status map containing all errors, warnings and bootup messages.
Duration getHeartbeatInterval() const
Return the watchdog interval.
Definition: Status.h:164
StatusMode
Different status levels sorted from "okay" to "most severe".
Definition: Status.h:73
boost::optional< Time > mLastHeartbeat
Definition: Status.h:276
DiagnosticsModule(const std::string &name="")
Definition: Status.h:142
void unregisterDiagnostics(const std::string &name)
Unregister a diagnostics module.
bool setStatus(Status::StatusMode mode, const std::string &category, const std::string &message, const std::string &trText="")
Set the status of a given category.
std::string mName
Definition: Status.h:278
std::string message
the corresponding message
Definition: Status.h:126
Status entry class.
Definition: Status.h:69
boost::optional< Status > mBootUpStatus
Definition: Status.h:273
Use this class to represent time durations.
Definition: Time.h:106
void reflect(Reflector &r)
Definition: Status.h:361
void recoverFinished()
Signal that the module has finished recovering (There can still be errors but recovering is finished)...
StatusMap getStatusMap() const
Gets the current status map.
static Time now()
Returns the current utc based time.
Definition: Time.h:481
DiagnosticsModule * DiagnosticsModulePtr
Typedef of a DiagnosticsModule pointer.
Definition: Status.h:282
void heartbeat()
When called for the first time heartbeat usage will be enabled.
Definition: Status.h:177
void bootup(const std::string &message, const std::string &trText="")
Signal that the module is booting up.
void setID(const std::string &id)
Set the id that is used for displaying status messages.
Definition: Status.h:309
bool hasHeartbeatTimeout() const
Returns true if heartbeat usage is enabled (by first call to heartbeat()) and last heartbeat was more...
Definition: Status.h:186
Duration mHeartbeatInterval
Definition: Status.h:275
static Status::StatusMode getOverallStatus(StatusMap::const_iterator start, StatusMap::const_iterator end)
Return the overall (most severe) status from a range of status map entries.
Definition: Status.h:296
StatusMode mode
the status flag (OK, WARNING or ERROR)
Definition: Status.h:117
bool error(const std::string &category, const std::string &message, const std::string &trText="")
Signal an error in a category.
bool warning(const std::string &category, const std::string &message, const std::string &trText="")
Signal a warning in a category.
Status::StatusMode getStatus() const
Get the status mode defined by the status of the watchdog (if used) and the bootup, error and warning methods.
Status::StatusMode getStatus() const
Get the overall status mode defined by the status of all registered diagnostic modules.
std::map< std::string, Status > StatusMap
Definition: Status.h:140
Base class for modules that want to use diagnostics and set the current status.
Definition: Status.h:136
void reflect(Reflector &r)
Definition: Status.h:106
std::string trText
Status text that can be used for translation of the error to other languages.
Definition: Status.h:123
bool operator==(const Status &other) const
Definition: Status.h:97
void ok(const std::string &category="")
Signal that a category contains no more errors.
std::vector< std::string > getDiagnosticModules() const
Get the list of all registered modules.
void setName(const std::string &name)
Definition: Status.h:156