INTRODUCTION Overview Download and Install Documentation Publications REPOSITORY Libraries DEVELOPER Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
status.h 00001 /* 00002 * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics 00003 * http://gearbox.sf.net/ 00004 * Copyright (c) 2004-2008 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 00044 }; 00045 00047 GBXUTILACFR_EXPORT std::string toString( SubsystemState state ); 00048 00050 enum SubsystemHealth 00051 { 00053 SubsystemOk, 00055 SubsystemWarning, 00057 SubsystemFault 00058 }; 00059 00061 GBXUTILACFR_EXPORT std::string toString( SubsystemHealth health ); 00062 00064 struct GBXUTILACFR_EXPORT SubsystemStatus 00065 { 00067 SubsystemStatus( SubsystemState s=SubsystemIdle, SubsystemHealth h=SubsystemOk, const std::string& msg="", 00068 bool stall=false, double beat=0.0 ) : 00069 state(s), 00070 health(h), 00071 message(msg), 00072 isStalled(stall), 00073 sinceHeartbeat(beat) {}; 00074 00076 SubsystemState state; 00077 00079 SubsystemHealth health; 00080 00082 std::string message; 00083 00085 bool isStalled; 00086 00091 double sinceHeartbeat; 00092 }; 00093 00095 GBXUTILACFR_EXPORT std::string toString( const SubsystemStatus& status ); 00096 00098 enum SubsystemType { 00100 SubsystemStandard, 00102 SubsystemEarlyExit 00103 }; 00104 00106 GBXUTILACFR_EXPORT std::string toString( SubsystemType type ); 00107 00188 class GBXUTILACFR_EXPORT Status 00189 { 00190 00191 public: 00192 00193 virtual ~Status() {}; 00194 00210 virtual void addSubsystem( const std::string& subsystem, 00211 double maxHeartbeatIntervalSec=-1.0, SubsystemType type=SubsystemStandard )=0; 00212 00215 virtual void removeSubsystem( const std::string& subsystem )=0; 00216 00218 virtual std::vector<std::string> subsystems()=0; 00219 00222 virtual SubsystemStatus subsystemStatus( const std::string& subsystem )=0; 00223 00225 virtual SubsystemState infrastructureState()=0; 00226 00231 virtual void setMaxHeartbeatInterval( const std::string& subsystem, double intervalSec )=0; 00232 00234 virtual void setSubsystemType( const std::string& subsystem, SubsystemType type )=0; 00235 00236 // 00237 // BOTH STATE AND HEALTH CHANGES 00238 // 00239 00243 virtual void setSubsystemStatus( const std::string& subsystem, SubsystemState state, SubsystemHealth health, const std::string& message="" )=0; 00244 00245 // 00246 // STATE CHANGES 00247 // 00248 00251 virtual void initialising( const std::string& subsystem, const std::string& message="" )=0; 00252 00255 virtual void working( const std::string& subsystem, const std::string& message="" )=0; 00256 00259 virtual void finalising( const std::string& subsystem, const std::string& message="" )=0; 00260 00261 // 00262 // HEALTH CHANGES 00263 // 00264 00267 virtual void ok( const std::string& subsystem, const std::string& message="" )=0; 00268 00271 virtual void warning( const std::string& subsystem, const std::string& message )=0; 00272 00275 virtual void fault( const std::string& subsystem, const std::string& message )=0; 00276 00277 // 00278 // NO CHANGE 00279 // 00280 00284 virtual void heartbeat( const std::string& subsystem )=0; 00285 00288 virtual void message( const std::string& subsystem, const std::string& message )=0; 00289 00290 // 00291 // INFRASTRUCTURE STATE CHANGES 00292 // 00294 virtual void infrastructureInitialising()=0; 00296 virtual void infrastructureWorking()=0; 00298 virtual void infrastructureFinalising()=0; 00299 00300 // 00301 // Utility 00302 // 00303 00306 virtual void process()=0; 00307 }; 00308 00309 } // namespace 00310 00311 #endif |