|
From: <rus...@us...> - 2008-05-08 08:10:39
|
Revision: 140
http://gearbox.svn.sourceforge.net/gearbox/?rev=140&view=rev
Author: russo2503v
Date: 2008-05-08 01:10:39 -0700 (Thu, 08 May 2008)
Log Message:
-----------
added functions to get the current subsystem status. not part of an external API.
Modified Paths:
--------------
gearbox/trunk/src/gbxsickacfr/gbxutilacfr/status.h
gearbox/trunk/src/gbxsickacfr/gbxutilacfr/trivialstatus.cpp
gearbox/trunk/src/gbxsickacfr/gbxutilacfr/trivialstatus.h
Modified: gearbox/trunk/src/gbxsickacfr/gbxutilacfr/status.h
===================================================================
--- gearbox/trunk/src/gbxsickacfr/gbxutilacfr/status.h 2008-05-07 07:35:47 UTC (rev 139)
+++ gearbox/trunk/src/gbxsickacfr/gbxutilacfr/status.h 2008-05-08 08:10:39 UTC (rev 140)
@@ -12,10 +12,41 @@
#define GBXUTILACFR_STATUS_H
#include <string>
+#include <vector>
namespace gbxsickacfr {
namespace gbxutilacfr {
+//! Possible subsystem status values
+enum SubsystemStatusType
+{
+ //! Subsystem is initialising -- it's not exactly OK yet, but there's also no fault yet.
+ SubsystemStatusInitialising,
+ //! Subsystem is OK
+ SubsystemStatusOk,
+ //! Subsystem has encountered an abnormal but non-fault condition
+ SubsystemStatusWarning,
+ //! Subsystem has declared a fault
+ SubsystemStatusFault,
+ //! Subsystem has not been heard from for an abnormally long time
+ SubsystemStatusStalled
+};
+
+//! Status for a single subsystem
+struct SubsystemStatus
+{
+ //! Machine-readable status description
+ SubsystemStatusType type;
+
+ //! Human-readable status description
+ std::string message;
+
+ //! Ratio of time since last heartbeat to maximum expected time between heartbeats.
+ //! For example, sinceHeartbeat=0.5 means that half of normally expected interval between heartbeats
+ //! has elapsed.
+ float sinceHeartbeat;
+};
+
/*
@brief Local interface to component status.
@@ -56,16 +87,6 @@
public:
- // this is for internal implementation only
- enum SubsystemStatusType
- {
- Initialising,
- Ok,
- Warning,
- Fault,
- Stalled
- };
-
virtual ~Status() {};
/*
@@ -87,6 +108,13 @@
// Throws gbxutilacfr::Exception if the subsystem does not exist.
virtual void removeSubsystem( const std::string& subsystem )=0;
+ // Returns a list of subsystem names.
+ virtual std::vector<std::string> subsystems()=0;
+
+ // Returns status of subsystem with the given name.
+ // Throws gbxutilacfr::Exception when the specified subsystem does not exist.
+ virtual SubsystemStatus subsystemStatus( const std::string& subsystem )=0;
+
// Modifies maximum expected interval between heartbeats (in seconds).
// When time since last heartbeat exceeds this, alarm is raised.
// Throws gbxutilacfr::Exception if the subsystem does not exist.
Modified: gearbox/trunk/src/gbxsickacfr/gbxutilacfr/trivialstatus.cpp
===================================================================
--- gearbox/trunk/src/gbxsickacfr/gbxutilacfr/trivialstatus.cpp 2008-05-07 07:35:47 UTC (rev 139)
+++ gearbox/trunk/src/gbxsickacfr/gbxutilacfr/trivialstatus.cpp 2008-05-08 08:10:39 UTC (rev 140)
@@ -11,6 +11,7 @@
#include <iostream>
#include <sstream>
#include "trivialstatus.h"
+#include "exceptions.h"
using namespace std;
@@ -44,6 +45,18 @@
tracer_.debug( ss.str() );
}
+std::vector<std::string>
+TrivialStatus::subsystems()
+{
+ return std::vector<std::string> ();
+}
+
+SubsystemStatus
+TrivialStatus::subsystemStatus( const std::string& subsystem )
+{
+ throw Exception( ERROR_INFO, "This implementation of Status does not store status of the subsystems" );
+}
+
void
TrivialStatus::setMaxHeartbeatInterval( const std::string& subsystem, double maxHeartbeatIntervalSec )
{
Modified: gearbox/trunk/src/gbxsickacfr/gbxutilacfr/trivialstatus.h
===================================================================
--- gearbox/trunk/src/gbxsickacfr/gbxutilacfr/trivialstatus.h 2008-05-07 07:35:47 UTC (rev 139)
+++ gearbox/trunk/src/gbxsickacfr/gbxutilacfr/trivialstatus.h 2008-05-08 08:10:39 UTC (rev 140)
@@ -32,6 +32,10 @@
virtual void addSubsystem( const std::string& subsystem, double maxHeartbeatIntervalSec=-1.0 );
virtual void removeSubsystem( const std::string& subsystem );
+ // does not keep track of subsystems, returns empty vector.
+ virtual std::vector<std::string> subsystems();
+ // does not keep track of status, throws Exception on any query
+ virtual SubsystemStatus subsystemStatus( const std::string& subsystem );
virtual void setMaxHeartbeatInterval( const std::string& subsystem, double interval );
virtual void initialising( const std::string& subsystem, const std::string& message="" );
virtual void ok( const std::string& subsystem, const std::string& message="" );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|