orca-robotics


INTRODUCTION
Overview
Download and Install
Documentation

REPOSITORY
Interfaces
Drivers
Libraries
Utilities
Software Map

DEVELOPER
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-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 HYDROICEUTIL_DETAIL_LOCAL_STATUS_H
00012 #define HYDROICEUTIL_DETAIL_LOCAL_STATUS_H
00013 
00014 #include <gbxsickacfr/gbxutilacfr/status.h>
00015 #include <gbxsickacfr/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     gbxsickacfr::gbxutilacfr::SubsystemStatusType type;
00029     std::string message;
00030     gbxsickacfr::gbxiceutilacfr::Timer heartbeatTimer;
00031     double maxHeartbeatInterval;
00032 };
00033 typedef std::map<std::string,LocalSubsystemStatus> NameStatusMap;
00034 
00035 
00036 // all public functions are thread safe.
00037 class LocalStatus : public gbxsickacfr::gbxutilacfr::Status,
00038                     public hydroutil::Uncopyable
00039 {
00040 public:
00041     LocalStatus( gbxsickacfr::gbxutilacfr::Tracer& tracer, const hydroutil::Properties& props );
00042     
00043     // from gbxsickacfr::gbxutilacfr::Status
00044 
00045     // addSubsystem() must be called before notifcations of the subsytem's status.
00046     virtual void addSubsystem( const std::string& subsystem, double maxHeartbeatIntervalSec=-1.0 );
00047     virtual void removeSubsystem( const std::string& subsystem );
00048     virtual std::vector<std::string> subsystems();
00049     virtual gbxsickacfr::gbxutilacfr::SubsystemStatus subsystemStatus( const std::string& subsystem );
00050     virtual void setMaxHeartbeatInterval( const std::string& subsystem, double interval );
00051     virtual void initialising( const std::string& subsystem, const std::string& message="" );
00052     virtual void ok( const std::string& subsystem, const std::string& message="" );
00053     virtual void warning( const std::string& subsystem, const std::string& message );
00054     virtual void fault( const std::string& subsystem, const std::string& message );
00055     virtual void heartbeat( const std::string& subsystem );
00056     virtual void process();
00057 
00058     // This event is called when 
00059     // - the status of any of the registered subsystems changes (including change in the message)
00060     // - the timer for periodic updates expires
00061     //
00062     // This implementation does nothing (but maybe should dump to tracer).
00063     // Overwrite this function to achieve different behavior.
00064     virtual void publishEvent( const NameStatusMap& subsystems );
00065 
00066 private:
00067     NameStatusMap subsystems_;
00068 
00069     // We only have one communicator but may have multiple threads, have
00070     // to protect ourself from simultaneous access
00071     IceUtil::Mutex localStatusMutex_;
00072 
00073     // this function aquires mutex when called from initialising(), ok(), warning(), fault()
00074     void setStatus( const std::string& subsystem, gbxsickacfr::gbxutilacfr::SubsystemStatusType type,
00075                     const std::string& message );
00076 
00077     void localPublish();
00078 
00079     gbxsickacfr::gbxutilacfr::Tracer& tracer_;
00080 
00081     gbxsickacfr::gbxiceutilacfr::Timer publishTimer_;
00082     double publishIntervalSec_;
00083 };
00084 
00085 } // namespace
00086 
00087 #endif
 

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


Generated for Orca Robotics by  doxygen 1.4.5