INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         
oceanserversystem.h
1 /*
2  * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
3  * http://gearbox.sf.net/
4  * Copyright (c) 2004-2010 Tobias Kaupp
5  *
6  * This distribution is licensed to you under the terms described in
7  * the LICENSE file included in this distribution.
8  *
9  */
10 
11 #ifndef GBX_OCEANSERVER_SYSTEM_H
12 #define GBX_OCEANSERVER_SYSTEM_H
13 
14 #include <map>
15 #include <gbxsmartbatteryacfr/smartbattery.h>
16 
17 namespace gbxsmartbatteryacfr
18 {
19 
27 {
28  public:
29 
32 
34  bool isEmpty() const { return isEmpty_; };
35 
37  const std::map<int,SmartBattery>& batteries() const;
38 
40  SmartBattery& battery( unsigned int batteryNumber );
41 
43  const SmartBattery& battery( unsigned int batteryNumber ) const;
44 
46  void eraseBattery( unsigned int batteryNumber );
47 
49  void setPercentCharge(int percentCharge) { isEmpty_=false; percentCharge_ = percentCharge; };
51  int percentCharge() const { return percentCharge_; };
53  void setMinToEmpty(int minToEmpty) { isEmpty_=false; minToEmpty_ = minToEmpty; };
55  int minToEmpty() const { return minToEmpty_; };
57  void setMessageToSystem(const std::string &messageToSystem) { isEmpty_=false; messageToSystem_ = messageToSystem; };
59  std::string messageToSystem() const { return messageToSystem_; };
60 
62  const std::vector<bool> &availableBatteries() const { return availableBatteries_; };
64  std::vector<bool> &availableBatteries() { isEmpty_=false; return availableBatteries_; };
66  const std::vector<bool> &chargingStates() const { return chargingStates_; };
68  std::vector<bool> &chargingStates() { isEmpty_=false; return chargingStates_; };
70  const std::vector<bool> &supplyingPowerStates() const { return supplyingPowerStates_; };
72  std::vector<bool> &supplyingPowerStates() { isEmpty_=false; return supplyingPowerStates_; };
74  const std::vector<bool> &chargePowerPresentStates() const { return chargePowerPresentStates_; };
76  std::vector<bool> &chargePowerPresentStates() { isEmpty_=false; return chargePowerPresentStates_; };
78  const std::vector<bool> &powerNoGoodStates() const { return powerNoGoodStates_; };
80  std::vector<bool> &powerNoGoodStates() { isEmpty_=false; return powerNoGoodStates_; };
82  const std::vector<bool> &chargeInhibitedStates() const { return chargeInhibitedStates_; }
84  std::vector<bool> &chargeInhibitedStates() { isEmpty_=false; return chargeInhibitedStates_; }
85 
87  const std::vector<std::string> &rawRecord() const { return rawRecord_; };
89  std::vector<std::string> &rawRecord() { isEmpty_=false; return rawRecord_; };
90 
91  private:
92 
93  bool isEmpty_;
94 
95  // Average battery values
96  int percentCharge_;
97  int minToEmpty_;
98  std::string messageToSystem_;
99 
100  // Battery module states. Each vector is always of size 8 because OceanServer's Battery
101  // Management Modules have a maximum of 8 slots (either 2, 4, or 8 dependent on the model)
102  std::vector<bool> availableBatteries_;
103  std::vector<bool> chargingStates_;
104  std::vector<bool> supplyingPowerStates_;
105  std::vector<bool> chargePowerPresentStates_;
106  std::vector<bool> powerNoGoodStates_;
107  std::vector<bool> chargeInhibitedStates_;
108 
109  // the latest raw record, useful for debugging
110  std::vector<std::string> rawRecord_;
111 
112  // key: slot number, data: a single smart battery module
113  std::map<int,SmartBattery> batteries_;
114 };
115 
117 std::string toString( const OceanServerSystem &system );
118 
120 std::string toLogString( const OceanServerSystem &system );
121 
127 void updateWithNewData( const OceanServerSystem &from,
128  OceanServerSystem &to );
129 
131 bool isChargePowerPresent( const OceanServerSystem &batterySystem );
132 
133 } // namespace
134 
135 #endif
std::vector< bool > & supplyingPowerStates()
Set supplyingPowerStates flags.
Definition: oceanserversystem.h:72
std::vector< bool > & powerNoGoodStates()
Set powerNoGoodStates flags.
Definition: oceanserversystem.h:80
std::vector< bool > & chargePowerPresentStates()
Set chargePowerPresentStates flags.
Definition: oceanserversystem.h:76
const std::vector< bool > & chargePowerPresentStates() const
Access chargePowerPresentStates flags.
Definition: oceanserversystem.h:74
void setPercentCharge(int percentCharge)
Set charge in %.
Definition: oceanserversystem.h:49
const std::vector< bool > & chargeInhibitedStates() const
Access chargeInhibitedStates flags.
Definition: oceanserversystem.h:82
const std::vector< bool > & chargingStates() const
Access chargingStates flags.
Definition: oceanserversystem.h:66
string toLogString(const OceanServerSystem &system)
Puts OceanServerSystem data into a machine-readable ASCII string.
Definition: oceanserversystem.cpp:75
const std::vector< std::string > & rawRecord() const
Access the latest raw record, useful for debugging.
Definition: oceanserversystem.h:87
void setMinToEmpty(int minToEmpty)
Set minutes to empty.
Definition: oceanserversystem.h:53
std::vector< std::string > & rawRecord()
Set the latest raw record.
Definition: oceanserversystem.h:89
const std::vector< bool > & availableBatteries() const
Access availableBatteries flags.
Definition: oceanserversystem.h:62
SmartBattery & battery(unsigned int batteryNumber)
Easy write access to single battery, instantiates a new one if it doesn&#39;t exist.
Definition: oceanserversystem.cpp:221
bool isEmpty() const
Returns true if no valid data has been set.
Definition: oceanserversystem.h:34
std::vector< bool > & chargingStates()
Set chargingStates flags.
Definition: oceanserversystem.h:68
const std::vector< bool > & powerNoGoodStates() const
Access powerNoGoodStates flags.
Definition: oceanserversystem.h:78
std::vector< bool > & availableBatteries()
Set availableBatteries flags.
Definition: oceanserversystem.h:64
Definition: smartbattery.h:69
SmartBattery library.
Definition: gbxsmartbatteryacfr/exceptions.h:16
void updateWithNewData(const OceanServerSystem &from, OceanServerSystem &to)
Definition: oceanserversystem.cpp:98
const std::vector< bool > & supplyingPowerStates() const
Access supplyingPowerStates flags.
Definition: oceanserversystem.h:70
Definition: oceanserversystem.h:26
void setMessageToSystem(const std::string &messageToSystem)
Set message-to-system string.
Definition: oceanserversystem.h:57
int minToEmpty() const
Access minutes-to-empty.
Definition: oceanserversystem.h:55
std::vector< bool > & chargeInhibitedStates()
Set chargeInhibitedStates flags.
Definition: oceanserversystem.h:84
bool isChargePowerPresent(const gbxsmartbatteryacfr::OceanServerSystem &batterySystem)
Returns true if the charge power is present for at least one of the battery modules, otherwise false.
Definition: oceanserversystem.cpp:181
OceanServerSystem()
Initialises all data in OceanServerSystem class.
Definition: oceanserversystem.cpp:196
string toString(const OceanServerSystem &system)
Puts OceanServerSystem data into a human-readable string.
Definition: oceanserversystem.cpp:53
std::string messageToSystem() const
Access message-to-system string.
Definition: oceanserversystem.h:59
void eraseBattery(unsigned int batteryNumber)
Erase a battery.
Definition: oceanserversystem.cpp:252
const std::map< int, SmartBattery > & batteries() const
Read access to all batteries.
Definition: oceanserversystem.cpp:214
int percentCharge() const
Access charget in %.
Definition: oceanserversystem.h:51
 

Generated for GearBox by  doxygen 1.4.5