A LoRa radio energy model. More...
#include "lora-radio-energy-model.h"
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 |
LoraRadioEnergyModelPhyListener * | GetPhyListener () |
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< 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) 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 | |
LoraRadioEnergyModelPhyListener * | m_listener |
EndDeviceLoraPhy listener. | |
uint8_t | m_nPendingChangeState |
pending state change | |
double | m_rxCurrentA |
receive current | |
double | m_sleepCurrentA |
sleep current | |
Ptr< EnergySource > | m_source |
energy source | |
TracedValue< double > | m_totalEnergyConsumption |
This variable keeps track of the total energy consumed by this model. | |
double | m_txCurrentA |
transmit current | |
Ptr< LoraTxCurrentModel > | m_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. | |
Related Functions inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
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:
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.
Callback type for energy depletion handling.
Definition at line 139 of file lora-radio-energy-model.h.
Callback type for energy recharged handling.
Definition at line 144 of file lora-radio-energy-model.h.
ns3::lorawan::LoraRadioEnergyModel::LoraRadioEnergyModel | ( | ) |
Definition at line 81 of file lora-radio-energy-model.cc.
References ns3::energy::DeviceEnergyModel::ChangeState(), m_currentState, m_energyDepletionCallback, m_isSupersededChangeState, m_lastUpdateTime, m_listener, m_nPendingChangeState, m_source, ns3::MakeCallback(), NS_LOG_FUNCTION, ns3::Callback< R, UArgs >::Nullify(), ns3::Seconds(), ns3::lorawan::LoraRadioEnergyModelPhyListener::SetChangeStateCallback(), SetTxCurrentFromModel(), ns3::lorawan::LoraRadioEnergyModelPhyListener::SetUpdateTxCurrentCallback(), and ns3::lorawan::EndDeviceLoraPhy::SLEEP.
|
override |
Destructor.
Definition at line 98 of file lora-radio-energy-model.cc.
References m_listener, and NS_LOG_FUNCTION.
|
overridevirtual |
Changes state of the LoraRadioEnergyMode.
newState | New state the lora radio is in. |
Implements DeviceEnergyModel::ChangeState.
Implements ns3::energy::DeviceEnergyModel.
Definition at line 220 of file lora-radio-energy-model.cc.
References ns3::Time::GetNanoSeconds(), ns3::Time::GetSeconds(), m_currentState, m_idleCurrentA, m_isSupersededChangeState, m_lastUpdateTime, m_nPendingChangeState, m_rxCurrentA, m_sleepCurrentA, m_source, m_totalEnergyConsumption, m_txCurrentA, ns3::Simulator::Now(), NS_ASSERT, NS_FATAL_ERROR, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::lorawan::EndDeviceLoraPhy::RX, SetLoraRadioState(), ns3::lorawan::EndDeviceLoraPhy::SLEEP, ns3::lorawan::EndDeviceLoraPhy::STANDBY, and ns3::lorawan::EndDeviceLoraPhy::TX.
|
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().
|
overrideprivatevirtual |
Implements DeviceEnergyModel::GetCurrentA.
Reimplemented from ns3::energy::DeviceEnergyModel.
Definition at line 332 of file lora-radio-energy-model.cc.
References m_currentState, m_idleCurrentA, m_rxCurrentA, m_sleepCurrentA, m_txCurrentA, NS_FATAL_ERROR, NS_LOG_FUNCTION, ns3::lorawan::EndDeviceLoraPhy::RX, ns3::lorawan::EndDeviceLoraPhy::SLEEP, ns3::lorawan::EndDeviceLoraPhy::STANDBY, and ns3::lorawan::EndDeviceLoraPhy::TX.
EndDeviceLoraPhy::State ns3::lorawan::LoraRadioEnergyModel::GetCurrentState | ( | ) | const |
Definition at line 176 of file lora-radio-energy-model.cc.
References m_currentState, and NS_LOG_FUNCTION.
LoraRadioEnergyModelPhyListener * ns3::lorawan::LoraRadioEnergyModel::GetPhyListener | ( | ) |
Definition at line 313 of file lora-radio-energy-model.cc.
References m_listener, and NS_LOG_FUNCTION.
double ns3::lorawan::LoraRadioEnergyModel::GetRxCurrentA | ( | ) | const |
Gets receive current.
Definition at line 148 of file lora-radio-energy-model.cc.
References m_rxCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
double ns3::lorawan::LoraRadioEnergyModel::GetSleepCurrentA | ( | ) | const |
Gets sleep current.
Definition at line 162 of file lora-radio-energy-model.cc.
References m_sleepCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
double ns3::lorawan::LoraRadioEnergyModel::GetStandbyCurrentA | ( | ) | const |
Gets idle current.
Definition at line 120 of file lora-radio-energy-model.cc.
References m_idleCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
overridevirtual |
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.
double ns3::lorawan::LoraRadioEnergyModel::GetTxCurrentA | ( | ) | const |
Gets transmit current.
Definition at line 134 of file lora-radio-energy-model.cc.
References m_txCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
static |
Register this type.
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().
|
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.
|
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.
|
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.
void ns3::lorawan::LoraRadioEnergyModel::SetEnergyDepletionCallback | ( | LoraRadioEnergyDepletionCallback | callback | ) |
callback | Callback 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.
void ns3::lorawan::LoraRadioEnergyModel::SetEnergyRechargedCallback | ( | LoraRadioEnergyRechargedCallback | callback | ) |
callback | Callback 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.
|
overridevirtual |
Sets pointer to EnergySouce installed on node.
source | Pointer 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.
|
private |
state | New 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().
void ns3::lorawan::LoraRadioEnergyModel::SetRxCurrentA | ( | double | rxCurrentA | ) |
Sets receive current.
rxCurrentA | The receive current [A]. |
Definition at line 155 of file lora-radio-energy-model.cc.
References m_rxCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::lorawan::LoraRadioEnergyModel::SetSleepCurrentA | ( | double | sleepCurrentA | ) |
Sets sleep current.
sleepCurrentA | The sleep current [A]. |
Definition at line 169 of file lora-radio-energy-model.cc.
References m_sleepCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::lorawan::LoraRadioEnergyModel::SetStandbyCurrentA | ( | double | idleCurrentA | ) |
Sets idle current.
idleCurrentA | The idle current [A]. |
Definition at line 127 of file lora-radio-energy-model.cc.
References m_idleCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::lorawan::LoraRadioEnergyModel::SetTxCurrentA | ( | double | txCurrentA | ) |
Sets transmit current.
txCurrentA | The transmit current [A]. |
Definition at line 141 of file lora-radio-energy-model.cc.
References m_txCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
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.
txPowerDbm | The 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().
void ns3::lorawan::LoraRadioEnergyModel::SetTxCurrentModel | ( | Ptr< LoraTxCurrentModel > | model | ) |
model | The model used to compute the lora tx current. |
Definition at line 205 of file lora-radio-energy-model.cc.
References m_txCurrentModel.
|
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().
|
private |
Energy depletion callback.
Definition at line 329 of file lora-radio-energy-model.h.
Referenced by LoraRadioEnergyModel(), DoDispose(), HandleEnergyDepletion(), and SetEnergyDepletionCallback().
|
private |
Energy recharged callback.
Definition at line 332 of file lora-radio-energy-model.h.
Referenced by HandleEnergyRecharged(), and SetEnergyRechargedCallback().
|
private |
idle current
Definition at line 313 of file lora-radio-energy-model.h.
Referenced by ChangeState(), DoGetCurrentA(), GetStandbyCurrentA(), and SetStandbyCurrentA().
|
private |
superseded change state
Definition at line 326 of file lora-radio-energy-model.h.
Referenced by LoraRadioEnergyModel(), and ChangeState().
|
private |
time stamp of previous energy update
Definition at line 323 of file lora-radio-energy-model.h.
Referenced by LoraRadioEnergyModel(), and ChangeState().
|
private |
EndDeviceLoraPhy listener.
Definition at line 335 of file lora-radio-energy-model.h.
Referenced by LoraRadioEnergyModel(), ~LoraRadioEnergyModel(), and GetPhyListener().
|
private |
pending state change
Definition at line 325 of file lora-radio-energy-model.h.
Referenced by LoraRadioEnergyModel(), and ChangeState().
|
private |
receive current
Definition at line 312 of file lora-radio-energy-model.h.
Referenced by ChangeState(), DoGetCurrentA(), GetRxCurrentA(), and SetRxCurrentA().
|
private |
sleep current
Definition at line 314 of file lora-radio-energy-model.h.
Referenced by ChangeState(), DoGetCurrentA(), GetSleepCurrentA(), and SetSleepCurrentA().
|
private |
energy source
Definition at line 308 of file lora-radio-energy-model.h.
Referenced by LoraRadioEnergyModel(), ChangeState(), DoDispose(), and SetEnergySource().
|
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().
|
private |
transmit current
Definition at line 311 of file lora-radio-energy-model.h.
Referenced by ChangeState(), DoGetCurrentA(), GetTxCurrentA(), SetTxCurrentA(), and SetTxCurrentFromModel().
|
private |
current model
Definition at line 316 of file lora-radio-energy-model.h.
Referenced by GetTypeId(), SetTxCurrentFromModel(), and SetTxCurrentModel().