A Discrete-Event Network Simulator
API
ns3::BasicEnergySource Class Reference

BasicEnergySource decreases/increases remaining energy stored in itself in linearly. More...

#include "basic-energy-source.h"

+ Inheritance diagram for ns3::BasicEnergySource:
+ Collaboration diagram for ns3::BasicEnergySource:

Public Member Functions

 BasicEnergySource ()
 
virtual ~BasicEnergySource ()
 
virtual double GetEnergyFraction (void)
 
Time GetEnergyUpdateInterval (void) const
 
virtual double GetInitialEnergy (void) const
 
virtual double GetRemainingEnergy (void)
 
virtual double GetSupplyVoltage (void) const
 
void SetEnergyUpdateInterval (Time interval)
 
void SetInitialEnergy (double initialEnergyJ)
 
void SetSupplyVoltage (double supplyVoltageV)
 
virtual void UpdateEnergySource (void)
 Implements UpdateEnergySource. More...
 
- Public Member Functions inherited from ns3::EnergySource
 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)
 
Ptr< NodeGetNode (void) const
 
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...
 
- 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
 Implement the GetInstanceTypeId method defined in ObjectBase. 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 ()
 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. 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::EnergySource
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...
 

Private Member Functions

void CalculateRemainingEnergy (void)
 Calculates remaining energy. More...
 
void DoDispose (void)
 Defined in ns3::Object. More...
 
void DoInitialize (void)
 Defined in ns3::Object. More...
 
void HandleEnergyDrainedEvent (void)
 Handles the remaining energy going to zero event. More...
 
void HandleEnergyRechargedEvent (void)
 Handles the remaining energy exceeding the high threshold after it went below the low threshold. More...
 

Private Attributes

bool m_depleted
 
EventId m_energyUpdateEvent
 
Time m_energyUpdateInterval
 
double m_highBatteryTh
 
double m_initialEnergyJ
 
Time m_lastUpdateTime
 
double m_lowBatteryTh
 
TracedValue< double > m_remainingEnergyJ
 
double m_supplyVoltageV
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::EnergySource
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 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...
 

Detailed Description

BasicEnergySource decreases/increases remaining energy stored in itself in linearly.

Introspection did not find any typical Config paths.


Attributes

  • BasicEnergySourceInitialEnergyJ: Initial energy stored in basic energy source.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 10
    • Flags: construct write read
  • BasicEnergySupplyVoltageV: Initial supply voltage for basic energy source.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 3
    • Flags: construct write read
  • BasicEnergyLowBatteryThreshold: Low battery threshold for basic energy source.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 0.1
    • Flags: construct write read
  • BasicEnergyHighBatteryThreshold: High battery threshold for basic energy source.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 0.15
    • Flags: construct write read
  • PeriodicEnergyUpdateInterval: Time between two consecutive periodic energy updates.
    • Set with class: ns3::TimeValue
    • Underlying type: Time –9223372036854775808.0ns:+9223372036854775807.0ns
    • Initial value: +1000000000.0ns
    • Flags: construct write read

TraceSources

Size of this type is 192 bytes (on a 64-bit architecture).

Definition at line 37 of file basic-energy-source.h.

Constructor & Destructor Documentation

ns3::BasicEnergySource::BasicEnergySource ( )

Definition at line 77 of file basic-energy-source.cc.

References m_depleted, m_lastUpdateTime, NS_LOG_FUNCTION, and ns3::Seconds().

+ Here is the call graph for this function:

ns3::BasicEnergySource::~BasicEnergySource ( )
virtual

Definition at line 84 of file basic-energy-source.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

void ns3::BasicEnergySource::CalculateRemainingEnergy ( void  )
private

Calculates remaining energy.

This function uses the total current from all device models to calculate the amount of energy to decrease. The energy to decrease is given by: energy to decrease = total current * supply voltage * time duration This function subtracts the calculated energy to decrease from remaining energy.

Definition at line 221 of file basic-energy-source.cc.

References ns3::EnergySource::CalculateTotalCurrent(), ns3::Time::GetSeconds(), m_lastUpdateTime, m_remainingEnergyJ, m_supplyVoltageV, ns3::Simulator::Now(), NS_ASSERT, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

Referenced by UpdateEnergySource().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::BasicEnergySource::DoDispose ( void  )
privatevirtual

Defined in ns3::Object.

Reimplemented from ns3::EnergySource.

Definition at line 198 of file basic-energy-source.cc.

References ns3::EnergySource::BreakDeviceEnergyModelRefCycle(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

void ns3::BasicEnergySource::DoInitialize ( void  )
privatevirtual

Defined in ns3::Object.

Reimplemented from ns3::Object.

Definition at line 191 of file basic-energy-source.cc.

References NS_LOG_FUNCTION, and UpdateEnergySource().

+ Here is the call graph for this function:

double ns3::BasicEnergySource::GetEnergyFraction ( void  )
virtual
Returns
Energy fraction.

Implements GetEnergyFraction.

Implements ns3::EnergySource.

Definition at line 143 of file basic-energy-source.cc.

References m_initialEnergyJ, m_remainingEnergyJ, NS_LOG_FUNCTION, and UpdateEnergySource().

+ Here is the call graph for this function:

Time ns3::BasicEnergySource::GetEnergyUpdateInterval ( void  ) const
Returns
The interval between each energy update.

Definition at line 113 of file basic-energy-source.cc.

References m_energyUpdateInterval, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

double ns3::BasicEnergySource::GetInitialEnergy ( void  ) const
virtual
Returns
Initial energy stored in energy source, in Joules.

Implements GetInitialEnergy.

Implements ns3::EnergySource.

Definition at line 127 of file basic-energy-source.cc.

References m_initialEnergyJ, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

double ns3::BasicEnergySource::GetRemainingEnergy ( void  )
virtual
Returns
Remaining energy in energy source, in Joules

Implements GetRemainingEnergy.

Implements ns3::EnergySource.

Definition at line 134 of file basic-energy-source.cc.

References m_remainingEnergyJ, NS_LOG_FUNCTION, and UpdateEnergySource().

Referenced by AnimationRemainingEnergyTestCase::CheckLogic().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double ns3::BasicEnergySource::GetSupplyVoltage ( void  ) const
virtual
Returns
Supply voltage at the energy source.

Implements GetSupplyVoltage.

Implements ns3::EnergySource.

Definition at line 120 of file basic-energy-source.cc.

References m_supplyVoltageV, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

void ns3::BasicEnergySource::HandleEnergyDrainedEvent ( void  )
private

Handles the remaining energy going to zero event.

This function notifies all the energy models aggregated to the node about the energy being depleted. Each energy model is then responsible for its own handler.

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

References ns3::EnergySource::NotifyEnergyDrained(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.

Referenced by UpdateEnergySource().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::BasicEnergySource::HandleEnergyRechargedEvent ( void  )
private

Handles the remaining energy exceeding the high threshold after it went below the low threshold.

This function notifies all the energy models aggregated to the node about the energy being recharged. Each energy model is then responsible for its own handler.

Definition at line 213 of file basic-energy-source.cc.

References ns3::EnergySource::NotifyEnergyRecharged(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.

Referenced by UpdateEnergySource().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::BasicEnergySource::SetEnergyUpdateInterval ( Time  interval)
Parameters
intervalEnergy update interval.

This function sets the interval between each energy update.

Definition at line 106 of file basic-energy-source.cc.

References m_energyUpdateInterval, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

void ns3::BasicEnergySource::SetInitialEnergy ( double  initialEnergyJ)
Parameters
initialEnergyJInitial energy, in Joules

Sets initial energy stored in the energy source. Note that initial energy is assumed to be set before simulation starts and is set only once per simulation.

Definition at line 90 of file basic-energy-source.cc.

References m_initialEnergyJ, m_remainingEnergyJ, NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by GetTypeId(), and AnimationRemainingEnergyTestCase::PrepareNetwork().

+ Here is the caller graph for this function:

void ns3::BasicEnergySource::SetSupplyVoltage ( double  supplyVoltageV)
Parameters
supplyVoltageVSupply voltage at the energy source, in Volts.

Sets supply voltage of the energy source.

Definition at line 99 of file basic-energy-source.cc.

References m_supplyVoltageV, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

Member Data Documentation

bool ns3::BasicEnergySource::m_depleted
private

Definition at line 143 of file basic-energy-source.h.

Referenced by BasicEnergySource(), and UpdateEnergySource().

EventId ns3::BasicEnergySource::m_energyUpdateEvent
private

Definition at line 146 of file basic-energy-source.h.

Referenced by UpdateEnergySource().

Time ns3::BasicEnergySource::m_energyUpdateInterval
private
double ns3::BasicEnergySource::m_highBatteryTh
private

Definition at line 142 of file basic-energy-source.h.

Referenced by GetTypeId(), and UpdateEnergySource().

double ns3::BasicEnergySource::m_initialEnergyJ
private
Time ns3::BasicEnergySource::m_lastUpdateTime
private
double ns3::BasicEnergySource::m_lowBatteryTh
private

Definition at line 141 of file basic-energy-source.h.

Referenced by GetTypeId(), and UpdateEnergySource().

TracedValue<double> ns3::BasicEnergySource::m_remainingEnergyJ
private
double ns3::BasicEnergySource::m_supplyVoltageV
private

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