INTRODUCTION Overview Download and Install Documentation Publications REPOSITORY Libraries DEVELOPER Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
status.h00001 /* 00002 * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics 00003 * http://gearbox.sf.net/ 00004 * Copyright (c) 2004-2010 Alex Brooks, Alexei Makarenko, Tobias Kaupp 00005 * 00006 * This distribution is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef GBXUTILACFR_STATUS_H 00012 #define GBXUTILACFR_STATUS_H 00013 00014 #if defined (WIN32) 00015 #if defined (GBXUTILACFR_STATIC) 00016 #define GBXUTILACFR_EXPORT 00017 #elif defined (GBXUTILACFR_EXPORTS) 00018 #define GBXUTILACFR_EXPORT __declspec (dllexport) 00019 #else 00020 #define GBXUTILACFR_EXPORT __declspec (dllimport) 00021 #endif 00022 #else 00023 #define GBXUTILACFR_EXPORT 00024 #endif 00025 00026 #include <string> 00027 #include <vector> 00028 00029 namespace gbxutilacfr { 00030 00032 enum SubsystemState 00033 { 00035 SubsystemIdle, 00037 SubsystemInitialising, 00039 SubsystemWorking, 00041 SubsystemFinalising, 00043 SubsystemShutdown, 00045 SubsystemFault 00046 }; 00047 00049 GBXUTILACFR_EXPORT std::string toString( SubsystemState state ); 00050 00052 enum SubsystemHealth 00053 { 00055 SubsystemOk, 00057 SubsystemWarning, 00059 SubsystemCritical 00060 }; 00061 00063 GBXUTILACFR_EXPORT std::string toString( SubsystemHealth health ); 00064 00066 struct GBXUTILACFR_EXPORT SubsystemStatus 00067 { 00069 SubsystemStatus( SubsystemState s=SubsystemIdle, SubsystemHealth h=SubsystemOk, const std::string& msg="", 00070 bool stall=false, double beat=0.0 ) : 00071 state(s), 00072 health(h), 00073 message(msg), 00074 isStalled(stall), 00075 sinceHeartbeat(beat) {}; 00076 00078 SubsystemState state; 00079 00081 SubsystemHealth health; 00082 00084 std::string message; 00085 00087 bool isStalled; 00088 00093 double sinceHeartbeat; 00094 }; 00095 00097 GBXUTILACFR_EXPORT std::string toString( const SubsystemStatus& status ); 00098 00100 enum SubsystemType 00101 { 00103 SubsystemStandard, 00108 SubsystemEarlyExit, 00113 SubsystemInfrastructure 00114 }; 00115 00117 GBXUTILACFR_EXPORT std::string toString( SubsystemType type ); 00118 00120 enum ComponentState 00121 { 00123 CompStarting, 00125 CompOperational, 00127 CompStopping, 00129 CompFault 00130 }; 00131 00133 GBXUTILACFR_EXPORT std::string toString( ComponentState type ); 00134 00136 enum ComponentHealth 00137 { 00139 CompOk, 00141 CompWarning, 00143 CompCritical 00144 }; 00145 00147 GBXUTILACFR_EXPORT std::string toString( ComponentHealth type ); 00148 00150 struct GBXUTILACFR_EXPORT ComponentStatus 00151 { 00153 ComponentState state; 00155 ComponentHealth health; 00157 bool isStalled; 00158 }; 00159 00253 class GBXUTILACFR_EXPORT Status 00254 { 00255 00256 public: 00257 00258 virtual ~Status() {}; 00259 00275 virtual void addSubsystem( const std::string& subsystem, 00276 double maxHeartbeatIntervalSec=-1.0, SubsystemType type=SubsystemStandard )=0; 00277 00280 virtual void removeSubsystem( const std::string& subsystem )=0; 00281 00283 virtual std::vector<std::string> subsystems()=0; 00284 00287 virtual SubsystemStatus subsystemStatus( const std::string& subsystem )=0; 00288 00290 // virtual SubsystemState infrastructureState()=0; 00291 00295 virtual ComponentStatus componentStatus()=0; 00296 00301 virtual void setMaxHeartbeatInterval( const std::string& subsystem, double intervalSec )=0; 00302 00304 virtual void setSubsystemType( const std::string& subsystem, SubsystemType type )=0; 00305 00306 // 00307 // BOTH STATE AND HEALTH CHANGES 00308 // 00309 00313 virtual void setSubsystemStatus( const std::string& subsystem, SubsystemState state, SubsystemHealth health, const std::string& message="" )=0; 00314 00315 // 00316 // STATE CHANGES 00317 // 00318 00321 virtual void initialising( const std::string& subsystem )=0; 00322 00325 virtual void working( const std::string& subsystem )=0; 00326 00329 virtual void finalising( const std::string& subsystem )=0; 00330 00334 virtual void fault( const std::string& subsystem, const std::string& message )=0; 00335 00336 // 00337 // HEALTH CHANGES 00338 // 00339 00342 virtual void ok( const std::string& subsystem, const std::string& message="" )=0; 00343 00346 virtual void warning( const std::string& subsystem, const std::string& message )=0; 00347 00350 virtual void critical( const std::string& subsystem, const std::string& message )=0; 00351 00352 // 00353 // NO CHANGE 00354 // 00355 00359 virtual void heartbeat( const std::string& subsystem )=0; 00360 00363 virtual void message( const std::string& subsystem, const std::string& message )=0; 00364 00365 // 00366 // Utility 00367 // 00368 00371 virtual void process()=0; 00372 }; 00373 00374 } // namespace 00375 00376 #endif |