A Discrete-Event Network Simulator
API
ns3::EnergySource Class Referenceabstract

Introspection did not find any typical Config paths. More...

#include "energy-source.h"

+ Inheritance diagram for ns3::EnergySource:
+ Collaboration diagram for ns3::EnergySource:

Public Member Functions

 EnergySource ()
 
virtual ~EnergySource ()
 
void AppendDeviceEnergyModel (Ptr< DeviceEnergyModel > deviceEnergyModelPtr)
 
void ConnectEnergyHarvester (Ptr< EnergyHarvester > energyHarvesterPtr)
 
void DisposeDeviceModels (void)
 Calls Dispose () method of the device energy models. More...
 
DeviceEnergyModelContainer FindDeviceEnergyModels (TypeId tid)
 
DeviceEnergyModelContainer FindDeviceEnergyModels (std::string name)
 
virtual double GetEnergyFraction (void)=0
 
virtual double GetInitialEnergy (void) const =0
 
Ptr< NodeGetNode (void) const
 
virtual double GetRemainingEnergy (void)=0
 
virtual double GetSupplyVoltage (void) const =0
 
void InitializeDeviceModels (void)
 Calls Start () method of the device energy models. More...
 
void SetNode (Ptr< Node > node)
 Sets pointer to node containing this EnergySource. More...
 
virtual void UpdateEnergySource (void)=0
 This function goes through the list of DeviceEnergyModels to obtain total current draw at the energy source and updates remaining energy. More...
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together. More...
 
void Dispose (void)
 Dispose of this Object. More...
 
AggregateIterator GetAggregateIterator (void) const
 Get an iterator to the Objects aggregated to this one. More...
 
virtual TypeId GetInstanceTypeId (void) const
 Get the most derived TypeId for this Object. More...
 
template<typename T >
Ptr< T > GetObject (void) const
 Get a pointer to the requested aggregated Object. More...
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId. More...
 
void Initialize (void)
 Invoke DoInitialize on all Objects aggregated to this one. More...
 
bool IsInitialized (void) const
 Check if the object has been initialized. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful. More...
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising erros. More...
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful. More...
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors. More...
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context. More...
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context. More...
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context. More...
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context. More...
 

Static Public Member Functions

static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Protected Member Functions

void BreakDeviceEnergyModelRefCycle (void)
 This function is called to break reference cycle between EnergySource and DeviceEnergyModel. More...
 
double CalculateTotalCurrent (void)
 
void NotifyEnergyDrained (void)
 This function notifies all DeviceEnergyModel of energy depletion event. More...
 
void NotifyEnergyRecharged (void)
 This function notifies all DeviceEnergyModel of energy recharged event. More...
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object. More...
 
virtual void DoInitialize (void)
 Initialize() implementation. More...
 
virtual void NotifyNewAggregate (void)
 Notify all Objects aggregated to this one of a new Object being aggregated. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes. More...
 
virtual void NotifyConstructionCompleted (void)
 Notifier called once the ObjectBase is fully constructed. More...
 

Private Member Functions

virtual void DoDispose (void)
 All child's implementation must call BreakDeviceEnergyModelRefCycle to ensure reference cycles to DeviceEnergyModel objects are broken. More...
 

Private Attributes

std::vector< Ptr< EnergyHarvester > > m_harvesters
 Vector of EnergyHarvester pointer connected to the same energy source. More...
 
DeviceEnergyModelContainer m_models
 List of device energy models installed on the same node. More...
 
Ptr< Nodem_node
 Pointer to node containing this EnergySource. More...
 

Additional Inherited Members

Detailed Description

Introspection did not find any typical Config paths.


No Attributes are defined for this type.
No TraceSources are defined for this type.
Size of this type is 88 bytes (on a 64-bit architecture).

Definition at line 81 of file energy-source.h.

Constructor & Destructor Documentation

ns3::EnergySource::EnergySource ( )

Definition at line 45 of file energy-source.cc.

References NS_LOG_FUNCTION.

ns3::EnergySource::~EnergySource ( )
virtual

Definition at line 50 of file energy-source.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

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

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

Definition at line 71 of file energy-source.cc.

References ns3::DeviceEnergyModelContainer::Add(), m_models, NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by AnimationRemainingEnergyTestCase::PrepareNetwork().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Definition at line 217 of file energy-source.cc.

References ns3::DeviceEnergyModelContainer::Clear(), m_harvesters, m_models, m_node, and NS_LOG_FUNCTION.

Referenced by ns3::BasicEnergySource::DoDispose(), ns3::LiIonEnergySource::DoDispose(), ns3::RvBatteryModel::DoDispose(), and DoDispose().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double ns3::EnergySource::CalculateTotalCurrent ( void  )
protected
Returns
Total current draw from all DeviceEnergyModels.

Definition at line 164 of file energy-source.cc.

References ns3::DeviceEnergyModelContainer::Begin(), ns3::DeviceEnergyModelContainer::End(), GetNode(), GetSupplyVoltage(), m_harvesters, m_models, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

Referenced by ns3::BasicEnergySource::CalculateRemainingEnergy(), ns3::LiIonEnergySource::CalculateRemainingEnergy(), and ns3::RvBatteryModel::UpdateEnergySource().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::EnergySource::ConnectEnergyHarvester ( Ptr< EnergyHarvester energyHarvesterPtr)
Parameters
energyHarvesterPtrPointer to energy harvester.

This function connect an energy harvester to the energy source. After the execution of this method, the pointer to the energy harvester is appended to the end of a vector of EnergyHarvester pointer. Note that the order in which different energy harvester are added to the energy source does not impact the simulation results.

Definition at line 141 of file energy-source.cc.

References m_harvesters, NS_ASSERT, and NS_LOG_FUNCTION.

void ns3::EnergySource::DisposeDeviceModels ( void  )

Calls Dispose () method of the device energy models.

Device energy models are not aggregated to the node, therefore we need to manually start them here. Called by EnergySourceContainer, which is aggregated to the node.

Definition at line 126 of file energy-source.cc.

References ns3::DeviceEnergyModelContainer::Begin(), ns3::DeviceEnergyModelContainer::End(), m_models, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

void ns3::EnergySource::DoDispose ( void  )
privatevirtual

All child's implementation must call BreakDeviceEnergyModelRefCycle to ensure reference cycles to DeviceEnergyModel objects are broken.

Defined in ns3::Object

Reimplemented from ns3::Object.

Reimplemented in ns3::RvBatteryModel, ns3::LiIonEnergySource, and ns3::BasicEnergySource.

Definition at line 153 of file energy-source.cc.

References BreakDeviceEnergyModelRefCycle(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

DeviceEnergyModelContainer ns3::EnergySource::FindDeviceEnergyModels ( TypeId  tid)
Parameters
tidTypeId of the DeviceEnergyModel we are searching for.
Returns
List of pointers to DeviceEnergyModel objects installed on node.

Definition at line 79 of file energy-source.cc.

References ns3::DeviceEnergyModelContainer::Add(), ns3::DeviceEnergyModelContainer::Begin(), ns3::DeviceEnergyModelContainer::End(), m_models, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

DeviceEnergyModelContainer ns3::EnergySource::FindDeviceEnergyModels ( std::string  name)
Parameters
namename of the DeviceEnergyModel we are searching for.
Returns
List of pointers to DeviceEnergyModel objects installed on node.

Definition at line 95 of file energy-source.cc.

References ns3::DeviceEnergyModelContainer::Add(), ns3::DeviceEnergyModelContainer::Begin(), ns3::DeviceEnergyModelContainer::End(), m_models, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

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::LiIonEnergySource, ns3::RvBatteryModel, and 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::LiIonEnergySource, ns3::RvBatteryModel, and ns3::BasicEnergySource.

Referenced by AcousticModemEnergyTestCase::DoRun().

+ Here is the caller graph for this function:

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.

Definition at line 64 of file energy-source.cc.

References m_node, and NS_LOG_FUNCTION.

Referenced by CalculateTotalCurrent(), ns3::LiIonEnergySource::HandleEnergyDrainedEvent(), and ns3::LiIonEnergySource::UpdateEnergySource().

+ Here is the caller graph for this function:

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

Implemented in ns3::LiIonEnergySource, ns3::RvBatteryModel, and ns3::BasicEnergySource.

Referenced by AcousticModemEnergyTestCase::DoRun().

+ Here is the caller graph for this function:

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::LiIonEnergySource, ns3::RvBatteryModel, and ns3::BasicEnergySource.

Referenced by CalculateTotalCurrent().

+ Here is the caller graph for this function:

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

Definition at line 36 of file energy-source.cc.

References ns3::TypeId::SetParent().

+ Here is the call graph for this function:

void ns3::EnergySource::InitializeDeviceModels ( void  )

Calls Start () method of the device energy models.

Device energy models are not aggregated to the node, therefore we need to manually start them here. Called by EnergySourceContainer, which is aggregated to the node.

Definition at line 111 of file energy-source.cc.

References ns3::DeviceEnergyModelContainer::Begin(), ns3::DeviceEnergyModelContainer::End(), m_models, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

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.

Definition at line 193 of file energy-source.cc.

References ns3::DeviceEnergyModelContainer::Begin(), ns3::DeviceEnergyModelContainer::End(), m_models, and NS_LOG_FUNCTION.

Referenced by ns3::BasicEnergySource::HandleEnergyDrainedEvent(), ns3::LiIonEnergySource::HandleEnergyDrainedEvent(), and ns3::RvBatteryModel::HandleEnergyDrainedEvent().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::EnergySource::NotifyEnergyRecharged ( void  )
protected

This function notifies all DeviceEnergyModel of energy recharged event.

It is called by the child EnergySource class when energy source is recharged.

Definition at line 205 of file energy-source.cc.

References ns3::DeviceEnergyModelContainer::Begin(), ns3::DeviceEnergyModelContainer::End(), m_models, and NS_LOG_FUNCTION.

Referenced by ns3::BasicEnergySource::HandleEnergyRechargedEvent().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Sets pointer to node containing this EnergySource.

Parameters
nodePointer to node containing this EnergySource.

Definition at line 56 of file energy-source.cc.

References m_node, NS_ASSERT, and NS_LOG_FUNCTION.

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::LiIonEnergySource, ns3::RvBatteryModel, and ns3::BasicEnergySource.

Member Data Documentation

std::vector< Ptr<EnergyHarvester> > ns3::EnergySource::m_harvesters
private

Vector of EnergyHarvester pointer connected to the same energy source.

This vector is used by the CalculateTotalCurrent method to determine the total power provided by the energy harvesters connected to the energy source.

Definition at line 210 of file energy-source.h.

Referenced by BreakDeviceEnergyModelRefCycle(), CalculateTotalCurrent(), and ConnectEnergyHarvester().

DeviceEnergyModelContainer ns3::EnergySource::m_models
private
Ptr<Node> ns3::EnergySource::m_node
private

Pointer to node containing this EnergySource.

Used by helper class to make sure device models are installed onto the corresponding node.

Definition at line 203 of file energy-source.h.

Referenced by BreakDeviceEnergyModelRefCycle(), GetNode(), and SetNode().


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