Public Member Functions | Static Public Member Functions | Protected Member Functions

ns3::EnergySource Class Reference

Energy source base class. More...

#include <energy-source.h>

Inheritance diagram for ns3::EnergySource:
Inheritance graph
[legend]
Collaboration diagram for ns3::EnergySource:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual double GetSupplyVoltage (void) const =0
virtual double GetInitialEnergy (void) const =0
virtual double GetRemainingEnergy (void)=0
virtual double GetEnergyFraction (void)=0
virtual void DecreaseRemainingEnergy (double energyJ)=0
virtual void IncreaseRemainingEnergy (double energyJ)=0
virtual void UpdateEnergySource (void)=0
void SetNode (Ptr< Node > node)
 Sets pointer to node containing this EnergySource.
Ptr< NodeGetNode (void) const
void AppendDeviceEnergyModel (Ptr< DeviceEnergyModel > deviceEnergyModelPtr)
DeviceEnergyModelContainer FindDeviceEnergyModels (TypeId tid)
DeviceEnergyModelContainer FindDeviceEnergyModels (std::string name)

Static Public Member Functions

static TypeId GetTypeId (void)
 This method returns the TypeId associated to ns3::EnergySource.

Protected Member Functions

double CalculateTotalCurrent (void)
void NotifyEnergyDrained (void)
void BreakDeviceEnergyModelRefCycle (void)

Detailed Description

Energy source base class.

This is the base class for energy sources. Energy sources keep track of remaining energy. Device energy models will be updating the remaining energy in the energy source. The energy source itself does not update the remaining energy. Energy source also keeps a list of device energy models installed on the same node. When the remaining energy level reaches 0, the energy source will notify all device energy models stored in the list.

EnergySource provides 2 types of interfaces for DeviceEnergyModels to update the remaining energy stored in EnergySource: -Direct energy update interface (Joules): DecreaseRemainingEnergy IncreaseRemainingEnergy -Indirect energy update interface (Current): UpdateEnergySource Direct energy update interface will decrease/increase energy from the source directly (in Joules). Direct energy update interface is typically used by simple DeviceEnergyModel which knows only average power consumption for each of its state. Indirect energy update interface uses the total current cumulated from all DeviceEnergyModel to calculate energy to decrease from the source. Indirect energy update interface is typically used by DeviceEnergyModel who knows its current draw for each of its states. Nonlinear EnergySource also uses this interface.

Unit of energy is chosen as Joules since energy models typically calculate energy as (time in seconds * power in Watts). If the energy source stores energy in different units (eg. kWh), a simple converter function should suffice.


Member Function Documentation

void ns3::EnergySource::AppendDeviceEnergyModel ( Ptr< DeviceEnergyModel deviceEnergyModelPtr  ) 
Parameters:
deviceEnergyModelPtr Pointer to device energy model.

This function appends a device energy model to the end of a list of DeviceEnergyModelInfo structs.

void ns3::EnergySource::BreakDeviceEnergyModelRefCycle ( void   )  [protected]

This function is called to break reference cycle between EnergySource and DeviceEnergyModel. Child of the EnergySource base class must call this function in their implementation of DoDispose to make sure the reference cycle is broken.

Normally this work will be completed by the DoDispose function. However it will be overridden in the child class. Hence we introduced this function.

double ns3::EnergySource::CalculateTotalCurrent ( void   )  [protected]
Returns:
Total current draw from all DeviceEnergyModels.
virtual void ns3::EnergySource::DecreaseRemainingEnergy ( double  energyJ  )  [pure virtual]
Parameters:
energyJ Amount of energy to decrease (in Joules)

This function decreases the remaining energy in the energy source by the specified amount. Provides linear interface for direct energy deduction.

Implemented in ns3::BasicEnergySource.

DeviceEnergyModelContainer ns3::EnergySource::FindDeviceEnergyModels ( std::string  name  ) 
Parameters:
name name of the DeviceEnergyModel we are searching for.
Returns:
List of pointers to DeviceEnergyModel objects installed on node.
DeviceEnergyModelContainer ns3::EnergySource::FindDeviceEnergyModels ( TypeId  tid  ) 
Parameters:
tid TypeId of the DeviceEnergyModel we are searching for.
Returns:
List of pointers to DeviceEnergyModel objects installed on node.
virtual double ns3::EnergySource::GetEnergyFraction ( void   )  [pure virtual]
Returns:
Energy fraction = remaining energy / initial energy [0, 1]

This function returns the percentage of energy left in the energy source.

Implemented in ns3::BasicEnergySource.

virtual double ns3::EnergySource::GetInitialEnergy ( void   )  const [pure virtual]
Returns:
Initial energy (capacity) of the energy source.

Set method is to be defined in child class only if necessary. For sources with a fixed initial energy (energy capacity), set method is not needed.

Implemented in ns3::BasicEnergySource.

Ptr<Node> ns3::EnergySource::GetNode ( void   )  const
Returns:
Pointer to node containing this EnergySource.

When a subclass needs to get access to the underlying node base class to print the nodeId for example, it can invoke this method.

virtual double ns3::EnergySource::GetRemainingEnergy ( void   )  [pure virtual]
Returns:
Remaining energy at the energy source.

Implemented in ns3::BasicEnergySource.

virtual double ns3::EnergySource::GetSupplyVoltage ( void   )  const [pure virtual]
Returns:
Supply voltage of the energy source.

Set method is to be defined in child class only if necessary. For sources with a fixed supply voltage, set method is not needed.

Implemented in ns3::BasicEnergySource.

static TypeId ns3::EnergySource::GetTypeId ( void   )  [static]

This method returns the TypeId associated to ns3::EnergySource.

This object is accessible through the following paths with Config::Set and Config::Connect:

  • /NodeList/[i]/DeviceList/[i]/$ns3::AlohaNoackNetDevice/Phy/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::BaseStationNetDevice/BsIpcsPacketClassifier/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::BaseStationNetDevice/LinkManager/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::BaseStationNetDevice/SSManager/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::BaseStationNetDevice/ServiceFlowManager/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::NonCommunicatingNetDevice/Phy/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::SubscriberStationNetDevice/Classifier/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::SubscriberStationNetDevice/LinkManager/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::SubscriberStationNetDevice/SSScheduler/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::UanNetDevice/Channel/NoiseModel/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::UanNetDevice/Channel/PropagationModel/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::UanNetDevice/Mac/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::UanNetDevice/Phy/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::UanNetDevice/Transducer/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/$ns3::BaseStationNetDevice/BsIpcsPacketClassifier/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/$ns3::BaseStationNetDevice/LinkManager/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/$ns3::BaseStationNetDevice/SSManager/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/$ns3::BaseStationNetDevice/ServiceFlowManager/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/$ns3::SubscriberStationNetDevice/Classifier/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/$ns3::SubscriberStationNetDevice/LinkManager/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/$ns3::SubscriberStationNetDevice/SSScheduler/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/BandwidthManager/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/BurstProfileManager/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/Channel/$ns3::UanChannel/NoiseModel/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/Channel/$ns3::UanChannel/PropagationModel/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/ConnectionManager/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/Phy/Channel/$ns3::UanChannel/NoiseModel/$ns3::EnergySource
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/Phy/Channel/$ns3::UanChannel/PropagationModel/$ns3::EnergySource

No Attributes defined for this type.
No TraceSources defined for this type.

Reimplemented from ns3::Object.

Reimplemented in ns3::BasicEnergySource.

virtual void ns3::EnergySource::IncreaseRemainingEnergy ( double  energyJ  )  [pure virtual]
Parameters:
energyJ Amount of energy to increase (in Joules)

This function increases the remaining energy in the energy source by the specified amount. Provides linear interface for direct energy increase.

Implemented in ns3::BasicEnergySource.

void ns3::EnergySource::NotifyEnergyDrained ( void   )  [protected]

This function notifies all DeviceEnergyModel of energy depletion event. It is called by the child EnergySource class when energy depletion happens.

void ns3::EnergySource::SetNode ( Ptr< Node node  ) 

Sets pointer to node containing this EnergySource.

Parameters:
node Pointer to node containing this EnergySource.
virtual void ns3::EnergySource::UpdateEnergySource ( void   )  [pure virtual]

This function goes through the list of DeviceEnergyModels to obtain total current draw at the energy source and updates remaining energy. Called by DeviceEnergyModels to inform EnergySource of a state change.

Implemented in ns3::BasicEnergySource.


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