BasicEnergySource decreases/increases remaining energy stored in itself in linearly. More...
#include "basic-energy-source.h"
Public Member Functions | |
BasicEnergySource () | |
~BasicEnergySource () override | |
double | GetEnergyFraction () override |
Time | GetEnergyUpdateInterval () const |
double | GetInitialEnergy () const override |
double | GetRemainingEnergy () override |
double | GetSupplyVoltage () const override |
void | SetEnergyUpdateInterval (Time interval) |
void | SetInitialEnergy (double initialEnergyJ) |
void | SetSupplyVoltage (double supplyVoltageV) |
void | UpdateEnergySource () override |
Implements UpdateEnergySource. | |
Public Member Functions inherited from ns3::energy::EnergySource | |
EnergySource () | |
~EnergySource () override | |
void | AppendDeviceEnergyModel (Ptr< DeviceEnergyModel > deviceEnergyModelPtr) |
void | ConnectEnergyHarvester (Ptr< EnergyHarvester > energyHarvesterPtr) |
void | DisposeDeviceModels () |
Calls Dispose () method of the device energy models. | |
DeviceEnergyModelContainer | FindDeviceEnergyModels (std::string name) |
DeviceEnergyModelContainer | FindDeviceEnergyModels (TypeId tid) |
Ptr< Node > | GetNode () const |
void | InitializeDeviceModels () |
Calls Start () method of the device energy models. | |
void | SetNode (Ptr< Node > node) |
Sets pointer to node containing this EnergySource. | |
Public Member Functions inherited from ns3::Object | |
Object () | |
Constructor. | |
~Object () override | |
Destructor. | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. | |
void | Dispose () |
Dispose of this Object. | |
AggregateIterator | GetAggregateIterator () const |
Get an iterator to the Objects aggregated to this one. | |
TypeId | GetInstanceTypeId () const override |
Get the most derived TypeId for this Object. | |
template<typename T > | |
Ptr< T > | GetObject () const |
Get a pointer to the requested aggregated Object. | |
template<> | |
Ptr< Object > | GetObject () const |
Specialization of () for objects of type ns3::Object. | |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
Get a pointer to the requested aggregated Object by TypeId. | |
template<> | |
Ptr< Object > | GetObject (TypeId tid) const |
Specialization of (TypeId tid) for objects of type ns3::Object. | |
void | Initialize () |
Invoke DoInitialize on all Objects aggregated to this one. | |
bool | IsInitialized () const |
Check if the object has been initialized. | |
void | UnidirectionalAggregateObject (Ptr< Object > other) |
Aggregate an Object to another Object. | |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Default constructor. | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment operator. | |
void | Ref () const |
Increment the reference count. | |
void | Unref () const |
Decrement the reference count. | |
Public Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. | |
void | GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const |
Get the value of an attribute, raising fatal errors if unsuccessful. | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Get the type ID. | |
Static Public Member Functions inherited from ns3::energy::EnergySource | |
static TypeId | GetTypeId () |
Get the type ID. | |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId () |
Register this type. | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId () |
Get the type ID. | |
Private Member Functions | |
void | CalculateRemainingEnergy () |
Calculates remaining energy. | |
void | DoDispose () override |
Defined in ns3::Object. | |
void | DoInitialize () override |
Defined in ns3::Object. | |
void | HandleEnergyDrainedEvent () |
Handles the remaining energy going to zero event. | |
void | HandleEnergyRechargedEvent () |
Handles the remaining energy exceeding the high threshold after it went below the low threshold. | |
Private Attributes | |
bool | m_depleted |
set to true when the remaining energy goes below the low threshold, set to false again when the remaining energy exceeds the high threshold | |
EventId | m_energyUpdateEvent |
energy update event | |
Time | m_energyUpdateInterval |
energy update interval | |
double | m_highBatteryTh |
high battery threshold, as a fraction of the initial energy | |
double | m_initialEnergyJ |
initial energy, in Joules | |
Time | m_lastUpdateTime |
last update time | |
double | m_lowBatteryTh |
low battery threshold, as a fraction of the initial energy | |
TracedValue< double > | m_remainingEnergyJ |
remaining energy, in Joules | |
double | m_supplyVoltageV |
supply voltage, in Volts | |
Additional Inherited Members | |
Protected Member Functions inherited from ns3::energy::EnergySource | |
void | BreakDeviceEnergyModelRefCycle () |
This function is called to break reference cycle between EnergySource and DeviceEnergyModel. | |
double | CalculateTotalCurrent () |
void | NotifyEnergyChanged () |
This function notifies all DeviceEnergyModel of energy changed event. | |
void | NotifyEnergyDrained () |
This function notifies all DeviceEnergyModel of energy depletion event. | |
void | NotifyEnergyRecharged () |
This function notifies all DeviceEnergyModel of energy recharged event. | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
Copy an Object. | |
virtual void | NotifyNewAggregate () |
Notify all Objects aggregated to this one of a new Object being aggregated. | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. | |
virtual void | NotifyConstructionCompleted () |
Notifier called once the ObjectBase is fully constructed. | |
Related Symbols inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
BasicEnergySource decreases/increases remaining energy stored in itself in linearly.
Definition at line 29 of file basic-energy-source.h.
ns3::energy::BasicEnergySource::BasicEnergySource | ( | ) |
Definition at line 69 of file basic-energy-source.cc.
References m_depleted, m_lastUpdateTime, NS_LOG_FUNCTION, and ns3::Seconds().
|
override |
Definition at line 76 of file basic-energy-source.cc.
References NS_LOG_FUNCTION.
|
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 212 of file basic-energy-source.cc.
References ns3::energy::EnergySource::CalculateTotalCurrent(), ns3::Time::IsPositive(), m_lastUpdateTime, m_remainingEnergyJ, m_supplyVoltageV, ns3::Simulator::Now(), NS_ASSERT, NS_LOG_DEBUG, and NS_LOG_FUNCTION.
Referenced by UpdateEnergySource().
|
overrideprivatevirtual |
Defined in ns3::Object.
Reimplemented from ns3::Object.
Definition at line 189 of file basic-energy-source.cc.
References ns3::energy::EnergySource::BreakDeviceEnergyModelRefCycle(), and NS_LOG_FUNCTION.
|
overrideprivatevirtual |
Defined in ns3::Object.
Reimplemented from ns3::Object.
Definition at line 182 of file basic-energy-source.cc.
References NS_LOG_FUNCTION, and UpdateEnergySource().
|
overridevirtual |
Implements GetEnergyFraction.
Implements ns3::energy::EnergySource.
Definition at line 135 of file basic-energy-source.cc.
References m_initialEnergyJ, m_remainingEnergyJ, NS_LOG_FUNCTION, and UpdateEnergySource().
Time ns3::energy::BasicEnergySource::GetEnergyUpdateInterval | ( | ) | const |
Definition at line 105 of file basic-energy-source.cc.
References m_energyUpdateInterval, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
overridevirtual |
Implements GetInitialEnergy.
Implements ns3::energy::EnergySource.
Definition at line 119 of file basic-energy-source.cc.
References m_initialEnergyJ, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
overridevirtual |
Implements GetRemainingEnergy.
Implements ns3::energy::EnergySource.
Definition at line 126 of file basic-energy-source.cc.
References m_remainingEnergyJ, NS_LOG_FUNCTION, and UpdateEnergySource().
|
overridevirtual |
Implements GetSupplyVoltage.
Implements ns3::energy::EnergySource.
Definition at line 112 of file basic-energy-source.cc.
References m_supplyVoltageV, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
static |
Get the type ID.
Definition at line 26 of file basic-energy-source.cc.
References ns3::TypeId::AddDeprecatedName(), GetEnergyUpdateInterval(), GetInitialEnergy(), GetSupplyVoltage(), m_highBatteryTh, m_lowBatteryTh, m_remainingEnergyJ, ns3::MakeDoubleAccessor(), ns3::MakeDoubleChecker(), ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeTraceSourceAccessor(), ns3::Seconds(), SetEnergyUpdateInterval(), SetInitialEnergy(), ns3::TypeId::SetParent(), and SetSupplyVoltage().
|
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 196 of file basic-energy-source.cc.
References ns3::energy::EnergySource::NotifyEnergyDrained(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.
Referenced by UpdateEnergySource().
|
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 204 of file basic-energy-source.cc.
References ns3::energy::EnergySource::NotifyEnergyRecharged(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.
Referenced by UpdateEnergySource().
void ns3::energy::BasicEnergySource::SetEnergyUpdateInterval | ( | Time | interval | ) |
interval | Energy update interval. |
This function sets the interval between each energy update.
Definition at line 98 of file basic-energy-source.cc.
References m_energyUpdateInterval, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::energy::BasicEnergySource::SetInitialEnergy | ( | double | initialEnergyJ | ) |
initialEnergyJ | Initial 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 82 of file basic-energy-source.cc.
References m_initialEnergyJ, m_remainingEnergyJ, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::energy::BasicEnergySource::SetSupplyVoltage | ( | double | supplyVoltageV | ) |
supplyVoltageV | Supply voltage at the energy source, in Volts. |
Sets supply voltage of the energy source.
Definition at line 91 of file basic-energy-source.cc.
References m_supplyVoltageV, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
overridevirtual |
Implements UpdateEnergySource.
Implements ns3::energy::EnergySource.
Definition at line 144 of file basic-energy-source.cc.
References CalculateRemainingEnergy(), HandleEnergyDrainedEvent(), HandleEnergyRechargedEvent(), ns3::EventId::IsExpired(), m_depleted, m_energyUpdateEvent, m_energyUpdateInterval, m_highBatteryTh, m_initialEnergyJ, m_lastUpdateTime, m_lowBatteryTh, m_remainingEnergyJ, ns3::energy::EnergySource::NotifyEnergyChanged(), ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and UpdateEnergySource().
Referenced by DoInitialize(), BasicEnergyHarvesterTestCase::DoRun(), GetEnergyFraction(), GetRemainingEnergy(), BasicEnergyUpdateTest::StateSwitchTest(), and UpdateEnergySource().
|
private |
set to true when the remaining energy goes below the low threshold, set to false again when the remaining energy exceeds the high threshold
Definition at line 142 of file basic-energy-source.h.
Referenced by BasicEnergySource(), and UpdateEnergySource().
|
private |
energy update event
Definition at line 144 of file basic-energy-source.h.
Referenced by UpdateEnergySource().
|
private |
energy update interval
Definition at line 146 of file basic-energy-source.h.
Referenced by GetEnergyUpdateInterval(), SetEnergyUpdateInterval(), and UpdateEnergySource().
|
private |
high battery threshold, as a fraction of the initial energy
Definition at line 137 of file basic-energy-source.h.
Referenced by GetTypeId(), and UpdateEnergySource().
|
private |
initial energy, in Joules
Definition at line 134 of file basic-energy-source.h.
Referenced by GetEnergyFraction(), GetInitialEnergy(), SetInitialEnergy(), and UpdateEnergySource().
|
private |
last update time
Definition at line 145 of file basic-energy-source.h.
Referenced by BasicEnergySource(), CalculateRemainingEnergy(), and UpdateEnergySource().
|
private |
low battery threshold, as a fraction of the initial energy
Definition at line 136 of file basic-energy-source.h.
Referenced by GetTypeId(), and UpdateEnergySource().
|
private |
remaining energy, in Joules
Definition at line 143 of file basic-energy-source.h.
Referenced by CalculateRemainingEnergy(), GetEnergyFraction(), GetRemainingEnergy(), GetTypeId(), SetInitialEnergy(), and UpdateEnergySource().
|
private |
supply voltage, in Volts
Definition at line 135 of file basic-energy-source.h.
Referenced by CalculateRemainingEnergy(), GetSupplyVoltage(), and SetSupplyVoltage().