A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::lorawan::LoraRadioEnergyModel Class Reference

A LoRa radio energy model. More...

#include "lora-radio-energy-model.h"

+ Inheritance diagram for ns3::lorawan::LoraRadioEnergyModel:
+ Collaboration diagram for ns3::lorawan::LoraRadioEnergyModel:

Public Types

typedef Callback< void > LoraRadioEnergyDepletionCallback
 Callback type for energy depletion handling.
 
typedef Callback< void > LoraRadioEnergyRechargedCallback
 Callback type for energy recharged handling.
 
- Public Types inherited from ns3::energy::DeviceEnergyModel
typedef Callback< void, int > ChangeStateCallback
 Callback type for ChangeState function.
 

Public Member Functions

 LoraRadioEnergyModel ()
 
 ~LoraRadioEnergyModel () override
 Destructor.
 
void ChangeState (int newState) override
 Changes state of the LoraRadioEnergyMode.
 
EndDeviceLoraPhy::State GetCurrentState () const
 
LoraRadioEnergyModelPhyListenerGetPhyListener ()
 
double GetRxCurrentA () const
 Gets receive current.
 
double GetSleepCurrentA () const
 Gets sleep current.
 
double GetStandbyCurrentA () const
 Gets idle current.
 
double GetTotalEnergyConsumption () const override
 
double GetTxCurrentA () const
 Gets transmit current.
 
void HandleEnergyChanged () override
 Handles energy recharged.
 
void HandleEnergyDepletion () override
 Handles energy depletion.
 
void HandleEnergyRecharged () override
 Handles energy recharged.
 
void SetEnergyDepletionCallback (LoraRadioEnergyDepletionCallback callback)
 
void SetEnergyRechargedCallback (LoraRadioEnergyRechargedCallback callback)
 
void SetEnergySource (Ptr< EnergySource > source) override
 Sets pointer to EnergySouce installed on node.
 
void SetRxCurrentA (double rxCurrentA)
 Sets receive current.
 
void SetSleepCurrentA (double sleepCurrentA)
 Sets sleep current.
 
void SetStandbyCurrentA (double idleCurrentA)
 Sets idle current.
 
void SetTxCurrentA (double txCurrentA)
 Sets transmit current.
 
void SetTxCurrentFromModel (double txPowerDbm)
 Calls the CalcTxCurrent method of the tx current model to compute the tx current based on such model.
 
void SetTxCurrentModel (Ptr< LoraTxCurrentModel > model)
 
- Public Member Functions inherited from ns3::energy::DeviceEnergyModel
 DeviceEnergyModel ()
 
 ~DeviceEnergyModel () override
 
virtual void ChangeState (int newState)=0
 
double GetCurrentA () const
 
virtual double GetTotalEnergyConsumption () const =0
 
virtual void HandleEnergyChanged ()=0
 This function is called by the EnergySource object when energy stored in the energy source is changed.
 
virtual void HandleEnergyDepletion ()=0
 This function is called by the EnergySource object when energy stored in the energy source is depleted.
 
virtual void HandleEnergyRecharged ()=0
 This function is called by the EnergySource object when energy stored in the energy source is recharged.
 
virtual void SetEnergySource (Ptr< EnergySource > source)=0
 
- 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< ObjectGetObject () 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< ObjectGetObject (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.
 
SimpleRefCountoperator= (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) 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.
 
virtual TypeId GetInstanceTypeId () const =0
 Get the most derived TypeId for this Object.
 
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 ()
 Register this type.
 
- Static Public Member Functions inherited from ns3::energy::DeviceEnergyModel
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 DoDispose () override
 Destructor implementation.
 
double DoGetCurrentA () const override
 
void SetLoraRadioState (const EndDeviceLoraPhy::State state)
 

Private Attributes

EndDeviceLoraPhy::State m_currentState
 current state the radio is in
 
LoraRadioEnergyDepletionCallback m_energyDepletionCallback
 Energy depletion callback.
 
LoraRadioEnergyRechargedCallback m_energyRechargedCallback
 Energy recharged callback.
 
double m_idleCurrentA
 idle current
 
bool m_isSupersededChangeState
 superseded change state
 
Time m_lastUpdateTime
 time stamp of previous energy update
 
LoraRadioEnergyModelPhyListenerm_listener
 EndDeviceLoraPhy listener.
 
uint8_t m_nPendingChangeState
 pending state change
 
double m_rxCurrentA
 receive current
 
double m_sleepCurrentA
 sleep current
 
Ptr< EnergySourcem_source
 energy source
 
TracedValue< doublem_totalEnergyConsumption
 This variable keeps track of the total energy consumed by this model.
 
double m_txCurrentA
 transmit current
 
Ptr< LoraTxCurrentModelm_txCurrentModel
 current model
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object.
 
virtual void DoDispose ()
 Destructor implementation.
 
virtual void DoInitialize ()
 Initialize() implementation.
 
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.
 

Detailed Description

A LoRa radio energy model.

4 states are defined for the radio: TX, RX, STANDBY, SLEEP. Default state is STANDBY. The different types of transactions that are defined are:

  1. Tx: State goes from STANDBY to TX, radio is in TX state for TX_duration, then state goes from TX to STANDBY.
  2. Rx: State goes from STANDBY to RX, radio is in RX state for RX_duration, then state goes from RX to STANDBY.
  3. Go_to_Sleep: State goes from STANDBY to SLEEP.
  4. End_of_Sleep: State goes from SLEEP to STANDBY. The class keeps track of what state the radio is currently in.

Energy calculation: For each transaction, this model notifies EnergySource object. The EnergySource object will query this model for the total current. Then the EnergySource object uses the total current to calculate energy.

Definition at line 133 of file lora-radio-energy-model.h.

Member Typedef Documentation

◆ LoraRadioEnergyDepletionCallback

Callback type for energy depletion handling.

Definition at line 139 of file lora-radio-energy-model.h.

◆ LoraRadioEnergyRechargedCallback

Callback type for energy recharged handling.

Definition at line 144 of file lora-radio-energy-model.h.

Constructor & Destructor Documentation

◆ LoraRadioEnergyModel()

◆ ~LoraRadioEnergyModel()

ns3::lorawan::LoraRadioEnergyModel::~LoraRadioEnergyModel ( )
override

Destructor.

Definition at line 98 of file lora-radio-energy-model.cc.

References m_listener, and NS_LOG_FUNCTION.

Member Function Documentation

◆ ChangeState()

void ns3::lorawan::LoraRadioEnergyModel::ChangeState ( int  newState)
overridevirtual

◆ DoDispose()

void ns3::lorawan::LoraRadioEnergyModel::DoDispose ( )
overrideprivatevirtual

Destructor implementation.

This method is called by Dispose() or by the Object's destructor, whichever comes first.

Subclasses are expected to implement their real destruction code in an overridden version of this method and chain up to their parent's implementation once they are done. i.e, for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose() method.

It is safe to call GetObject() from within this method.

Reimplemented from ns3::Object.

Definition at line 324 of file lora-radio-energy-model.cc.

References m_energyDepletionCallback, m_source, NS_LOG_FUNCTION, and ns3::Callback< R, UArgs >::Nullify().

+ Here is the call graph for this function:

◆ DoGetCurrentA()

double ns3::lorawan::LoraRadioEnergyModel::DoGetCurrentA ( ) const
overrideprivatevirtual

◆ GetCurrentState()

EndDeviceLoraPhy::State ns3::lorawan::LoraRadioEnergyModel::GetCurrentState ( ) const
Returns
Current state.

Definition at line 176 of file lora-radio-energy-model.cc.

References m_currentState, and NS_LOG_FUNCTION.

◆ GetPhyListener()

LoraRadioEnergyModelPhyListener * ns3::lorawan::LoraRadioEnergyModel::GetPhyListener ( )
Returns
Pointer to the PHY listener.

Definition at line 313 of file lora-radio-energy-model.cc.

References m_listener, and NS_LOG_FUNCTION.

◆ GetRxCurrentA()

double ns3::lorawan::LoraRadioEnergyModel::GetRxCurrentA ( ) const

Gets receive current.

Returns
Receive current [A] of the lora device.

Definition at line 148 of file lora-radio-energy-model.cc.

References m_rxCurrentA, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ GetSleepCurrentA()

double ns3::lorawan::LoraRadioEnergyModel::GetSleepCurrentA ( ) const

Gets sleep current.

Returns
Sleep current [A] of the lora device.

Definition at line 162 of file lora-radio-energy-model.cc.

References m_sleepCurrentA, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ GetStandbyCurrentA()

double ns3::lorawan::LoraRadioEnergyModel::GetStandbyCurrentA ( ) const

Gets idle current.

Returns
Idle current [A] of the lora device.

Definition at line 120 of file lora-radio-energy-model.cc.

References m_idleCurrentA, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ GetTotalEnergyConsumption()

double ns3::lorawan::LoraRadioEnergyModel::GetTotalEnergyConsumption ( ) const
overridevirtual
Returns
Total energy consumption of the wifi device.

Implements DeviceEnergyModel::GetTotalEnergyConsumption.

Implements ns3::energy::DeviceEnergyModel.

Definition at line 113 of file lora-radio-energy-model.cc.

References m_totalEnergyConsumption, and NS_LOG_FUNCTION.

◆ GetTxCurrentA()

double ns3::lorawan::LoraRadioEnergyModel::GetTxCurrentA ( ) const

Gets transmit current.

Returns
Transmit current [A] of the lora device.

Definition at line 134 of file lora-radio-energy-model.cc.

References m_txCurrentA, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::lorawan::LoraRadioEnergyModel::GetTypeId ( )
static

Register this type.

Returns
The object TypeId.

Definition at line 37 of file lora-radio-energy-model.cc.

References GetRxCurrentA(), GetSleepCurrentA(), GetStandbyCurrentA(), GetTxCurrentA(), m_totalEnergyConsumption, m_txCurrentModel, ns3::MakeDoubleAccessor(), ns3::MakePointerAccessor(), ns3::MakeTraceSourceAccessor(), ns3::TypeId::SetParent(), SetRxCurrentA(), SetSleepCurrentA(), SetStandbyCurrentA(), and SetTxCurrentA().

+ Here is the call graph for this function:

◆ HandleEnergyChanged()

void ns3::lorawan::LoraRadioEnergyModel::HandleEnergyChanged ( )
overridevirtual

Handles energy recharged.

Implements DeviceEnergyModel::HandleEnergyChanged.

Implements ns3::energy::DeviceEnergyModel.

Definition at line 294 of file lora-radio-energy-model.cc.

References NS_LOG_DEBUG, and NS_LOG_FUNCTION.

◆ HandleEnergyDepletion()

void ns3::lorawan::LoraRadioEnergyModel::HandleEnergyDepletion ( )
overridevirtual

Handles energy depletion.

Implements DeviceEnergyModel::HandleEnergyDepletion.

Implements ns3::energy::DeviceEnergyModel.

Definition at line 282 of file lora-radio-energy-model.cc.

References ns3::Callback< R, UArgs >::IsNull(), m_energyDepletionCallback, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ HandleEnergyRecharged()

void ns3::lorawan::LoraRadioEnergyModel::HandleEnergyRecharged ( )
overridevirtual

Handles energy recharged.

Implements DeviceEnergyModel::HandleEnergyRecharged.

Implements ns3::energy::DeviceEnergyModel.

Definition at line 301 of file lora-radio-energy-model.cc.

References ns3::Callback< R, UArgs >::IsNull(), m_energyRechargedCallback, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ SetEnergyDepletionCallback()

void ns3::lorawan::LoraRadioEnergyModel::SetEnergyDepletionCallback ( LoraRadioEnergyDepletionCallback  callback)
Parameters
callbackCallback function.

Sets callback for energy depletion handling.

Definition at line 183 of file lora-radio-energy-model.cc.

References ns3::Callback< R, UArgs >::IsNull(), m_energyDepletionCallback, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ SetEnergyRechargedCallback()

void ns3::lorawan::LoraRadioEnergyModel::SetEnergyRechargedCallback ( LoraRadioEnergyRechargedCallback  callback)
Parameters
callbackCallback function.

Sets callback for energy recharged handling.

Definition at line 194 of file lora-radio-energy-model.cc.

References ns3::Callback< R, UArgs >::IsNull(), m_energyRechargedCallback, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ SetEnergySource()

void ns3::lorawan::LoraRadioEnergyModel::SetEnergySource ( Ptr< EnergySource source)
overridevirtual

Sets pointer to EnergySouce installed on node.

Parameters
sourcePointer to EnergySource installed on node.

Implements DeviceEnergyModel::SetEnergySource.

Implements ns3::energy::DeviceEnergyModel.

Definition at line 105 of file lora-radio-energy-model.cc.

References m_source, NS_ASSERT, and NS_LOG_FUNCTION.

◆ SetLoraRadioState()

void ns3::lorawan::LoraRadioEnergyModel::SetLoraRadioState ( const EndDeviceLoraPhy::State  state)
private
Parameters
stateNew state the radio device is currently in.

Sets current state. This function is private so that only the energy model can change its own state.

Definition at line 351 of file lora-radio-energy-model.cc.

References m_currentState, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::lorawan::EndDeviceLoraPhy::RX, ns3::lorawan::EndDeviceLoraPhy::SLEEP, ns3::lorawan::EndDeviceLoraPhy::STANDBY, and ns3::lorawan::EndDeviceLoraPhy::TX.

Referenced by ChangeState().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetRxCurrentA()

void ns3::lorawan::LoraRadioEnergyModel::SetRxCurrentA ( double  rxCurrentA)

Sets receive current.

Parameters
rxCurrentAThe receive current [A].

Definition at line 155 of file lora-radio-energy-model.cc.

References m_rxCurrentA, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ SetSleepCurrentA()

void ns3::lorawan::LoraRadioEnergyModel::SetSleepCurrentA ( double  sleepCurrentA)

Sets sleep current.

Parameters
sleepCurrentAThe sleep current [A].

Definition at line 169 of file lora-radio-energy-model.cc.

References m_sleepCurrentA, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ SetStandbyCurrentA()

void ns3::lorawan::LoraRadioEnergyModel::SetStandbyCurrentA ( double  idleCurrentA)

Sets idle current.

Parameters
idleCurrentAThe idle current [A].

Definition at line 127 of file lora-radio-energy-model.cc.

References m_idleCurrentA, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ SetTxCurrentA()

void ns3::lorawan::LoraRadioEnergyModel::SetTxCurrentA ( double  txCurrentA)

Sets transmit current.

Parameters
txCurrentAThe transmit current [A].

Definition at line 141 of file lora-radio-energy-model.cc.

References m_txCurrentA, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ SetTxCurrentFromModel()

void ns3::lorawan::LoraRadioEnergyModel::SetTxCurrentFromModel ( double  txPowerDbm)

Calls the CalcTxCurrent method of the tx current model to compute the tx current based on such model.

Parameters
txPowerDbmThe nominal tx power in dBm.

Definition at line 211 of file lora-radio-energy-model.cc.

References m_txCurrentA, and m_txCurrentModel.

Referenced by LoraRadioEnergyModel().

+ Here is the caller graph for this function:

◆ SetTxCurrentModel()

void ns3::lorawan::LoraRadioEnergyModel::SetTxCurrentModel ( Ptr< LoraTxCurrentModel model)
Parameters
modelThe model used to compute the lora tx current.

Definition at line 205 of file lora-radio-energy-model.cc.

References m_txCurrentModel.

Member Data Documentation

◆ m_currentState

EndDeviceLoraPhy::State ns3::lorawan::LoraRadioEnergyModel::m_currentState
private

current state the radio is in

Definition at line 322 of file lora-radio-energy-model.h.

Referenced by LoraRadioEnergyModel(), ChangeState(), DoGetCurrentA(), GetCurrentState(), and SetLoraRadioState().

◆ m_energyDepletionCallback

LoraRadioEnergyDepletionCallback ns3::lorawan::LoraRadioEnergyModel::m_energyDepletionCallback
private

Energy depletion callback.

Definition at line 329 of file lora-radio-energy-model.h.

Referenced by LoraRadioEnergyModel(), DoDispose(), HandleEnergyDepletion(), and SetEnergyDepletionCallback().

◆ m_energyRechargedCallback

LoraRadioEnergyRechargedCallback ns3::lorawan::LoraRadioEnergyModel::m_energyRechargedCallback
private

Energy recharged callback.

Definition at line 332 of file lora-radio-energy-model.h.

Referenced by HandleEnergyRecharged(), and SetEnergyRechargedCallback().

◆ m_idleCurrentA

double ns3::lorawan::LoraRadioEnergyModel::m_idleCurrentA
private

idle current

Definition at line 313 of file lora-radio-energy-model.h.

Referenced by ChangeState(), DoGetCurrentA(), GetStandbyCurrentA(), and SetStandbyCurrentA().

◆ m_isSupersededChangeState

bool ns3::lorawan::LoraRadioEnergyModel::m_isSupersededChangeState
private

superseded change state

Definition at line 326 of file lora-radio-energy-model.h.

Referenced by LoraRadioEnergyModel(), and ChangeState().

◆ m_lastUpdateTime

Time ns3::lorawan::LoraRadioEnergyModel::m_lastUpdateTime
private

time stamp of previous energy update

Definition at line 323 of file lora-radio-energy-model.h.

Referenced by LoraRadioEnergyModel(), and ChangeState().

◆ m_listener

LoraRadioEnergyModelPhyListener* ns3::lorawan::LoraRadioEnergyModel::m_listener
private

◆ m_nPendingChangeState

uint8_t ns3::lorawan::LoraRadioEnergyModel::m_nPendingChangeState
private

pending state change

Definition at line 325 of file lora-radio-energy-model.h.

Referenced by LoraRadioEnergyModel(), and ChangeState().

◆ m_rxCurrentA

double ns3::lorawan::LoraRadioEnergyModel::m_rxCurrentA
private

receive current

Definition at line 312 of file lora-radio-energy-model.h.

Referenced by ChangeState(), DoGetCurrentA(), GetRxCurrentA(), and SetRxCurrentA().

◆ m_sleepCurrentA

double ns3::lorawan::LoraRadioEnergyModel::m_sleepCurrentA
private

sleep current

Definition at line 314 of file lora-radio-energy-model.h.

Referenced by ChangeState(), DoGetCurrentA(), GetSleepCurrentA(), and SetSleepCurrentA().

◆ m_source

Ptr<EnergySource> ns3::lorawan::LoraRadioEnergyModel::m_source
private

energy source

Definition at line 308 of file lora-radio-energy-model.h.

Referenced by LoraRadioEnergyModel(), ChangeState(), DoDispose(), and SetEnergySource().

◆ m_totalEnergyConsumption

TracedValue<double> ns3::lorawan::LoraRadioEnergyModel::m_totalEnergyConsumption
private

This variable keeps track of the total energy consumed by this model.

Definition at line 319 of file lora-radio-energy-model.h.

Referenced by ChangeState(), GetTotalEnergyConsumption(), and GetTypeId().

◆ m_txCurrentA

double ns3::lorawan::LoraRadioEnergyModel::m_txCurrentA
private

transmit current

Definition at line 311 of file lora-radio-energy-model.h.

Referenced by ChangeState(), DoGetCurrentA(), GetTxCurrentA(), SetTxCurrentA(), and SetTxCurrentFromModel().

◆ m_txCurrentModel

Ptr<LoraTxCurrentModel> ns3::lorawan::LoraRadioEnergyModel::m_txCurrentModel
private

current model

Definition at line 316 of file lora-radio-energy-model.h.

Referenced by GetTypeId(), SetTxCurrentFromModel(), and SetTxCurrentModel().


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