Protected Member Functions | Protected Attributes

BatteryAccess Class Reference
[Power consumption - Classes using/defining power consumptionbaseModules - base module classes of MiXiM]

Extends BaseModule by several methods which provide access to the battery module. More...

#include <BatteryAccess.h>

Inherits BaseModule.

Inherited by BaseLayer, BaseMobility, and ChannelAccess.

Collaboration diagram for BatteryAccess:
Collaboration graph
[legend]

List of all members.

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

BaseBatterybattery
 Stores pointer to the battery module.
int deviceID
 This devices id for the battery module.

Detailed Description

Extends BaseModule by several methods which provide access to the battery module.

Author:
Karl Wessel

Definition at line 22 of file BatteryAccess.h.


Member Function Documentation

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().

                                                        {
  if(!battery)
    return;

  battery->draw(deviceID, amount, account);
}

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);
  }
}


The documentation for this class was generated from the following files: