libPlayingWithFusion 2026.3.05
Playing With Fusion driver library for FRC roboRIO
Loading...
Searching...
No Matches
BattFuelGauge.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include "wpi/sendable/Sendable.h"
5#include "wpi/sendable/SendableHelper.h"
6#include "wpi/sendable/SendableBuilder.h"
7#include "BattFuelGaugeApi.h"
8
9namespace pwf {
10class BattFuelGaugeImpl;
11
24class BattFuelGauge : public wpi::Sendable, public wpi::SendableHelper<BattFuelGauge> {
25
26public:
34 kInit = 0,
35
40
45
50
55
59 kIdle = 5,
60
65 };
66
67
80
81
82 explicit BattFuelGauge(uint8_t sensorID);
83 virtual ~BattFuelGauge();
84
85 // Delete Copy constructor and assignment operator
88
89 // Use default Move constructor and assignment operator
92
93 void InitSendable(wpi::SendableBuilder& builder) override;
94
100 void IdentifySensor();
101
107 uint32_t GetFirmwareVersion() const;
108
114 uint32_t GetSerialNumber() const;
115
120
130 void SaveLog(std::string filename = "");
131
132
133 // -------------------------------------------------------------------------
134 // Core real-time / state values
135 // -------------------------------------------------------------------------
136
142
147 float GetCurrent() const;
148
153 float GetVoltage() const;
154
159 float GetDodAh() const;
160
165 float GetDodWh() const;
166
171 float GetRemainingChargePct() const;
172
177 float GetEffectiveCapacityAh() const;
178
179 // -------------------------------------------------------------------------
180 // Battery age, capacity & cycle information
181 // -------------------------------------------------------------------------
182
187 float GetBatteryAgeDays() const;
188
193 float GetCapacityAh() const;
194
199 float GetRatedCapacityAh() const;
200
205 int GetNumCycles() const;
206
207 // -------------------------------------------------------------------------
208 // Identification
209 // -------------------------------------------------------------------------
210
215 std::string GetNickname() const;
216
221 BattMfg GetManufacturer() const;
222
223
228 void SetNickname(std::string newNickname) const;
229
234 void SetManufacturer(BattMfg newMfg) const;
235
236
237 // -------------------------------------------------------------------------
238 // Last full charge cycle statistics
239 // -------------------------------------------------------------------------
240
245 float GetCycleRmsDischargeCurrent() const;
246
251 float GetCycleMaxCurrent() const;
252
257 float GetCycleMinCurrent() const;
258
263 float GetCycleMinVoltage() const;
264
269 float GetCycleMaxVoltage() const;
270
275 float GetCycleMinDodAh() const;
276
281 float GetCycleMaxDodAh() const;
282
287 float GetCycleMinDodWh() const;
288
293 float GetCycleMaxDodWh() const;
294
299 float GetCycleChargeTime() const;
300
305 float GetCycleDischargeTime() const;
306
311 float GetCycleStartingVoltage() const;
312
313 // -------------------------------------------------------------------------
314 // Last robot match statistics
315 // -------------------------------------------------------------------------
316
321 float GetMatchRmsDischargeCurrent() const;
322
327 float GetMatchMaxCurrent() const;
328
333 float GetMatchMinCurrent() const;
334
339 float GetMatchMinVoltage() const;
340
345 float GetMatchMaxVoltage() const;
346
351 float GetMatchMinDodAh() const;
352
357 float GetMatchMaxDodAh() const;
358
363 float GetMatchChargeTime() const;
364
369 float GetMatchDischargeTime() const;
370
375 float GetMatchStartingVoltage() const;
376
381 float GetMatchStartingEnergy() const;
382
387 float GetMatchEndingEnergy() const;
388
393 float GetMatchStartingCharge() const;
394
399 float GetMatchEndingCharge() const;
400
405 float GetMatchDuration() const;
406
413 bool IsConnected() const;
414
415private:
416 BattFuelGauge_t *m_handle;
417};
418
419}
float GetVoltage() const
Get the current battery voltage.
Definition BattFuelGauge.cpp:71
uint32_t GetSerialNumber() const
Definition BattFuelGauge.cpp:50
float GetMatchStartingEnergy() const
Energy stored at the beginning of the last robot match.
Definition BattFuelGauge.cpp:228
float GetCycleMaxCurrent() const
Maximum charging current observed during the last charge cycle.
Definition BattFuelGauge.cpp:140
void SaveLog(std::string filename="")
Get the battery charge/discharge state.
Definition BattFuelGauge.cpp:55
float GetMatchChargeTime() const
Total charging time during the last robot match (if any).
Definition BattFuelGauge.cpp:216
float GetCycleMaxDodAh() const
Maximum depth of discharge reached during the last charge cycle.
Definition BattFuelGauge.cpp:160
float GetCycleChargeTime() const
Total time spent charging during the last charge cycle.
Definition BattFuelGauge.cpp:172
float GetCycleStartingVoltage() const
Starting voltage at the beginning of the last charge cycle.
Definition BattFuelGauge.cpp:180
BattFuelGauge(const BattFuelGauge &)=delete
float GetMatchMinVoltage() const
Minimum voltage observed during the last robot match.
Definition BattFuelGauge.cpp:200
float GetEffectiveCapacityAh() const
Get the effective (usable) capacity of the battery.
Definition BattFuelGauge.cpp:87
BattMfg GetManufacturer() const
Get the battery manufacturer identifier.
Definition BattFuelGauge.cpp:120
float GetCycleMaxVoltage() const
Maximum voltage observed during the last charge cycle.
Definition BattFuelGauge.cpp:152
float GetMatchMaxDodAh() const
Maximum depth of discharge reached during the last robot match.
Definition BattFuelGauge.cpp:212
float GetMatchMinCurrent() const
Minimum current (most negative discharge) during the last match.
Definition BattFuelGauge.cpp:196
float GetMatchMinDodAh() const
Minimum depth of discharge reached during the last robot match.
Definition BattFuelGauge.cpp:208
bool IsConnected() const
Definition BattFuelGauge.cpp:248
float GetBatteryAgeDays() const
Get the age of the battery.
Definition BattFuelGauge.cpp:95
float GetDodWh() const
Get the current depth of discharge energy.
Definition BattFuelGauge.cpp:79
float GetMatchMaxCurrent() const
Maximum current (any direction) during the last robot match.
Definition BattFuelGauge.cpp:192
BattFuelGauge(BattFuelGauge &&)=default
float GetMatchStartingVoltage() const
Battery voltage at the start of the last robot match.
Definition BattFuelGauge.cpp:224
float GetCycleMinDodAh() const
Minimum depth of discharge reached during the last charge cycle.
Definition BattFuelGauge.cpp:156
float GetMatchMaxVoltage() const
Maximum voltage observed during the last robot match.
Definition BattFuelGauge.cpp:204
float GetMatchStartingCharge() const
Charge stored at the beginning of the last robot match.
Definition BattFuelGauge.cpp:236
float GetCycleRmsDischargeCurrent() const
RMS discharge current during the last complete charge cycle.
Definition BattFuelGauge.cpp:136
float GetCurrent() const
Get the battery discharge current.
Definition BattFuelGauge.cpp:67
float GetMatchDuration() const
Duration of the last robot match.
Definition BattFuelGauge.cpp:244
float GetCapacityAh() const
Get the current (estimated) battery capacity.
Definition BattFuelGauge.cpp:99
BattFuelGauge & operator=(BattFuelGauge &&)=default
float GetCycleDischargeTime() const
Total time spent discharging during the last charge cycle.
Definition BattFuelGauge.cpp:176
float GetCycleMinDodWh() const
Minimum energy discharged during the last charge cycle.
Definition BattFuelGauge.cpp:164
uint32_t GetFirmwareVersion() const
Definition BattFuelGauge.cpp:46
float GetRemainingChargePct() const
Get the remaining charge as a percentage.
Definition BattFuelGauge.cpp:83
BattFuelGauge & operator=(const BattFuelGauge &)=delete
int GetNumCycles() const
Get the total number of charge/discharge cycles.
Definition BattFuelGauge.cpp:107
float GetCycleMinCurrent() const
Maximum discharge current observed during the last charge cycle.
Definition BattFuelGauge.cpp:144
ChargeState GetBatteryState() const
Get the battery charge/discharge state.
Definition BattFuelGauge.cpp:63
virtual ~BattFuelGauge()
Definition BattFuelGauge.cpp:21
float GetCycleMaxDodWh() const
Maximum energy discharged during the last charge cycle.
Definition BattFuelGauge.cpp:168
float GetMatchEndingEnergy() const
Energy remaining at the end of the last robot match.
Definition BattFuelGauge.cpp:232
float GetMatchRmsDischargeCurrent() const
RMS discharge current during the last robot match.
Definition BattFuelGauge.cpp:188
BattMfg
Definition BattFuelGauge.h:71
@ kDuracell
Definition BattFuelGauge.h:72
@ kPowerSonic
Definition BattFuelGauge.h:77
@ kMKPowered
Definition BattFuelGauge.h:76
@ kMightyMax
Definition BattFuelGauge.h:75
@ kInterstate
Definition BattFuelGauge.h:74
@ kEnergizer
Definition BattFuelGauge.h:73
@ kNumMfgs
Definition BattFuelGauge.h:78
void InitSendable(wpi::SendableBuilder &builder) override
Definition BattFuelGauge.cpp:28
void IdentifySensor()
Definition BattFuelGauge.cpp:42
void SetManufacturer(BattMfg newMfg) const
Set the battery manufacturer.
Definition BattFuelGauge.cpp:128
std::string GetNickname() const
Get the user-defined nickname of the battery.
Definition BattFuelGauge.cpp:115
float GetDodAh() const
Get the current depth of discharge in ampere-hours.
Definition BattFuelGauge.cpp:75
float GetMatchEndingCharge() const
Charge remaining at the end of the last robot match.
Definition BattFuelGauge.cpp:240
float GetRatedCapacityAh() const
Get the original rated capacity when the battery was new.
Definition BattFuelGauge.cpp:103
ChargeState
Definition BattFuelGauge.h:30
@ kConstVCharge
Definition BattFuelGauge.h:49
@ kDischarge
Definition BattFuelGauge.h:39
@ kTrickleCharge
Definition BattFuelGauge.h:54
@ kIdle
Definition BattFuelGauge.h:59
@ kConstICharge
Definition BattFuelGauge.h:44
@ kMeasureOCV
Definition BattFuelGauge.h:64
@ kInit
Definition BattFuelGauge.h:34
float GetMatchDischargeTime() const
Total discharging time during the last robot match.
Definition BattFuelGauge.cpp:220
BattFuelGauge(uint8_t sensorID)
Definition BattFuelGauge.cpp:14
float GetCycleMinVoltage() const
Minimum voltage observed during the last charge cycle.
Definition BattFuelGauge.cpp:148
void SetNickname(std::string newNickname) const
Set the user-defined nickname of the battery.
Definition BattFuelGauge.cpp:124
Definition BattFuelGauge.h:9