|
From: <rus...@us...> - 2009-05-01 21:24:11
|
Revision: 397
http://gearbox.svn.sourceforge.net/gearbox/?rev=397&view=rev
Author: russo2503v
Date: 2009-05-01 21:23:59 +0000 (Fri, 01 May 2009)
Log Message:
-----------
added missing files
Added Paths:
-----------
gearbox/trunk/cmake/SetupProjectName.cmake
gearbox/trunk/cmake/WritePackageConfig.cmake
gearbox/trunk/cmake/internal/gearbox-config-internal.cmake
gearbox/trunk/cmake/internal/gearbox-config-version.cmake.in
gearbox/trunk/cmake/internal/gearbox-config.cmake
gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/threadutils.cpp
gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/threadutils.h
gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverhealthchecks.cpp
gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverhealthchecks.h
gearbox/trunk/src/gbxutilacfr/stoppable.h
Added: gearbox/trunk/cmake/SetupProjectName.cmake
===================================================================
--- gearbox/trunk/cmake/SetupProjectName.cmake (rev 0)
+++ gearbox/trunk/cmake/SetupProjectName.cmake 2009-05-01 21:23:59 UTC (rev 397)
@@ -0,0 +1,30 @@
+# this is a copy of GBX_STRING_TO_CAPITAL in StringToCapital.cmake
+# (making a copy so that we can use this file here and in derived projects)
+macro( UTIL_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( UTIL_STRING_TO_CAPITAL input_string OUTPUT_VAR )
+
+#
+# We often use different variants of the project name.
+# E.g. for project "gearbox" we want "GEARBOX", "gearbox", "Gearbox".
+#
+
+UTIL_STRING_TO_CAPITAL( ${PROJECT_NAME} GBX_PROJECT_NAME_CAP )
+# message( STATUS "Setting capitalized project name to ${PROJECT_NAME_CAP}" )
+
+string( TOUPPER ${PROJECT_NAME} GBX_PROJECT_NAME_UPPER )
+
+string( TOLOWER ${PROJECT_NAME} GBX_PROJECT_NAME_LOWER )
Added: gearbox/trunk/cmake/WritePackageConfig.cmake
===================================================================
--- gearbox/trunk/cmake/WritePackageConfig.cmake (rev 0)
+++ gearbox/trunk/cmake/WritePackageConfig.cmake 2009-05-01 21:23:59 UTC (rev 397)
@@ -0,0 +1,43 @@
+
+set( _input_dir ${PROJECT_SOURCE_DIR}/cmake/internal )
+set( _output_dir ${PROJECT_BINARY_DIR} )
+set( _destination lib/${PROJECT_NAME} )
+
+# set( _input_file config-internal.cmake.in )
+# set( _output_file ${PROJECT_NAME}-config-internal.cmake )
+# configure_file(
+# ${_input_dir}/${_input_file}
+# ${_output_dir}/${_output_file}
+# @ONLY )
+
+# set( _input_file config-external.cmake.in )
+set( _output_file ${PROJECT_NAME}-config.cmake )
+# configure_file(
+# ${_input_dir}/${_input_file}
+# ${_output_dir}/${_output_file}
+# @ONLY )
+install(
+ FILES ${_input_dir}/${_output_file}
+ DESTINATION ${_destination} )
+
+set( _input_file ${PROJECT_NAME}-config-version.cmake.in )
+set( _output_file ${PROJECT_NAME}-config-version.cmake )
+configure_file(
+ ${_input_dir}/${_input_file}
+ ${_output_dir}/${_output_file}
+ @ONLY )
+install(
+ FILES ${_output_dir}/${_output_file}
+ DESTINATION ${_destination} )
+
+# export targets
+install(
+ EXPORT ${PROJECT_NAME}-targets
+# NAMESPACE import_
+ DESTINATION ${_destination} )
+
+set( _input_dir )
+set( _output_dir )
+set( _input_file )
+set( _output_file )
+set( _destination )
Added: gearbox/trunk/cmake/internal/gearbox-config-internal.cmake
===================================================================
--- gearbox/trunk/cmake/internal/gearbox-config-internal.cmake (rev 0)
+++ gearbox/trunk/cmake/internal/gearbox-config-internal.cmake 2009-05-01 21:23:59 UTC (rev 397)
@@ -0,0 +1,11 @@
+set( GEARBOX_FOUND 1 )
+
+# This is potentially problematic: installed directory structure is different from in-source one.
+set( GEARBOX_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/gearbox/src" )
+
+set( GEARBOX_CMAKE_DIR "${CMAKE_SOURCE_DIR}/gearbox/cmake" )
+
+set( GEARBOX_USE_FILE "${GEARBOX_CMAKE_DIR}/gearbox-use-file.cmake" )
+
+# this is where Gearbox libs will be installed
+set( GEARBOX_LINK_DIR ${CMAKE_INSTALL_PREFIX}/lib/gearbox )
Added: gearbox/trunk/cmake/internal/gearbox-config-version.cmake.in
===================================================================
--- gearbox/trunk/cmake/internal/gearbox-config-version.cmake.in (rev 0)
+++ gearbox/trunk/cmake/internal/gearbox-config-version.cmake.in 2009-05-01 21:23:59 UTC (rev 397)
@@ -0,0 +1,8 @@
+set( PACKAGE_VERSION @GBX_PROJECT_VERSION@ )
+
+if( "${PACKAGE_FIND_VERSION_MAJOR}" EQUAL @GBX_PROJECT_VERSION_MAJOR@ )
+if( "${PACKAGE_FIND_VERSION_MINOR}" EQUAL @GBX_PROJECT_VERSION_MINOR@ )
+ set( PACKAGE_VERSION_COMPATIBLE 1 )
+ set( PACKAGE_VERSION_EXACT 1 )
+endif()
+endif()
Added: gearbox/trunk/cmake/internal/gearbox-config.cmake
===================================================================
--- gearbox/trunk/cmake/internal/gearbox-config.cmake (rev 0)
+++ gearbox/trunk/cmake/internal/gearbox-config.cmake 2009-05-01 21:23:59 UTC (rev 397)
@@ -0,0 +1,33 @@
+# Find Gearbox includes and library.
+#
+#
+
+set( GEARBOX_FOUND 1 )
+
+# this is the installed location of <package>-config.cmake file
+get_filename_component( _found_dir "${CMAKE_CURRENT_LIST_FILE}" PATH )
+include( ${_found_dir}/gearbox-targets.cmake )
+
+# assume that <package>-config.cmake was installed into
+# <install-root>/lib/<package>/
+set( _install_dir "${_found_dir}/../../" )
+
+get_filename_component(
+ GEARBOX_INCLUDE_DIR
+ "${_install_dir}/include/gearbox"
+ ABSOLUTE )
+
+get_filename_component(
+ GEARBOX_CMAKE_DIR
+ "${_install_dir}/share/gearbox/cmake"
+ ABSOLUTE )
+
+set( GEARBOX_USE_FILE "${GEARBOX_CMAKE_DIR}/gearbox-use-file.cmake" )
+
+get_filename_component(
+ GEARBOX_LINK_DIR
+ "${_install_dir}/lib/gearbox"
+ ABSOLUTE )
+
+set( _found_dir )
+set( _install_dir )
Added: gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/threadutils.cpp
===================================================================
--- gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/threadutils.cpp (rev 0)
+++ gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/threadutils.cpp 2009-05-01 21:23:59 UTC (rev 397)
@@ -0,0 +1,35 @@
+/*
+ * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
+ * http://gearbox.sf.net/
+ * Copyright (c) 2004-2008 Alex Brooks, Alexei Makarenko, Tobias Kaupp
+ *
+ * This distribution is licensed to you under the terms described in
+ * the LICENSE file included in this distribution.
+ *
+ */
+
+#include <assert.h>
+#include <IceUtil/Thread.h>
+#include "threadutils.h"
+
+namespace gbxiceutilacfr {
+
+void checkedSleep( gbxutilacfr::Stoppable* activity, const IceUtil::Time& duration, int checkIntervalMs )
+{
+ assert( activity && "Null activity pointer" );
+
+ IceUtil::Time wakeupTime = IceUtil::Time::now() + duration;
+ IceUtil::Time checkInterval = IceUtil::Time::milliSeconds( checkIntervalMs );
+
+ while ( !activity->isStopping() && IceUtil::Time::now() < wakeupTime )
+ {
+ IceUtil::ThreadControl::sleep( checkInterval );
+ }
+}
+
+void checkedSleep( gbxutilacfr::Stoppable* activity, int durationMs, int checkIntervalMs )
+{
+ checkedSleep( activity, IceUtil::Time::milliSeconds( durationMs ), checkIntervalMs );
+}
+
+} // namespace
Added: gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/threadutils.h
===================================================================
--- gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/threadutils.h (rev 0)
+++ gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/threadutils.h 2009-05-01 21:23:59 UTC (rev 397)
@@ -0,0 +1,30 @@
+/*
+ * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
+ * http://gearbox.sf.net/
+ * Copyright (c) 2004-2008 Alex Brooks, Alexei Makarenko, Tobias Kaupp
+ *
+ * This distribution is licensed to you under the terms described in
+ * the LICENSE file included in this distribution.
+ *
+ */
+
+#ifndef GBXICEUTILACFR_THREAD_UTILS_H
+#define GBXICEUTILACFR_THREAD_UTILS_H
+
+#include <IceUtil/Time.h>
+#include <gbxutilacfr/stoppable.h>
+
+namespace gbxiceutilacfr {
+
+//! Sleeps for @ref duration waking up every @ref checkIntervalMs [ms] to check if the @c activity
+//! was told to stop. This implementation is very simple so the error in total sleep duration
+//! can be as large as checkIntervalMs. In particular, if @ref duration is shorter than @ref checkIntervalMs,
+//! this function will sleep for @ref checkIntervalMs.
+void checkedSleep( gbxutilacfr::Stoppable* activity, const IceUtil::Time& duration, int checkIntervalMs=250 );
+
+//! Same as above, but sleep duration is specified in milliseconds.
+void checkedSleep( gbxutilacfr::Stoppable* activity, int durationMs, int checkIntervalMs=250 );
+
+} // end namespace
+
+#endif
Added: gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverhealthchecks.cpp
===================================================================
--- gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverhealthchecks.cpp (rev 0)
+++ gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverhealthchecks.cpp 2009-05-01 21:23:59 UTC (rev 397)
@@ -0,0 +1,293 @@
+/*
+ * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
+ * http://gearbox.sf.net/
+ * Copyright (c) 2004-2009 Tobias Kaupp
+ *
+ * This distribution is licensed to you under the terms described in
+ * the LICENSE file included in this distribution.
+ *
+ */
+
+#include <sstream>
+#include "oceanserverhealthchecks.h"
+
+
+using namespace std;
+
+namespace gbxsmartbatteryacfr
+{
+ namespace
+ {
+
+ bool haveBattery( const OceanServerSystem &batteryData,
+ vector<string> &warnShort,
+ vector<string> &warnVerbose )
+ {
+ const vector<bool> &bats = batteryData.availableBatteries;
+ bool haveBattery = false;
+ for (unsigned int i=0; i<bats.size(); i++)
+ {
+ if (bats[i] == true) {
+ haveBattery = true;
+ break;
+ }
+ }
+ if (!haveBattery)
+ {
+ warnVerbose.push_back("Driver reports that there are no batteries installed!\n");
+ warnShort.push_back("NO BATTERIES! ");
+ }
+ return haveBattery;
+ }
+
+ string toString( const vector<string> &stringList )
+ {
+ stringstream ss;
+ for (unsigned int i=0; i<stringList.size(); ++i)
+ {
+ ss << stringList[i];
+ }
+ return ss.str();
+
+ }
+
+ }
+
+bool checkNumberOfBatteries( const OceanServerSystem &batteryData,
+ std::vector<std::string> &warnShort,
+ std::vector<std::string> &warnVerbose,
+ int expectedNumBatteries )
+{
+ bool haveWarning = false;
+
+ int numBatteries = 0;
+ const vector<bool> &bats = batteryData.availableBatteries;
+
+ for (unsigned int i=0; i<bats.size(); i++)
+ {
+ if (bats[i] == true) {
+ numBatteries++;
+ }
+ }
+ if ( numBatteries!=expectedNumBatteries )
+ {
+ stringstream ssWarnShort;
+ ssWarnShort << "ONLY " << numBatteries << " BATTERIES! ";
+ warnShort.push_back(ssWarnShort.str());
+ stringstream ssWarnVerbose;
+ ssWarnVerbose << "Only found " << numBatteries << " battery modules (expected to see " << expectedNumBatteries << ")" << endl;
+ warnVerbose.push_back( ssWarnVerbose.str() );
+ haveWarning = true;
+ }
+
+ return haveWarning;
+}
+
+bool checkNumCycles( const OceanServerSystem &batteryData,
+ vector<string> &warnShort,
+ vector<string> &warnVerbose,
+ int numCyclesThreshhold,
+ bool printRawRecord )
+{
+ bool haveWarning = false;
+
+ map<int,SmartBattery>::const_iterator it;
+ for (it=batteryData.batteries().begin(); it!=batteryData.batteries().end(); it++)
+ {
+ const SmartBattery &bat = batteryData.battery( it->first );
+ if ( !bat.has(CycleCount) ) continue;
+
+ int numCycles = bat.cycleCount();
+
+ // There's a bug in the Oceanserver system which sometimes produces an FFFF record for this field.
+ // According to Kevin Ludlam (lu...@oc...), "caused by a collision on the SMBus"
+ if ( (numCycles > numCyclesThreshhold) && (numCycles!=65535) )
+ {
+ haveWarning = true;
+ stringstream ssWarnShort;
+ ssWarnShort << "BAT(" << it->first << "): HIGH CYCLES! ";
+ warnShort.push_back(ssWarnShort.str());
+ stringstream ssWarnVerbose;
+ ssWarnVerbose << "High charge cycles! Battery no " << it->first << " has had " << numCycles << " cycles (consider swapping at " << numCyclesThreshhold << " cycles)" << endl;
+ warnVerbose.push_back(ssWarnVerbose.str());
+ }
+ }
+
+ if (haveWarning && printRawRecord)
+ {
+ stringstream ssWarnVerbose;
+ ssWarnVerbose << "Latest raw record: " << endl << toString(batteryData.rawRecord) << endl;
+ warnVerbose.push_back(ssWarnVerbose.str());
+ }
+
+ return haveWarning;
+
+}
+
+bool checkTemperatures(const OceanServerSystem &batteryData,
+ vector<string> &warnShort,
+ vector<string> &warnVerbose,
+ double chargeTempThreshhold,
+ double dischargeTempThreshhold,
+ bool printRawRecord )
+{
+ bool haveWarning = false;
+
+ map<int,SmartBattery>::const_iterator it;
+
+ for (it=batteryData.batteries().begin(); it!=batteryData.batteries().end(); it++)
+ {
+ int batteryNumber = it->first;
+ const SmartBattery &bat = batteryData.battery( batteryNumber );
+ if ( !bat.has(Temperature) ) continue;
+
+ assert( (int)batteryData.chargingStates.size() >= batteryNumber-1 );
+ bool isCharging = batteryData.chargingStates[batteryNumber-1];
+
+ double tempThreshhold = 0.0;
+ if (isCharging) {
+ tempThreshhold = chargeTempThreshhold;
+ } else {
+ tempThreshhold = dischargeTempThreshhold;
+ }
+
+ double temperature = bat.temperature();
+ if ( temperature > tempThreshhold)
+ {
+ haveWarning = true;
+ stringstream ssWarnShort;
+ ssWarnShort << "BAT(" << batteryNumber << "): HOT! ";
+ warnShort.push_back(ssWarnShort.str());
+ stringstream ssWarnVerbose;
+ ssWarnVerbose << "High temperature! Battery no " << batteryNumber << " has " << temperature << "degC (threshhold: " << tempThreshhold << "degC)" << endl;
+ warnVerbose.push_back(ssWarnVerbose.str());
+ }
+ }
+
+ if (haveWarning && printRawRecord)
+ {
+ stringstream ssWarnVerbose;
+ ssWarnVerbose << "Latest raw record: " << endl << toString(batteryData.rawRecord) << endl;
+ warnVerbose.push_back(ssWarnVerbose.str());
+ }
+
+ return haveWarning;
+}
+
+bool checkCharges(const OceanServerSystem &batteryData,
+ vector<string> &warnShort,
+ vector<string> &warnVerbose,
+ int chargeWarnThreshhold,
+ int chargeDeviationThreshold )
+{
+ bool haveWarning = false;
+
+ map<int,SmartBattery>::const_iterator it;
+
+ for (it=batteryData.batteries().begin(); it!=batteryData.batteries().end(); it++)
+ {
+ int batteryNumber = it->first;
+ const SmartBattery &bat = batteryData.battery( batteryNumber );
+ if ( !bat.has(RelativeStateOfCharge) ) continue;
+
+ int charge = bat.relativeStateOfCharge();
+ const int avgCharge = batteryData.percentCharge;
+
+ // check whether battery charge is lower than the average
+ if ( charge < (avgCharge - chargeDeviationThreshold) )
+ {
+ haveWarning = true;
+ stringstream ssWarnShort;
+ ssWarnShort << "BAT(" << batteryNumber << "): INCONSISTENT CHARGE! ";
+ warnShort.push_back(ssWarnShort.str());
+ stringstream ssWarnVerbose;
+ ssWarnVerbose << "Inconsistent charge! Battery no " << batteryNumber << "'s charge is " << charge << "% (average: " << avgCharge << "%)" << endl;
+ warnVerbose.push_back(ssWarnVerbose.str());
+ }
+
+ // check whether battery charge is below a threshhold
+ if (charge < chargeWarnThreshhold)
+ {
+ haveWarning = true;
+ stringstream ssWarnShort;
+ ssWarnShort << "BAT(" << batteryNumber << "): LOW CHARGE! ";
+ warnShort.push_back(ssWarnShort.str());
+ stringstream ssWarnVerbose;
+ ssWarnVerbose << "Low charge! Battery no " << batteryNumber << "'s charge is " << charge << "% (threshhold: " << chargeWarnThreshhold << "%)" << endl;
+ warnVerbose.push_back(ssWarnVerbose.str());
+ }
+ }
+
+ return haveWarning;
+}
+
+bool checkModuleHealth( const OceanServerSystem &batteryData,
+ vector<string> &warnShort,
+ vector<string> &warnVerbose )
+{
+ bool haveWarning = false;
+
+ // check the flags
+ const vector<bool> &badPower = batteryData.powerNoGoodStates;
+ for (unsigned int i=0; i<badPower.size(); i++)
+ {
+ if (badPower[i]==true)
+ {
+ haveWarning = true;
+ stringstream ssWarnShort;
+ ssWarnShort << "BAT(" << i+1 << "): BAD POWER! ";
+ warnShort.push_back(ssWarnShort.str());
+ stringstream ssWarnVerbose;
+ ssWarnVerbose << "Power-no-good flag of battery number " << i+1 << " is set!" << endl;
+ warnVerbose.push_back(ssWarnVerbose.str());
+ }
+ }
+
+ const vector<bool> &chargeInhibit = batteryData.chargeInhibitedStates;
+ for (unsigned int i=0; i<chargeInhibit.size(); i++)
+ {
+ if (chargeInhibit[i]==true)
+ {
+ haveWarning = true;
+ stringstream ssWarnShort;
+ ssWarnShort << "BAT(" << i+1 << "): CHARGE INHIBITED! ";
+ warnShort.push_back(ssWarnShort.str());
+ stringstream ssWarnVerbose;
+ ssWarnVerbose << "Charge-inhibited flag of battery number " << i+1 << " is set!" << endl;
+ warnVerbose.push_back(ssWarnVerbose.str());
+ }
+ }
+
+ return haveWarning;
+}
+
+bool conductAllHealthChecks( const OceanServerSystem &batteryData,
+ const BatteryHealthWarningConfig &batteryConfig,
+ std::vector<std::string> &warnShort,
+ std::vector<std::string> &warnVerbose,
+ bool printRawRecord )
+{
+ if ( !haveBattery( batteryData, warnShort, warnVerbose ) ) return true;
+
+ bool warnNumBatteries = checkNumberOfBatteries( batteryData, warnShort, warnVerbose, batteryConfig.expectedNumBatteries );
+ bool warnModule = checkModuleHealth( batteryData, warnShort, warnVerbose );
+ bool warnCycle = checkNumCycles( batteryData, warnShort, warnVerbose, batteryConfig.numCyclesThreshhold, false );
+ bool warnTemp = checkTemperatures( batteryData, warnShort, warnVerbose, batteryConfig.chargeTempThreshhold, batteryConfig.dischargeTempThreshhold, false );
+ bool warnCharge = checkCharges( batteryData, warnShort, warnVerbose, batteryConfig.chargeWarnThreshhold, batteryConfig.chargeDeviationThreshold );
+
+ bool haveWarnings = warnNumBatteries || warnModule || warnCycle || warnTemp || warnCharge;
+
+ if (printRawRecord && haveWarnings )
+ {
+ stringstream ssWarnVerbose;
+ ssWarnVerbose << "Latest raw record: " << endl << toString(batteryData.rawRecord) << endl;
+ warnVerbose.push_back(ssWarnVerbose.str());
+ }
+
+ return haveWarnings;
+}
+
+
+
+}
+
Added: gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverhealthchecks.h
===================================================================
--- gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverhealthchecks.h (rev 0)
+++ gearbox/trunk/src/gbxsmartbatteryacfr/oceanserverhealthchecks.h 2009-05-01 21:23:59 UTC (rev 397)
@@ -0,0 +1,92 @@
+/*
+ * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
+ * http://gearbox.sf.net/
+ * Copyright (c) 2004-2009 Tobias Kaupp
+ *
+ * This distribution is licensed to you under the terms described in
+ * the LICENSE file included in this distribution.
+ *
+ */
+
+#ifndef GBX_OCEANSERVER_HEALTH_CHECKS
+#define GBX_OCEANSERVER_HEALTH_CHECKS
+
+#include <gbxsmartbatteryacfr/oceanserversystem.h>
+
+namespace gbxsmartbatteryacfr
+{
+
+//! Issues a short and verbose warning if the number of recharge cycles of one or more batteries are exceeded
+//! Optionally includes the raw battery record in warnVerbose
+//! Returns true if there was a warning otherwise false
+bool checkNumCycles( const OceanServerSystem &batteryData,
+ std::vector<std::string> &warnShort,
+ std::vector<std::string> &warnVerbose,
+ int numCyclesThreshhold,
+ bool printRawRecord = false );
+
+//! Issues a short and verbose warning if the temperature threshholds are of one or more batteries are exceeded
+//! Optionally includes the raw battery record in warnVerbose
+//! Returns true if there was a warning otherwise false
+bool checkTemperatures(const OceanServerSystem &batteryData,
+ std::vector<std::string> &warnShort,
+ std::vector<std::string> &warnVerbose,
+ double chargeTempThreshhold,
+ double dischargeTempThreshhold,
+ bool printRawRecord = false );
+
+//! Issues a short and verbose warning if the charge of one or more batteries is below the threshold or if the charge of any battery deviates by chargeDeviationThreshold percent from the average of all batteries
+//! Returns true if there was a warning otherwise false
+bool checkCharges(const OceanServerSystem &batteryData,
+ std::vector<std::string> &warnShort,
+ std::vector<std::string> &warnVerbose,
+ int chargeWarnThreshhold,
+ int chargeDeviationThreshold );
+
+//! Issues a short and verbose warning if any of the individual modules have "bad power" or are "charge-inhibited"
+//! Returns true if there was a warning otherwise false
+bool checkModuleHealth( const OceanServerSystem &batteryData,
+ std::vector<std::string> &warnShort,
+ std::vector<std::string> &warnVerbose );
+
+//! Issues a short and verbose warning if the number of expected batteries are not installed
+//! Returns true if there was a warning otherwise false
+bool checkNumberOfBatteries( const OceanServerSystem &batteryData,
+ std::vector<std::string> &warnShort,
+ std::vector<std::string> &warnVerbose,
+ int expectedNumBatteries );
+
+//! Config structure for battery health checks
+//! The threshholds represent acceptable values before warnings are issued
+struct BatteryHealthWarningConfig
+{
+ //! Expected number of battery modules installed
+ int expectedNumBatteries;
+ //! Maximum number of battery recharge cycles before a warning is issued
+ int numCyclesThreshhold;
+ //! Maximum charging temperature before a warning is issued
+ double chargeTempThreshhold;
+ //! Maximum discharging temperature before a warning is issued
+ double dischargeTempThreshhold;
+ //! Minimum charge in percent before a warning is issued
+ int chargeWarnThreshhold;
+ //! Minimum deviation of a single battery from the average of all batteries before a warning is issued (in percent)
+ int chargeDeviationThreshold;
+};
+
+//! Conducts all of the health checks above given a battery health configuration
+//! Adds up short and verbose warning messages
+//! Optionally includes the raw battery record at the end of warnVerbose if any check generated a warning
+//! Returns true if there were warnings otherwise false
+bool conductAllHealthChecks( const OceanServerSystem &batteryData,
+ const BatteryHealthWarningConfig &batteryCheckConfig,
+ std::vector<std::string> &warnShort,
+ std::vector<std::string> &warnVerbose,
+ bool printRawRecord = false );
+
+
+
+
+} // namespace
+
+#endif
Added: gearbox/trunk/src/gbxutilacfr/stoppable.h
===================================================================
--- gearbox/trunk/src/gbxutilacfr/stoppable.h (rev 0)
+++ gearbox/trunk/src/gbxutilacfr/stoppable.h 2009-05-01 21:23:59 UTC (rev 397)
@@ -0,0 +1,58 @@
+/*
+ * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
+ * http://gearbox.sf.net/
+ * Copyright (c) 2004-2008 Alex Brooks, Alexei Makarenko, Tobias Kaupp
+ *
+ * This distribution is licensed to you under the terms described in
+ * the LICENSE file included in this distribution.
+ *
+ */
+
+#ifndef GBXUTILACFR_STOPPABLE_H
+#define GBXUTILACFR_STOPPABLE_H
+
+namespace gbxutilacfr {
+
+/*!
+@brief An abstract interface class representing an stoppable activity.
+
+Inherit from this and other classes will know how to ask if your class was stopped (interrupted).
+
+@verbatim
+function doBigJob( gbxutilacfr::Stoppable* parent )
+{
+ // check periodically that the parent activity is not stopping
+ while( !parent->isStopping() )
+ {
+ // perform many steps
+ }
+}
+
+class MyActivity : public gbxutilacfr::Stoppable
+{
+public:
+ virtual bool isStopping()
+ {
+ // return TRUE if we are interrupted
+ };
+
+ void run()
+ {
+ doBigJob( this );
+ };
+};
+@endverbatim
+
+@author Alex Makarenko
+*/
+class Stoppable
+{
+public:
+ virtual ~Stoppable() {};
+
+ virtual bool isStopping()=0;
+};
+
+} // namespace
+
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|