INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         
smartbattery.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_SMARTBATTERY_H
12 #define GBX_SMARTBATTERY_H
13 
14 #include <stdint.h>
15 
16 #include <vector>
17 #include <string>
18 #include <assert.h>
19 
20 namespace gbxsmartbatteryacfr {
21 
25 {
26  ManufacturerAccess = 0,
27  RemainingCapacityAlarm,
28  RemainingTimeAlarm,
29  BatteryMode,
30  AtRate,
31  AtRateTimeToFull,
32  AtRateTimeToEmpty,
33  AtRateOk,
34  Temperature,
35  Voltage,
36  Current,
37  AverageCurrent,
38  MaxError,
39  RelativeStateOfCharge,
40  AbsoluteStateOfCharge,
41  RemainingCapacity,
42  FullChargeCapacity,
43  RunTimeToEmpty,
44  AverageTimeToEmpty,
45  AverageTimeToFull,
46  ChargingCurrent,
47  ChargingVoltage,
48  BatteryStatus,
49  CycleCount,
50  DesignCapacity,
51  DesignVoltage,
52  SpecificationInfo,
53  ManufactureDate,
54  SerialNumber,
55  ManufacturerName,
56  DeviceName,
57  DeviceChemistry,
58  ManufacturerData,
59  NUM_SMARTBATTERY_FIELDS
60 };
61 
64 SmartBatteryDataField keyToSmartField( const std::string &key );
65 
70 {
71  public:
72  SmartBattery() : has_(NUM_SMARTBATTERY_FIELDS)
73  { std::fill( has_.begin(), has_.end(), false ); };
74 
75  bool has( SmartBatteryDataField field ) const;
76 
77  uint16_t manufacturerAccess() const { assert(has_[ManufacturerAccess]); return manufacturerAccess_; };
78  void setManufacturerAccess( uint16_t manufacturerAccess ) { has_[ManufacturerAccess] = true; manufacturerAccess_ = manufacturerAccess; };
79 
80  int remainingCapacityAlarm() const { assert(has_[RemainingCapacityAlarm]); return remainingCapacityAlarm_; };
81  void setRemainingCapacityAlarm( int remainingCapacityAlarm ) { has_[RemainingCapacityAlarm] = true; remainingCapacityAlarm_ = remainingCapacityAlarm; };
82 
83  int remainingTimeAlarm() const { assert(has_[RemainingTimeAlarm]); return remainingTimeAlarm_; };
84  void setRemainingTimeAlarm( int remainingTimeAlarm ) { has_[RemainingTimeAlarm] = true; remainingTimeAlarm_ = remainingTimeAlarm; };
85 
86  uint16_t batteryMode() const { assert(has_[BatteryMode]); return batteryMode_; };
87  void setBatteryMode( uint16_t batteryMode ) { has_[BatteryMode] = true; batteryMode_ = batteryMode; };
88 
89  int atRate() const { assert(has_[AtRate]); return atRate_; };
90  void setAtRate( int atRate ) { has_[AtRate] = true; atRate_ = atRate; };
91 
92  int atRateTimeToFull() const { assert(has_[AtRateTimeToFull]); return atRateTimeToFull_; };
93  void setAtRateTimeToFull( int atRateTimeToFull ) { has_[AtRateTimeToFull] = true; atRateTimeToFull_ = atRateTimeToFull; };
94 
95  int atRateTimeToEmpty() const { assert(has_[AtRateTimeToEmpty]); return atRateTimeToEmpty_; };
96  void setAtRateTimeToEmpty( int atRateTimeToEmpty ) { has_[AtRateTimeToEmpty] = true; atRateTimeToEmpty_ = atRateTimeToEmpty; };
97 
98  bool atRateOk() const { assert(has_[AtRateOk]); return atRateOk_; };
99  void setAtRateOk( bool atRateOk ) { has_[AtRateOk] = true; atRateOk_ = atRateOk; };
100 
101  double temperature() const { assert(has_[Temperature]); return temperature_; };
102  void setTemperature( double temperature ) { has_[Temperature] = true; temperature_ = temperature; };
103 
104  double voltage() const { assert(has_[Voltage]); return voltage_; };
105  void setVoltage( double voltage ) { has_[Voltage] = true; voltage_ = voltage; };
106 
107  double current() const { assert(has_[Current]); return current_; };
108  void setCurrent( double current ) { has_[Current] = true; current_ = current; };
109 
110  double averageCurrent() const { assert(has_[AverageCurrent]); return averageCurrent_; };
111  void setAverageCurrent( double averageCurrent ) { has_[AverageCurrent] = true; averageCurrent_ = averageCurrent; };
112 
113  int maxError() const { assert(has_[MaxError]); return maxError_; };
114  void setMaxError( int maxError ) { has_[MaxError] = true; maxError_ = maxError; };
115 
116  int relativeStateOfCharge() const { assert(has_[RelativeStateOfCharge]); return relativeStateOfCharge_; };
117  void setRelativeStateOfCharge( int relativeStateOfCharge ) { has_[RelativeStateOfCharge] = true; relativeStateOfCharge_ = relativeStateOfCharge; };
118 
119  int absoluteStateOfCharge() const { assert(has_[AbsoluteStateOfCharge]); return absoluteStateOfCharge_; };
120  void setAbsoluteStateOfCharge( int absoluteStateOfCharge ) { has_[AbsoluteStateOfCharge] = true; absoluteStateOfCharge_ = absoluteStateOfCharge; };
121 
122  int remainingCapacity() const { assert(has_[RemainingCapacity]); return remainingCapacity_; };
123  void setRemainingCapacity( int remainingCapacity ) { has_[RemainingCapacity] = true; remainingCapacity_ = remainingCapacity; };
124 
125  int fullChargeCapacity() const { assert(has_[FullChargeCapacity]); return fullChargeCapacity_; };
126  void setFullChargeCapacity( int fullChargeCapacity ) { has_[FullChargeCapacity] = true; fullChargeCapacity_ = fullChargeCapacity; };
127 
128  int runTimeToEmpty() const { assert(has_[RunTimeToEmpty]); return runTimeToEmpty_; };
129  void setRunTimeToEmpty( int runTimeToEmpty ) { has_[RunTimeToEmpty] = true; runTimeToEmpty_ = runTimeToEmpty; };
130 
131  int averageTimeToEmpty() const { assert(has_[AverageTimeToEmpty]); return averageTimeToEmpty_; };
132  void setAverageTimeToEmpty( int averageTimeToEmpty ) { has_[AverageTimeToEmpty] = true; averageTimeToEmpty_ = averageTimeToEmpty; };
133 
134  int averageTimeToFull() const { assert(has_[AverageTimeToFull]); return averageTimeToFull_; };
135  void setAverageTimeToFull( int averageTimeToFull ) { has_[AverageTimeToFull] = true; averageTimeToFull_ = averageTimeToFull; };
136 
137  double chargingCurrent() const { assert(has_[ChargingCurrent]); return chargingCurrent_; };
138  void setChargingCurrent( double chargingCurrent ) { has_[ChargingCurrent] = true; chargingCurrent_ = chargingCurrent; };
139 
140  double chargingVoltage() const { assert(has_[ChargingVoltage]); return chargingVoltage_; };
141  void setChargingVoltage( double chargingVoltage ) { has_[ChargingVoltage] = true; chargingVoltage_ = chargingVoltage; };
142 
143  uint16_t batteryStatus() const { assert(has_[BatteryStatus]); return batteryStatus_; };
144  void setBatteryStatus( uint16_t batteryStatus ) { has_[BatteryStatus] = true; batteryStatus_ = batteryStatus; };
145 
146  int cycleCount() const { assert(has_[CycleCount]); return cycleCount_; };
147  void setCycleCount( int cycleCount ) { has_[CycleCount] = true; cycleCount_ = cycleCount; };
148 
149  int designCapacity() const { assert(has_[DesignCapacity]); return designCapacity_; };
150  void setDesignCapacity( int designCapacity ) { has_[DesignCapacity] = true; designCapacity_ = designCapacity; };
151 
152  double designVoltage() const { assert(has_[DesignVoltage]); return designVoltage_; };
153  void setDesignVoltage( double designVoltage ) { has_[DesignVoltage] = true; designVoltage_ = designVoltage; };
154 
155  uint16_t specificationInfo() const { assert(has_[SpecificationInfo]); return specificationInfo_; };
156  void setSpecificationInfo( uint16_t specificationInfo ) { has_[SpecificationInfo] = true; specificationInfo_ = specificationInfo; };
157 
158  uint16_t manufactureDate() const { assert(has_[ManufactureDate]); return manufactureDate_; };
159  void setManufactureDate ( uint16_t manufactureDate ) { has_[ManufactureDate] = true; manufactureDate_ = manufactureDate; };
160 
161  int serialNumber() const { assert(has_[SerialNumber]); return serialNumber_; };
162  void setSerialNumber( int serialNumber ) { has_[SerialNumber] = true; serialNumber_ = serialNumber; };
163 
164  const std::string manufacturerName() const { assert(has_[ManufacturerName]); return manufacturerName_; };
165  void setManufacturerName( std::string manufacturerName ) { has_[ManufacturerName] = true; manufacturerName_ = manufacturerName; };
166 
167  const std::string deviceName() const { assert(has_[DeviceName]); return deviceName_; };
168  void setDeviceName( std::string deviceName ) { has_[DeviceName] = true; deviceName_ = deviceName; };
169 
170  const std::string deviceChemistry() const { assert(has_[DeviceChemistry]); return deviceChemistry_; };
171  void setDeviceChemistry( std::string deviceChemistry ) { has_[DeviceChemistry] = true; deviceChemistry_ = deviceChemistry; };
172 
173  uint16_t manufacturerData() const { assert(has_[ManufacturerData]); return manufacturerData_; };
174  void setManufacturerData( uint16_t manufacturerData ) { has_[ManufacturerData] = true; manufacturerData_ = manufacturerData; };
175 
176  private:
177 
178  std::vector<bool> has_;
179 
180  uint16_t manufacturerAccess_; // manufacturer specific
181  int remainingCapacityAlarm_; // mAh or 10 mWh
182  int remainingTimeAlarm_; // min
183  uint16_t batteryMode_; // flags, see specs
184  int atRate_; // mA or 10 mW
185  int atRateTimeToFull_; // min
186  int atRateTimeToEmpty_; // min
187  bool atRateOk_; // bool
188  double temperature_; // Celsius
189  double voltage_; // V
190  double current_; // A
191  double averageCurrent_; // A
192  int maxError_; // percent
193  int relativeStateOfCharge_; // percent
194  int absoluteStateOfCharge_; // percent
195  int remainingCapacity_; // mAh or 10 mWh
196  int fullChargeCapacity_; // mAh or 10 mWh
197  int runTimeToEmpty_; // min
198  int averageTimeToEmpty_; // min
199  int averageTimeToFull_; // min
200  double chargingCurrent_; // A
201  double chargingVoltage_; // V
202  uint16_t batteryStatus_; // flags, see specs
203  int cycleCount_; // count
204  int designCapacity_; // mAh or 10 mWh
205  double designVoltage_; // V
206  uint16_t specificationInfo_; // flags, see specs
207  uint16_t manufactureDate_; // raw, see specs
208  int serialNumber_; // number
209  std::string manufacturerName_;
210  std::string deviceName_;
211  std::string deviceChemistry_;
212  uint16_t manufacturerData_; // manufacturer specific
213 
214 
215 };
216 
218 std::string toString( const SmartBattery &b );
219 
221 std::string toLogString( const SmartBattery &b );
222 
223 }
224 
225 #endif
226 
SmartBatteryDataField
Definition: smartbattery.h:24
string toLogString(const OceanServerSystem &system)
Puts OceanServerSystem data into a machine-readable ASCII string.
Definition: oceanserversystem.cpp:75
Definition: smartbattery.h:69
SmartBattery library.
Definition: gbxsmartbatteryacfr/exceptions.h:16
string toString(const OceanServerSystem &system)
Puts OceanServerSystem data into a human-readable string.
Definition: oceanserversystem.cpp:53
 

Generated for GearBox by  doxygen 1.4.5