47 #ifndef _MIRA_STATUS_H_ 48 #define _MIRA_STATUS_H_ 54 #include <boost/optional.hpp> 59 #include <serialization/adapters/std/map> 92 const std::string& iTrText,
const std::string& iMessage) :
107 template <
typename Reflector>
110 r.member(
"Mode",
mode,
"Status mode");
111 r.member(
"Category",
category,
"Category");
112 r.member(
"TranslatedText",
trText,
"Translated text");
113 r.member(
"Message",
message,
"Message");
145 mHeartbeatInterval(
Duration::seconds(1)),
155 mHeartbeatInterval = interval;
168 return mHeartbeatInterval;
190 return mLastHeartbeat && (
Time::now()-*mLastHeartbeat) > mHeartbeatInterval;
197 void bootup(
const std::string& message,
const std::string& trText=
"");
203 void bootupFinished();
209 void recoverFinished();
215 void recover(
const std::string& message,
const std::string& trText=
"");
221 void ok(
const std::string& category=
"");
229 bool warning(
const std::string& category,
const std::string& message,
230 const std::string& trText=
"");
238 bool error(
const std::string& category,
const std::string& message,
239 const std::string& trText=
"");
255 const std::string& message,
const std::string& trText=
"");
271 StatusMap getStatusMap()
const;
299 StatusMap::const_iterator end)
302 for(
auto i = start; i != end; ++i)
304 if (mostSevereMode < i->second.mode)
305 mostSevereMode = i->second.mode;
307 return mostSevereMode;
339 void unregisterDiagnostics(
const std::string& name);
350 std::vector<std::string> getDiagnosticModules()
const;
355 StatusMap getStatusMap()
const;
362 template <
typename Reflector>
368 typedef std::map<std::string, DiagnosticsModulePtr> ModuleMap;
370 std::vector<std::string> mModuleOrder;
371 mutable boost::mutex mModuleMutex;
Manages the status of one or multiple modules inheriting from DiagnosticsModule.
Definition: Status.h:291
Status()
Definition: Status.h:86
void setHeartbeatInterval(const Duration &interval)
Set the watchdog interval.
Definition: Status.h:153
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:91
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
StatusMap mStatusMap
Definition: Status.h:279
Time and Duration wrapper class.
std::string category
category of that status
Definition: Status.h:122
boost::optional< Status > mRecoverStatus
Definition: Status.h:276
std::multimap< std::string, Status > StatusMap
Definition: Status.h:295
virtual ~DiagnosticsModule()
Definition: Status.h:148
Provides MIRA_CLASS_SERIALIZATION macro and includes the major headers of the serialization framework...
Framework export macro declaration.
Duration getHeartbeatInterval() const
Return the watchdog interval.
Definition: Status.h:166
StatusMode
Different status levels sorted from "okay" to "most severe".
Definition: Status.h:75
boost::optional< Time > mLastHeartbeat
Definition: Status.h:278
DiagnosticsModule(const std::string &name="")
Definition: Status.h:144
std::string mName
Definition: Status.h:280
std::string message
the corresponding message
Definition: Status.h:128
Status entry class.
Definition: Status.h:71
boost::optional< Status > mBootUpStatus
Definition: Status.h:275
#define MIRA_FRAMEWORK_EXPORT
Definition: FrameworkExports.h:61
Use this class to represent time durations.
Definition: Time.h:106
void reflect(Reflector &r)
Definition: Status.h:363
DiagnosticsModule * DiagnosticsModulePtr
Typedef of a DiagnosticsModule pointer.
Definition: Status.h:284
void heartbeat()
When called for the first time heartbeat usage will be enabled.
Definition: Status.h:179
void setID(const std::string &id)
Set the id that is used for displaying status messages.
Definition: Status.h:311
bool hasHeartbeatTimeout() const
Returns true if heartbeat usage is enabled (by first call to heartbeat()) and last heartbeat was more...
Definition: Status.h:188
Duration mHeartbeatInterval
Definition: Status.h:277
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:298
StatusMode mode
the status flag (OK, WARNING or ERROR)
Definition: Status.h:119
static Time now() static Time eternity()
Returns the current utc based time.
Definition: Time.h:481
std::map< std::string, Status > StatusMap
Definition: Status.h:142
Base class for modules that want to use diagnostics and set the current status.
Definition: Status.h:138
void reflect(Reflector &r)
Definition: Status.h:108
std::string trText
Status text that can be used for translation of the error to other languages.
Definition: Status.h:125
bool operator==(const Status &other) const
Definition: Status.h:99
void setName(const std::string &name)
Definition: Status.h:158