Energy source base class. More...
#include <energy-source.h>
Public Member Functions | |
EnergySource () | |
virtual | ~EnergySource () |
void | AppendDeviceEnergyModel (Ptr< DeviceEnergyModel > deviceEnergyModelPtr) |
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< Node > | GetNode (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 () | |
virtual | ~Object () |
void | AggregateObject (Ptr< Object > other) |
void | Dispose (void) |
Run the DoDispose methods of this object and all the objects aggregated to it. More... | |
AggregateIterator | GetAggregateIterator (void) const |
virtual TypeId | GetInstanceTypeId (void) const |
template<typename T > | |
Ptr< T > | GetObject (void) const |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
void | Initialize (void) |
This method calls the virtual DoInitialize method on all the objects aggregated to this object. More... | |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Constructor. More... | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount (void) const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment. 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 |
bool | GetAttributeFailSafe (std::string name, AttributeValue &attribute) const |
void | SetAttribute (std::string name, const AttributeValue &value) |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
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::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
static void | Cleanup (void) |
Noop. 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... | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
virtual void | DoInitialize (void) |
This method is called only once by Object::Initialize. More... | |
virtual void | NotifyNewAggregate (void) |
This method is invoked whenever two sets of objects are aggregated together. More... | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
virtual void | NotifyConstructionCompleted (void) |
This method is invoked once all member attributes have been initialized. 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 | |
DeviceEnergyModelContainer | m_models |
List of device energy models installed on the same node. More... | |
Ptr< Node > | m_node |
Pointer to node containing this EnergySource. More... | |
Energy source base class.
Doxygen introspection did not find any typical Config paths.
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.
No Attributes are defined for this type.
No TraceSources are defined for this type.
Definition at line 71 of file energy-source.h.
ns3::EnergySource::EnergySource | ( | ) |
Definition at line 40 of file energy-source.cc.
References NS_LOG_FUNCTION.
|
virtual |
Definition at line 45 of file energy-source.cc.
References NS_LOG_FUNCTION.
void ns3::EnergySource::AppendDeviceEnergyModel | ( | Ptr< DeviceEnergyModel > | deviceEnergyModelPtr | ) |
deviceEnergyModelPtr | Pointer to device energy model. |
This function appends a device energy model to the end of a list of DeviceEnergyModelInfo structs.
Definition at line 66 of file energy-source.cc.
References ns3::DeviceEnergyModelContainer::Add(), m_models, NS_ASSERT, and NS_LOG_FUNCTION.
|
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 176 of file energy-source.cc.
References ns3::DeviceEnergyModelContainer::Clear(), m_models, m_node, and NS_LOG_FUNCTION.
Referenced by ns3::BasicEnergySource::DoDispose(), ns3::LiIonEnergySource::DoDispose(), DoDispose(), and ns3::RvBatteryModel::DoDispose().
|
protected |
Definition at line 151 of file energy-source.cc.
References ns3::DeviceEnergyModelContainer::Begin(), ns3::DeviceEnergyModelContainer::End(), m_models, and NS_LOG_FUNCTION.
Referenced by ns3::BasicEnergySource::CalculateRemainingEnergy(), ns3::LiIonEnergySource::CalculateRemainingEnergy(), and ns3::RvBatteryModel::UpdateEnergySource().
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 121 of file energy-source.cc.
References ns3::DeviceEnergyModelContainer::Begin(), ns3::DeviceEnergyModelContainer::End(), m_models, and NS_LOG_FUNCTION.
|
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 140 of file energy-source.cc.
References BreakDeviceEnergyModelRefCycle(), and NS_LOG_FUNCTION.
DeviceEnergyModelContainer ns3::EnergySource::FindDeviceEnergyModels | ( | TypeId | tid | ) |
tid | TypeId of the DeviceEnergyModel we are searching for. |
Definition at line 74 of file energy-source.cc.
References ns3::DeviceEnergyModelContainer::Add(), ns3::DeviceEnergyModelContainer::Begin(), ns3::DeviceEnergyModelContainer::End(), m_models, and NS_LOG_FUNCTION.
Referenced by main().
DeviceEnergyModelContainer ns3::EnergySource::FindDeviceEnergyModels | ( | std::string | name | ) |
name | name of the DeviceEnergyModel we are searching for. |
Definition at line 90 of file energy-source.cc.
References ns3::DeviceEnergyModelContainer::Add(), ns3::DeviceEnergyModelContainer::Begin(), ns3::DeviceEnergyModelContainer::End(), m_models, and NS_LOG_FUNCTION.
|
pure virtual |
This function returns the percentage of energy left in the energy source.
Implemented in ns3::LiIonEnergySource, ns3::RvBatteryModel, and ns3::BasicEnergySource.
|
pure virtual |
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.
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 59 of file energy-source.cc.
References m_node, and NS_LOG_FUNCTION.
Referenced by ns3::LiIonEnergySource::HandleEnergyDrainedEvent(), and ns3::LiIonEnergySource::UpdateEnergySource().
|
pure virtual |
Implemented in ns3::LiIonEnergySource, ns3::RvBatteryModel, and ns3::BasicEnergySource.
|
pure virtual |
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.
|
static |
Definition at line 32 of file energy-source.cc.
References ns3::TypeId::SetParent().
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 106 of file energy-source.cc.
References ns3::DeviceEnergyModelContainer::Begin(), ns3::DeviceEnergyModelContainer::End(), m_models, and NS_LOG_FUNCTION.
|
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 164 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().
Sets pointer to node containing this EnergySource.
node | Pointer to node containing this EnergySource. |
Definition at line 51 of file energy-source.cc.
References m_node, NS_ASSERT, and NS_LOG_FUNCTION.
|
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.
|
private |
List of device energy models installed on the same node.
Definition at line 176 of file energy-source.h.
Referenced by AppendDeviceEnergyModel(), BreakDeviceEnergyModelRefCycle(), CalculateTotalCurrent(), DisposeDeviceModels(), FindDeviceEnergyModels(), InitializeDeviceModels(), and NotifyEnergyDrained().
Pointer to node containing this EnergySource.
Used by helper class to make sure device models are installed onto the corresponding node.
Definition at line 182 of file energy-source.h.
Referenced by BreakDeviceEnergyModelRefCycle(), GetNode(), and SetNode().