Base class for any power source. More...
#include <BaseBattery.h>
Inherits BaseModule.
Inherited by SimpleBattery.
Public Member Functions | |
virtual int | registerDevice (const std::string &name, int numAccounts)=0 |
Registers a power draining device with this battery. | |
virtual void | draw (int drainID, DrawAmount &amount, int account)=0 |
Draws power from the battery. | |
State-of-charge interface | |
Other host modules should use these interfaces to obtain the state-of-charge of the battery. Do NOT use BatteryState interfaces, which should be used only by Battery Stats modules. | |
virtual double | getVoltage ()=0 |
get voltage (future support for non-voltage regulated h/w | |
virtual double | estimateResidualRelative ()=0 |
current state of charge of the battery, relative to its rated nominal capacity [0..1] | |
virtual double | estimateResidualAbs ()=0 |
current state of charge of the battery (mW-s) |
Base class for any power source.
See "SimpleBattery" for an example implementation.
Definition at line 64 of file BaseBattery.h.
virtual void BaseBattery::draw | ( | int | drainID, | |
DrawAmount & | amount, | |||
int | account | |||
) | [pure virtual] |
Draws power from the battery.
The actual amount and type of power drawn is defined by the passed DrawAmount parameter. Can be an fixed single amount or an amount drawn over time. The drainID identifies the device which drains the power. "Account" identifies the account the power is drawn from. It is used for statistical evaluation only to see which activity of a device has used how much power. It does not affect functionality.
Implemented in SimpleBattery.
Referenced by BatteryAccess::draw(), BatteryAccess::drawCurrent(), and BatteryAccess::drawEnergy().
virtual int BaseBattery::registerDevice | ( | const std::string & | name, | |
int | numAccounts | |||
) | [pure virtual] |
Registers a power draining device with this battery.
Takes the name of the device as well as a number of accounts the devices draws power for (like rx, tx, idle for a radio device).
Returns an ID by which the device can identify itself to the battery.
Has to be implemented by actual battery implementations.
Implemented in SimpleBattery.
Referenced by BatteryAccess::registerWithBattery().