Extends BaseModule by several methods which provide access to the battery module. More...
#include <BatteryAccess.h>
Inherits BaseModule.
Inherited by BaseLayer, BaseMobility, and ChannelAccess.
Protected Member Functions | |
void | registerWithBattery (const std::string &name, int numAccounts) |
Registers this module as a device with the battery module. | |
void | draw (DrawAmount &amount, int account) |
Draws the amount defined by the passed DrawAmount from the battery on account of the passed account. | |
void | drawCurrent (double amount, int account) |
Draws the passed amount of current (in mA) over time from the battery on account of the passed account. | |
void | drawEnergy (double amount, int account) |
Draws the passed amount of energy (in mWs) from the battery on account of the passed account. | |
Protected Attributes | |
BaseBattery * | battery |
Stores pointer to the battery module. | |
int | deviceID |
This devices id for the battery module. |
Extends BaseModule by several methods which provide access to the battery module.
Definition at line 22 of file BatteryAccess.h.
void BatteryAccess::draw | ( | DrawAmount & | amount, | |
int | account | |||
) | [protected] |
Draws the amount defined by the passed DrawAmount from the battery on account of the passed account.
If no battery module is available than nothing happens.
Definition at line 25 of file BatteryAccess.cc.
References battery, deviceID, and BaseBattery::draw().
void BatteryAccess::drawCurrent | ( | double | amount, | |
int | account | |||
) | [protected] |
Draws the passed amount of current (in mA) over time from the battery on account of the passed account.
If no battery module is available than nothing happens.
Definition at line 32 of file BatteryAccess.cc.
References battery, deviceID, and BaseBattery::draw().
{ if(!battery) return; DrawAmount val(DrawAmount::CURRENT, amount); battery->draw(deviceID, val, account); }
void BatteryAccess::drawEnergy | ( | double | amount, | |
int | account | |||
) | [protected] |
Draws the passed amount of energy (in mWs) from the battery on account of the passed account.
If no battery module is available than nothing happens.
Definition at line 40 of file BatteryAccess.cc.
References battery, deviceID, BaseBattery::draw(), and DrawAmount::ENERGY.
{ if(!battery) return; DrawAmount val(DrawAmount::ENERGY, amount); battery->draw(deviceID, val, account); }
void BatteryAccess::registerWithBattery | ( | const std::string & | name, | |
int | numAccounts | |||
) | [protected] |
Registers this module as a device with the battery module.
If no battery module is available than nothing happens.
Definition at line 15 of file BatteryAccess.cc.
References battery, deviceID, BaseModule::findHost(), and BaseBattery::registerDevice().
Referenced by PhyLayerUWBIR::initialize(), and PhyLayerBattery::initialize().
{ battery = FindModule<BaseBattery*>::findSubModule(findHost()); if(!battery) { opp_warning("No battery module defined!"); } else { deviceID = battery->registerDevice(name, numAccounts); } }