|
From: <bo...@us...> - 2009-07-02 07:16:03
|
Revision: 426
http://gearbox.svn.sourceforge.net/gearbox/?rev=426&view=rev
Author: borax00
Date: 2009-07-02 07:15:57 +0000 (Thu, 02 Jul 2009)
Log Message:
-----------
MR changes
Modified Paths:
--------------
gearbox/trunk/src/gbxsickacfr/sickdefines.h
gearbox/trunk/src/gbxsmartbatteryacfr/oceanserver.cpp
gearbox/trunk/src/gbxsmartbatteryacfr/oceanserver.h
gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverreader.cpp
gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverreader.h
gearbox/trunk/src/gbxsmartbatteryacfr/test/longtest.cpp
gearbox/trunk/src/gbxutilacfr/tracer.h
gearbox/trunk/src/gbxutilacfr/trivialtracer.cpp
gearbox/trunk/src/gbxutilacfr/trivialtracer.h
Added Paths:
-----------
gearbox/trunk/cmake/StringToCapital.cmake
Added: gearbox/trunk/cmake/StringToCapital.cmake
===================================================================
--- gearbox/trunk/cmake/StringToCapital.cmake (rev 0)
+++ gearbox/trunk/cmake/StringToCapital.cmake 2009-07-02 07:15:57 UTC (rev 426)
@@ -0,0 +1,20 @@
+# GBX_STRING_TO_CAPITAL( input_string OUTPUT_VAR )
+#
+# E.g. converts "gearbox" to "Gearbox"
+#
+macro( GBX_STRING_TO_CAPITAL input_string OUTPUT_VAR )
+
+ # jump through the hoops to construct project name string with the first character capitalized
+ string( LENGTH ${input_string} string_length )
+
+ math( EXPR string_length_minus_one "${string_length} - 1" )
+
+ string( SUBSTRING ${input_string} 0 1 output_start )
+ string( SUBSTRING ${input_string} 1 ${string_length_minus_one} output_rest )
+
+ string( TOUPPER ${output_start} output_start_upper )
+ string( TOLOWER ${output_rest} output_rest_lower )
+
+ set( ${OUTPUT_VAR} "${output_start_upper}${output_rest_lower}" )
+
+endmacro( GBX_STRING_TO_CAPITAL input_string OUTPUT_VAR )
Modified: gearbox/trunk/src/gbxsickacfr/sickdefines.h
===================================================================
--- gearbox/trunk/src/gbxsickacfr/sickdefines.h 2009-06-13 12:30:47 UTC (rev 425)
+++ gearbox/trunk/src/gbxsickacfr/sickdefines.h 2009-07-02 07:15:57 UTC (rev 426)
@@ -11,6 +11,7 @@
#define SICK_ACFR_DRIVER_SICKDEFINES_H
#include <string>
+#include <stdint.h>
namespace gbxsickacfr {
Modified: gearbox/trunk/src/gbxsmartbatteryacfr/oceanserver.cpp
===================================================================
--- gearbox/trunk/src/gbxsmartbatteryacfr/oceanserver.cpp 2009-06-13 12:30:47 UTC (rev 425)
+++ gearbox/trunk/src/gbxsmartbatteryacfr/oceanserver.cpp 2009-07-02 07:15:57 UTC (rev 426)
@@ -13,13 +13,15 @@
#include "oceanserver.h"
namespace gbxsmartbatteryacfr {
-
-static const int MAX_EXCEPTIONS_ROW = 10;
+static const int MAX_EXCEPTIONS_BEFORE_RESET = 10;
+static const int MAX_EXCEPTIONS_BEFORE_CRITICAL = 20;
+
OceanServer::OceanServer( const std::string &port,
gbxutilacfr::Tracer &tracer)
: tracer_(tracer),
- exceptionCounter_(0)
+ exceptionCounter_(0),
+ exceptionString_("")
{
reader_.reset(new gbxsmartbatteryacfr::OceanServerReader( port, tracer_ ));
}
@@ -27,14 +29,16 @@
const gbxsmartbatteryacfr::OceanServerSystem&
OceanServer::getData()
{
+ gbxsmartbatteryacfr::OceanServerSystem data;
+
try
{
// read new data, this may throw
- gbxsmartbatteryacfr::OceanServerSystem data;
reader_->read(data);
- // if successful, reset counter
+ // if successful, reset counter and string
exceptionCounter_ = 0;
+ exceptionString_ = "";
// update internal (full) record
gbxsmartbatteryacfr::updateWithNewData( data, data_ );
@@ -48,11 +52,28 @@
tracer_.debug( ss.str(), 3 );
exceptionCounter_++;
- if (exceptionCounter_ >= MAX_EXCEPTIONS_ROW)
+ stringstream ssEx;
+ ssEx << e.what() << endl;
+ for (unsigned int i=0; i<data.rawRecord.size(); i++)
+ ssEx << data.rawRecord[i] << endl;
+ ssEx << endl;
+ exceptionString_ = exceptionString_ + ssEx.str();
+
+ if (exceptionCounter_ >= MAX_EXCEPTIONS_BEFORE_RESET)
{
+ stringstream ss;
+ ss << "OceanServer: " << __func__ << ": Caught " << MAX_EXCEPTIONS_BEFORE_RESET
+ << " ParsingExceptions in a row. Resetting the reader now...";
+ tracer_.warning( ss.str() );
+ reader_->reset();
+ }
+
+ if (exceptionCounter_ >= MAX_EXCEPTIONS_BEFORE_CRITICAL)
+ {
ss.str("");
- ss << "OceanServer: " << __func__ << ": Caught " << MAX_EXCEPTIONS_ROW
- << " ParsingExceptions in a row. Something must be wrong";
+ ss << "OceanServer: " << __func__ << ": Caught " << MAX_EXCEPTIONS_BEFORE_CRITICAL
+ << " ParsingExceptions in a row. Something must be wrong. Here's the history: " << endl
+ << exceptionString_;
throw gbxutilacfr::Exception( ERROR_INFO, ss.str() );
}
}
Modified: gearbox/trunk/src/gbxsmartbatteryacfr/oceanserver.h
===================================================================
--- gearbox/trunk/src/gbxsmartbatteryacfr/oceanserver.h 2009-06-13 12:30:47 UTC (rev 425)
+++ gearbox/trunk/src/gbxsmartbatteryacfr/oceanserver.h 2009-07-02 07:15:57 UTC (rev 426)
@@ -47,6 +47,7 @@
auto_ptr<gbxsmartbatteryacfr::OceanServerReader> reader_;
int exceptionCounter_;
+ std::string exceptionString_;
};
Modified: gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverreader.cpp
===================================================================
--- gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverreader.cpp 2009-06-13 12:30:47 UTC (rev 425)
+++ gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverreader.cpp 2009-07-02 07:15:57 UTC (rev 426)
@@ -64,13 +64,25 @@
tracer_(tracer),
parser_(tracer),
firstTime_(true)
-{
+{
checkConnection();
+ reset();
+}
- // send the command to start reading data
+void
+OceanServerReader::reset()
+{
serial_.flush();
- const char startReading = 'X';
- serial_.write(&startReading, 1);
+
+ // send the command to get into menu mode
+ const char menuMode = ' ';
+ serial_.write(&menuMode, 1);
+
+ // send the command to start sending hex data
+ const char startSendingHex = 'X';
+ serial_.write(&startSendingHex, 1);
+
+ firstTime_ = true;
}
void
Modified: gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverreader.h
===================================================================
--- gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverreader.h 2009-06-13 12:30:47 UTC (rev 425)
+++ gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverreader.h 2009-07-02 07:15:57 UTC (rev 426)
@@ -41,6 +41,12 @@
//! May throw HardwareReadingExceptions and ParsingExceptions
void read( OceanServerSystem &system );
+ //! Resets the reader:
+ //! - tells the OceanServer system to spit out hex data
+ //! - tries to find the beginning of a new record
+ void reset();
+
+
private:
gbxserialacfr::Serial serial_;
Modified: gearbox/trunk/src/gbxsmartbatteryacfr/test/longtest.cpp
===================================================================
--- gearbox/trunk/src/gbxsmartbatteryacfr/test/longtest.cpp 2009-06-13 12:30:47 UTC (rev 425)
+++ gearbox/trunk/src/gbxsmartbatteryacfr/test/longtest.cpp 2009-07-02 07:15:57 UTC (rev 426)
@@ -49,8 +49,8 @@
gbxsmartbatteryacfr::BatteryHealthWarningConfig config;
config.expectedNumBatteries = 2;
config.numCyclesThreshhold = 300;
- config.chargeTempThreshhold = 54.0;
- config.dischargeTempThreshhold = 70.0;
+ config.chargeTempThreshhold = 40.0;
+ config.dischargeTempThreshhold = 45.0;
config.chargeWarnThreshhold = 10;
config.chargeDeviationThreshold = 10;
Modified: gearbox/trunk/src/gbxutilacfr/tracer.h
===================================================================
--- gearbox/trunk/src/gbxutilacfr/tracer.h 2009-06-13 12:30:47 UTC (rev 425)
+++ gearbox/trunk/src/gbxutilacfr/tracer.h 2009-07-02 07:15:57 UTC (rev 426)
@@ -118,22 +118,34 @@
//! Routing is determined by InfoToXxx parameter.
//! If localOnly is set to TRUE, messages are not sent over the network (useful when traces
//! is caused by network errors).
- virtual void info( const std::string &message, int level=1, bool localOnly=false ) = 0;
+ virtual void info( const std::string &message, int level=1, bool localOnly=false )
+ { info("",message,level,localOnly); }
+ //! This version gives the Tracer some hints about a specific subsytem which generated the message
+ virtual void info( const std::string &subsystem, const std::string &message, int level=1, bool localOnly=false ) = 0;
//! Routing is determined by WarningToXxx parameter.
//! If localOnly is set to TRUE, messages are not sent over the network (useful when traces
//! is caused by network errors).
- virtual void warning( const std::string &message, int level=1, bool localOnly=false ) = 0;
+ virtual void warning( const std::string &message, int level=1, bool localOnly=false )
+ { warning("",message,level,localOnly); }
+ //! This version gives the Tracer some hints about a specific subsytem which generated the message
+ virtual void warning( const std::string &subsystem, const std::string &message, int level=1, bool localOnly=false ) = 0;
//! Routing is determined by ErrorToXxx parameter.
//! If localOnly is set to TRUE, messages are not sent over the network (useful when traces
//! is caused by network errors).
- virtual void error( const std::string &message, int level=1, bool localOnly=false ) = 0;
+ virtual void error( const std::string &message, int level=1, bool localOnly=false )
+ { error("",message,level,localOnly); }
+ //! This version gives the Tracer some hints about a specific subsytem which generated the message
+ virtual void error( const std::string &subsystem, const std::string &message, int level=1, bool localOnly=false ) = 0;
//! Routing is determined by DebugToXxx parameter.
//! If localOnly is set to TRUE, messages are not sent over the network (useful when traces
//! is caused by network errors).
- virtual void debug( const std::string &message, int level=1, bool localOnly=false ) = 0;
+ virtual void debug( const std::string &message, int level=1, bool localOnly=false )
+ { debug("",message,level,localOnly); }
+ //! This version gives the Tracer some hints about a specific subsytem which generated the message
+ virtual void debug( const std::string &subsystem, const std::string &message, int level=1, bool localOnly=false ) = 0;
//! Returns the verbosity level for traceType to destType. This test is performed
//! internally by all tracing functions, e.g. error(). You may want to call this
@@ -144,12 +156,12 @@
//! @b EXPERIMENTAL. Sets debug level for an individual subsystem.
//! Only debug-to-display is supported.
- virtual void setLevel( const std::string &subsystem, int level=0 ) {};
+ virtual void setSubsystemDebugLevel( const std::string &subsystem, int level=0 ) {};
//! @b EXPERIMENTAL. Debug tracing for an individual subsystem.
//! Only debug-to-display is supported.
//! The maximum traceable level is set per-subsystem with setLevel().
- virtual void debug( const std::string &subsystem, const std::string &message, int level=1 )
+ virtual void subsystemDebug( const std::string &subsystem, const std::string &message, int level=1 )
{
debug( message, level );
};
Modified: gearbox/trunk/src/gbxutilacfr/trivialtracer.cpp
===================================================================
--- gearbox/trunk/src/gbxutilacfr/trivialtracer.cpp 2009-06-13 12:30:47 UTC (rev 425)
+++ gearbox/trunk/src/gbxutilacfr/trivialtracer.cpp 2009-07-02 07:15:57 UTC (rev 426)
@@ -31,31 +31,51 @@
}
void
-TrivialTracer::info( const std::string &message, int level, bool localOnly )
+TrivialTracer::info( const std::string &subsystem, const std::string &message, int level, bool localOnly )
{
if ( traceLevels_[InfoTrace] >= level )
- cout << "info: " << message << endl;
+ {
+ cout << "info: ";
+ if ( subsystem != "" )
+ cout << subsystem << ": ";
+ cout << message << endl;
+ }
}
void
-TrivialTracer::warning( const std::string &message, int level, bool localOnly )
+TrivialTracer::warning( const std::string &subsystem, const std::string &message, int level, bool localOnly )
{
if ( traceLevels_[WarningTrace] >= level )
- cout << "warn: " << message << endl;
+ {
+ cout << "warn: ";
+ if ( subsystem != "" )
+ cout << subsystem << ": ";
+ cout << message << endl;
+ }
}
void
-TrivialTracer::error( const std::string &message, int level, bool localOnly )
+TrivialTracer::error( const std::string &subsystem, const std::string &message, int level, bool localOnly )
{
if ( traceLevels_[ErrorTrace] >= level )
- cout << "error: " << message << endl;
+ {
+ cout << "error: ";
+ if ( subsystem != "" )
+ cout << subsystem << ": ";
+ cout << message << endl;
+ }
}
void
-TrivialTracer::debug( const std::string &message, int level, bool localOnly )
+TrivialTracer::debug( const std::string &subsystem, const std::string &message, int level, bool localOnly )
{
if ( traceLevels_[DebugTrace] >= level )
- cout << "debug: " << message << endl;
+ {
+ cout << "debug: ";
+ if ( subsystem != "" )
+ cout << subsystem << ": ";
+ cout << message << endl;
+ }
}
int
Modified: gearbox/trunk/src/gbxutilacfr/trivialtracer.h
===================================================================
--- gearbox/trunk/src/gbxutilacfr/trivialtracer.h 2009-06-13 12:30:47 UTC (rev 425)
+++ gearbox/trunk/src/gbxutilacfr/trivialtracer.h 2009-07-02 07:15:57 UTC (rev 426)
@@ -33,12 +33,21 @@
int error=9 );
virtual void print( const std::string &message );
- virtual void info( const std::string &message, int level=1, bool localOnly=false );
- virtual void warning( const std::string &message, int level=1, bool localOnly=false );
- virtual void error( const std::string &message, int level=1, bool localOnly=false );
- virtual void debug( const std::string &message, int level=1, bool localOnly=false );
+ virtual void info( const std::string &message, int level=1, bool localOnly=false )
+ { info("",message,level,localOnly); }
+ virtual void warning( const std::string &message, int level=1, bool localOnly=false )
+ { warning("",message,level,localOnly); }
+ virtual void error( const std::string &message, int level=1, bool localOnly=false )
+ { error("",message,level,localOnly); }
+ virtual void debug( const std::string &message, int level=1, bool localOnly=false )
+ { debug("",message,level,localOnly); }
virtual int verbosity( TraceType traceType, DestinationType destType=ToAny ) const;
+ virtual void info( const std::string &subsystem, const std::string &message, int level=1, bool localOnly=false );
+ virtual void warning( const std::string &subsystem, const std::string &message, int level=1, bool localOnly=false );
+ virtual void error( const std::string &subsystem, const std::string &message, int level=1, bool localOnly=false );
+ virtual void debug( const std::string &subsystem, const std::string &message, int level=1, bool localOnly=false );
+
private:
int traceLevels_[NumberOfTraceTypes];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|