INTRODUCTION Overview Download and Install Documentation Publications REPOSITORY Libraries DEVELOPER Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
substatus.h00001 /* 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_SUBSYSTEM_STATUS_H 00012 #define GBXUTILACFR_SUBSYSTEM_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 <gbxutilacfr/status.h> 00027 00028 namespace gbxutilacfr { 00029 00039 class GBXUTILACFR_EXPORT SubStatus 00040 { 00041 00042 public: 00045 SubStatus( Status& status, const std::string& subsysName, double maxHeartbeatIntervalSec=-1.0 ) : 00046 status_(status), 00047 subsysName_(subsysName) 00048 { 00049 status_.addSubsystem( subsysName_, maxHeartbeatIntervalSec ); 00050 }; 00051 00053 ~SubStatus() 00054 { 00055 status_.removeSubsystem( subsysName_ ); 00056 } 00057 00058 // 00059 // set expectations about ourselves 00060 // 00061 00063 void setMaxHeartbeatInterval( double interval ) { status_.setMaxHeartbeatInterval( subsysName_, interval ); }; 00064 00066 void setSubsystemType( SubsystemType type ) { status_.setSubsystemType( subsysName_, type ); }; 00067 00068 // 00069 // set health 00070 // 00071 00073 void heartbeat() { status_.heartbeat( subsysName_ ); }; 00074 00076 void message( const std::string& message ) { status_.message( subsysName_, message ); }; 00077 00079 void ok( const std::string& message="" ) { status_.ok( subsysName_, message ); }; 00080 00082 void warning( const std::string& message ) { status_.warning( subsysName_, message ); }; 00083 00085 void fault( const std::string& message ) { status_.fault( subsysName_, message ); }; 00086 00087 // 00088 // Set state machine states 00089 // 00090 00092 void initialising( const std::string& message="" ) { status_.initialising( subsysName_, message ); }; 00093 00095 void working( const std::string& message="" ) { status_.working( subsysName_, message ); }; 00096 00098 void finalising( const std::string& message="" ) { status_.finalising( subsysName_, message ); }; 00099 00100 00102 Status& status() { return status_; }; 00103 00105 std::string name() const { return subsysName_; }; 00106 00107 private: 00108 00109 Status& status_; 00110 std::string subsysName_; 00111 }; 00112 00113 } // namespace 00114 00115 #endif |