INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

NONFRAMEWORK CODE
Driver Interfaces
Drivers
Libraries
Utilities

FRAMEWORK CODE
Interfaces
Components
Libraries
Utilities

Full Software Listings

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

localstatus.h

00001 /*
00002  * Orca-Robotics Project: Components for robotics 
00003  *               http://orca-robotics.sf.net/
00004  * Copyright (c) 2004-2009 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 HYDROICEUTIL_DETAIL_LOCAL_STATUS_H
00012 #define HYDROICEUTIL_DETAIL_LOCAL_STATUS_H
00013 
00014 #include <gbxutilacfr/status.h>
00015 #include <gbxutilacfr/tracer.h>
00016 #include <hydroutil/properties.h>
00017 #include <hydroutil/uncopyable.h>
00018 #include <gbxsickacfr/gbxiceutilacfr/timer.h>
00019 
00020 #include <IceUtil/Mutex.h>
00021 #include <map>
00022 
00023 namespace hydroiceutil
00024 {
00025 
00026 struct LocalSubsystemStatus
00027 {
00028     LocalSubsystemStatus() :
00029         state(gbxutilacfr::SubsystemIdle),
00030         health(gbxutilacfr::SubsystemOk),
00031         isStalled(false),
00032         type(gbxutilacfr::SubsystemStandard),
00033         maxHeartbeatInterval(-1)
00034     {};
00035 
00036     gbxutilacfr::SubsystemState state;
00037     gbxutilacfr::SubsystemHealth health;
00038     std::string message;
00039     bool isStalled;
00040 
00041     gbxutilacfr::SubsystemType type;
00042     double maxHeartbeatInterval;
00043     gbxiceutilacfr::Timer heartbeatTimer;
00044 };
00045 
00046 typedef std::map<std::string,LocalSubsystemStatus> LocalSubsystemStatusMap;
00047 
00048 struct LocalComponentStatus
00049 {
00050     LocalComponentStatus() :
00051         infrastructure(gbxutilacfr::SubsystemIdle),
00052         publishIntervalSec(-1)
00053     {};
00054         
00055     gbxutilacfr::SubsystemState infrastructure;
00056     LocalSubsystemStatusMap subsystems;
00057     double publishIntervalSec;
00058 };
00059 
00070 class LocalStatus : public gbxutilacfr::Status,
00071                     public hydroutil::Uncopyable
00072 {
00073 public:
00074     LocalStatus( gbxutilacfr::Tracer& tracer, const hydroutil::Properties& props );
00075     
00076     // from gbxutilacfr::Status
00077 
00078     // addSubsystem() must be called before notifcations of the subsytem's status.
00079     virtual void addSubsystem( const std::string& subsystem,
00080             double maxHeartbeatIntervalSec=-1.0, gbxutilacfr::SubsystemType type=gbxutilacfr::SubsystemStandard );
00081     virtual void removeSubsystem( const std::string& subsystem );
00082     virtual std::vector<std::string> subsystems();
00083     virtual gbxutilacfr::SubsystemStatus subsystemStatus( const std::string& subsystem );
00084     virtual gbxutilacfr::SubsystemState infrastructureState();
00085     virtual void setMaxHeartbeatInterval( const std::string& subsystem, double interval );
00086     virtual void setSubsystemType( const std::string& subsystem, gbxutilacfr::SubsystemType type );
00087 
00088     virtual void setSubsystemStatus( const std::string& subsystem, gbxutilacfr::SubsystemState state, 
00089             gbxutilacfr::SubsystemHealth health, const std::string& msg="" );
00090 
00091     virtual void initialising( const std::string& subsystem, const std::string& msg="" );
00092     virtual void working( const std::string& subsystem, const std::string& msg="" );
00093     virtual void finalising( const std::string& subsystem, const std::string& msg="" );
00094 
00095     virtual void ok( const std::string& subsystem, const std::string& msg="" );
00096     virtual void warning( const std::string& subsystem, const std::string& msg );
00097     virtual void fault( const std::string& subsystem, const std::string& msg );
00098     virtual void heartbeat( const std::string& subsystem );
00099     virtual void message( const std::string& subsystem, const std::string& msg );
00100 
00101     virtual void infrastructureInitialising();
00102     virtual void infrastructureWorking();
00103     virtual void infrastructureFinalising();
00104     virtual void process();
00105 
00106 private:
00107 
00113     virtual void publishEvent( const LocalComponentStatus& componentStatus );
00114 
00115     LocalComponentStatus componentStatus_;
00116 
00117     // makes acess to to componentStatus_ thread-safe
00118     IceUtil::Mutex localStatusMutex_;
00119 
00120     // this utility function aquires mutex when called from initialising(), ok(), warning(), fault()
00121     void internalSetStatus( const std::string& subsystem, gbxutilacfr::SubsystemState state, 
00122                 gbxutilacfr::SubsystemHealth health, const std::string& msg );
00123 
00124     void localPublish();
00125 
00126     gbxutilacfr::Tracer& tracer_;
00127 
00128     double toleranceMultiplicative_;
00129     double toleranceAdditive_;
00130 
00131     gbxiceutilacfr::Timer publishTimer_;
00132 };
00133 
00134 } // namespace
00135 
00136 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5