INTRODUCTION Overview Download and Install Documentation Publications REPOSITORY Libraries DEVELOPER Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
oceanserversystem.h00001 /* 00002 * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics 00003 * http://gearbox.sf.net/ 00004 * Copyright (c) 2004-2010 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 GBX_OCEANSERVER_SYSTEM_H 00012 #define GBX_OCEANSERVER_SYSTEM_H 00013 00014 #include <map> 00015 #include <gbxsmartbatteryacfr/smartbattery.h> 00016 00017 namespace gbxsmartbatteryacfr 00018 { 00019 00026 class OceanServerSystem 00027 { 00028 public: 00029 00031 OceanServerSystem(); 00032 00034 bool isEmpty() const { return isEmpty_; }; 00035 00037 const std::map<int,SmartBattery>& batteries() const; 00038 00040 SmartBattery& battery( unsigned int batteryNumber ); 00041 00043 const SmartBattery& battery( unsigned int batteryNumber ) const; 00044 00046 void eraseBattery( unsigned int batteryNumber ); 00047 00049 void setPercentCharge(int percentCharge) { isEmpty_=false; percentCharge_ = percentCharge; }; 00051 int percentCharge() const { return percentCharge_; }; 00053 void setMinToEmpty(int minToEmpty) { isEmpty_=false; minToEmpty_ = minToEmpty; }; 00055 int minToEmpty() const { return minToEmpty_; }; 00057 void setMessageToSystem(const std::string &messageToSystem) { isEmpty_=false; messageToSystem_ = messageToSystem; }; 00059 std::string messageToSystem() const { return messageToSystem_; }; 00060 00062 const std::vector<bool> &availableBatteries() const { return availableBatteries_; }; 00064 std::vector<bool> &availableBatteries() { isEmpty_=false; return availableBatteries_; }; 00066 const std::vector<bool> &chargingStates() const { return chargingStates_; }; 00068 std::vector<bool> &chargingStates() { isEmpty_=false; return chargingStates_; }; 00070 const std::vector<bool> &supplyingPowerStates() const { return supplyingPowerStates_; }; 00072 std::vector<bool> &supplyingPowerStates() { isEmpty_=false; return supplyingPowerStates_; }; 00074 const std::vector<bool> &chargePowerPresentStates() const { return chargePowerPresentStates_; }; 00076 std::vector<bool> &chargePowerPresentStates() { isEmpty_=false; return chargePowerPresentStates_; }; 00078 const std::vector<bool> &powerNoGoodStates() const { return powerNoGoodStates_; }; 00080 std::vector<bool> &powerNoGoodStates() { isEmpty_=false; return powerNoGoodStates_; }; 00082 const std::vector<bool> &chargeInhibitedStates() const { return chargeInhibitedStates_; } 00084 std::vector<bool> &chargeInhibitedStates() { isEmpty_=false; return chargeInhibitedStates_; } 00085 00087 const std::vector<std::string> &rawRecord() const { return rawRecord_; }; 00089 std::vector<std::string> &rawRecord() { isEmpty_=false; return rawRecord_; }; 00090 00091 private: 00092 00093 bool isEmpty_; 00094 00095 // Average battery values 00096 int percentCharge_; 00097 int minToEmpty_; 00098 std::string messageToSystem_; 00099 00100 // Battery module states. Each vector is always of size 8 because OceanServer's Battery 00101 // Management Modules have a maximum of 8 slots (either 2, 4, or 8 dependent on the model) 00102 std::vector<bool> availableBatteries_; 00103 std::vector<bool> chargingStates_; 00104 std::vector<bool> supplyingPowerStates_; 00105 std::vector<bool> chargePowerPresentStates_; 00106 std::vector<bool> powerNoGoodStates_; 00107 std::vector<bool> chargeInhibitedStates_; 00108 00109 // the latest raw record, useful for debugging 00110 std::vector<std::string> rawRecord_; 00111 00112 // key: slot number, data: a single smart battery module 00113 std::map<int,SmartBattery> batteries_; 00114 }; 00115 00117 std::string toString( const OceanServerSystem &system ); 00118 00120 std::string toLogString( const OceanServerSystem &system ); 00121 00127 void updateWithNewData( const OceanServerSystem &from, 00128 OceanServerSystem &to ); 00129 00131 bool isChargePowerPresent( const OceanServerSystem &batterySystem ); 00132 00133 } // namespace 00134 00135 #endif |