A BLE radio energy model. More...
#include "ble-radio-energy-model.h"
Public Types | |
typedef Callback< void > | BleRadioEnergyDepletionCallback |
Callback type for energy depletion handling. More... | |
typedef Callback< void > | BleRadioEnergyRechargedCallback |
Callback for energy recharged handling. More... | |
Public Types inherited from ns3::DeviceEnergyModel | |
typedef Callback< void, int > | ChangeStateCallback |
Callback type for ChangeState function. More... | |
Public Member Functions | |
BleRadioEnergyModel () | |
virtual | ~BleRadioEnergyModel () |
virtual void | ChangeState (int newState) |
Changes state of the BleRadioEnergyMode. More... | |
void | ChangeState (BlePhy::BlePhyState oldState, BlePhy::BlePhyState newState) |
BlePhy::BlePhyState | GetCurrentState (void) const |
double | GetIdleCurrentA (void) const |
double | GetOffCurrentA (void) const |
double | GetRxCurrentA (void) const |
virtual double | GetTotalEnergyConsumption (void) const |
double | GetTxCurrentA (void) const |
virtual void | HandleEnergyDepletion (void) |
Handles energy depletion. More... | |
virtual void | HandleEnergyRecharged (void) |
Handles energy recharged. More... | |
void | SetEnergyDepletionCallback (BleRadioEnergyDepletionCallback callback) |
void | SetEnergyRechargedCallback (BleRadioEnergyRechargedCallback callback) |
virtual void | SetEnergySource (Ptr< EnergySource > source) |
Sets pointer to Energy Source instaleld on node. More... | |
void | SetIdleCurrentA (double idleCurrentA) |
void | SetOffCurrentA (double offCurrentA) |
virtual void | SetPhy (Ptr< BlePhy > phy) |
Sets pointer to PHY on node. More... | |
void | SetRxCurrentA (double rxCurrentA) |
void | SetTxCurrentA (double txCurrentA) |
Public Member Functions inherited from ns3::DeviceEnergyModel | |
DeviceEnergyModel () | |
virtual | ~DeviceEnergyModel () |
double | GetCurrentA (void) const |
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... | |
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 |
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::DeviceEnergyModel | |
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 | DoDispose (void) |
Destructor implementation. More... | |
virtual double | DoGetCurrentA (void) const |
void | SetBleRadioState (const BlePhy::BlePhyState state) |
Private Attributes | |
BlePhy::BlePhyState | m_currentState |
BleRadioEnergyDepletionCallback | m_energyDepletionCallback |
BleRadioEnergyRechargedCallback | m_energyRechargedCallback |
double | m_idleCurrentA |
bool | m_isSupersededChangeState |
Time | m_lastUpdateTime |
uint8_t | m_nPendingChangeState |
double | m_offCurrentA |
Ptr< BlePhy > | m_phy |
double | m_rxCurrentA |
Ptr< EnergySource > | m_source |
TracedValue< double > | m_totalEnergyConsumption |
double | m_txCurrentA |
Additional Inherited Members | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
Copy an Object. More... | |
virtual void | DoInitialize (void) |
Initialize() implementation. 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... | |
Related Functions inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid (void) |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. More... | |
A BLE radio energy model.
Introspection did not find any typical Config paths.
4 states are defined for the radio: BUSY_TX, BUSY_RX, IDLE. Default state is IDLE.
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.
Specifications of
Size of this type is 144 bytes (on a 64-bit architecture).
Definition at line 55 of file ble-radio-energy-model.h.
Callback type for energy depletion handling.
Definition at line 61 of file ble-radio-energy-model.h.
Callback for energy recharged handling.
Definition at line 65 of file ble-radio-energy-model.h.
ns3::BleRadioEnergyModel::BleRadioEnergyModel | ( | ) |
Definition at line 75 of file ble-radio-energy-model.cc.
References ns3::BlePhy::IDLE, m_currentState, m_energyDepletionCallback, m_isSupersededChangeState, m_lastUpdateTime, m_nPendingChangeState, m_source, NS_LOG_FUNCTION, ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::Nullify(), and ns3::Seconds().
|
virtual |
Definition at line 86 of file ble-radio-energy-model.cc.
References NS_LOG_FUNCTION.
|
virtual |
Changes state of the BleRadioEnergyMode.
newState | New state the ble radio is in. |
Implements DeviceEnergyModel::ChangeState.
Implements ns3::DeviceEnergyModel.
Definition at line 206 of file ble-radio-energy-model.cc.
References ns3::BlePhy::BUSY_RX, ns3::BlePhy::BUSY_TX, ns3::Time::GetNanoSeconds(), ns3::Time::GetSeconds(), ns3::BlePhy::IDLE, ns3::BlePhy::LISTEN, m_currentState, m_idleCurrentA, m_isSupersededChangeState, m_lastUpdateTime, m_nPendingChangeState, m_offCurrentA, m_rxCurrentA, m_source, m_totalEnergyConsumption, m_txCurrentA, ns3::Simulator::Now(), NS_ASSERT, NS_FATAL_ERROR, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::BlePhy::OFF, SetBleRadioState(), and ns3::BlePhy::TRANS.
Referenced by ChangeState(), and ns3::BleRadioEnergyModelHelper::DoInstall().
void ns3::BleRadioEnergyModel::ChangeState | ( | BlePhy::BlePhyState | oldState, |
BlePhy::BlePhyState | newState | ||
) |
Definition at line 199 of file ble-radio-energy-model.cc.
References ChangeState(), and NS_LOG_FUNCTION.
|
privatevirtual |
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 overriden 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 298 of file ble-radio-energy-model.cc.
References m_energyDepletionCallback, m_source, NS_LOG_FUNCTION, and ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::Nullify().
|
privatevirtual |
Implements DeviceEnergyModel::GetCurrentA.
Reimplemented from ns3::DeviceEnergyModel.
Definition at line 306 of file ble-radio-energy-model.cc.
References ns3::BlePhy::BUSY_RX, ns3::BlePhy::BUSY_TX, ns3::BlePhy::IDLE, ns3::BlePhy::LISTEN, m_currentState, m_idleCurrentA, m_offCurrentA, m_rxCurrentA, m_txCurrentA, NS_FATAL_ERROR, NS_LOG_FUNCTION, ns3::BlePhy::OFF, and ns3::BlePhy::TRANS.
BlePhy::BlePhyState ns3::BleRadioEnergyModel::GetCurrentState | ( | void | ) | const |
Definition at line 168 of file ble-radio-energy-model.cc.
References m_currentState, and NS_LOG_FUNCTION.
double ns3::BleRadioEnergyModel::GetIdleCurrentA | ( | void | ) | const |
Definition at line 127 of file ble-radio-energy-model.cc.
References m_idleCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
double ns3::BleRadioEnergyModel::GetOffCurrentA | ( | void | ) | const |
Definition at line 114 of file ble-radio-energy-model.cc.
References m_offCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
double ns3::BleRadioEnergyModel::GetRxCurrentA | ( | void | ) | const |
Definition at line 154 of file ble-radio-energy-model.cc.
References m_rxCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
virtual |
Implements ns3::DeviceEnergyModel.
Definition at line 107 of file ble-radio-energy-model.cc.
References m_totalEnergyConsumption, and NS_LOG_FUNCTION.
double ns3::BleRadioEnergyModel::GetTxCurrentA | ( | void | ) | const |
Definition at line 140 of file ble-radio-energy-model.cc.
References m_txCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
static |
Definition at line 36 of file ble-radio-energy-model.cc.
References GetIdleCurrentA(), GetOffCurrentA(), GetRxCurrentA(), GetTxCurrentA(), m_totalEnergyConsumption, ns3::MakeDoubleAccessor(), ns3::MakeTraceSourceAccessor(), SetIdleCurrentA(), SetOffCurrentA(), ns3::TypeId::SetParent(), SetRxCurrentA(), and SetTxCurrentA().
|
virtual |
Handles energy depletion.
Implements DeviceEnergyModel::HandleEnergyDepletion
Implements ns3::DeviceEnergyModel.
Definition at line 270 of file ble-radio-energy-model.cc.
References ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::IsNull(), m_energyDepletionCallback, NS_LOG_DEBUG, and NS_LOG_FUNCTION.
|
virtual |
Handles energy recharged.
Implements DeviceEnergyModel::HandleEnergyRecharged
Implements ns3::DeviceEnergyModel.
Definition at line 282 of file ble-radio-energy-model.cc.
References ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::IsNull(), m_energyRechargedCallback, NS_LOG_DEBUG, 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 327 of file ble-radio-energy-model.cc.
References ns3::BlePhy::BUSY_RX, ns3::BlePhy::BUSY_TX, ns3::BlePhy::IDLE, ns3::BlePhy::LISTEN, m_currentState, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::BlePhy::OFF, and ns3::BlePhy::TRANS.
Referenced by ChangeState().
void ns3::BleRadioEnergyModel::SetEnergyDepletionCallback | ( | BleRadioEnergyDepletionCallback | callback | ) |
callback | Callback function Sets callback for energy depletion handling |
Definition at line 175 of file ble-radio-energy-model.cc.
References ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::IsNull(), m_energyDepletionCallback, NS_LOG_DEBUG, and NS_LOG_FUNCTION.
void ns3::BleRadioEnergyModel::SetEnergyRechargedCallback | ( | BleRadioEnergyRechargedCallback | callback | ) |
callback | Callback function. |
Sets callback for energy recharged handling.
Definition at line 187 of file ble-radio-energy-model.cc.
References ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::IsNull(), m_energyRechargedCallback, NS_LOG_DEBUG, and NS_LOG_FUNCTION.
|
virtual |
Sets pointer to Energy Source instaleld on node.
source | Pointer to Energy Source installed on node. Implements DeviceEnergyModel::SetEnergySource |
Implements ns3::DeviceEnergyModel.
Definition at line 99 of file ble-radio-energy-model.cc.
References m_source, NS_ASSERT, and NS_LOG_FUNCTION.
void ns3::BleRadioEnergyModel::SetIdleCurrentA | ( | double | idleCurrentA | ) |
Definition at line 133 of file ble-radio-energy-model.cc.
References m_idleCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::BleRadioEnergyModel::SetOffCurrentA | ( | double | offCurrentA | ) |
Definition at line 120 of file ble-radio-energy-model.cc.
References m_offCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
Sets pointer to PHY on node.
phy | Pointer to PHY installed on node. |
Definition at line 92 of file ble-radio-energy-model.cc.
References m_phy, NS_ASSERT, NS_LOG_FUNCTION, and third::phy.
void ns3::BleRadioEnergyModel::SetRxCurrentA | ( | double | rxCurrentA | ) |
Definition at line 161 of file ble-radio-energy-model.cc.
References m_rxCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::BleRadioEnergyModel::SetTxCurrentA | ( | double | txCurrentA | ) |
Definition at line 147 of file ble-radio-energy-model.cc.
References m_txCurrentA, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
private |
Definition at line 173 of file ble-radio-energy-model.h.
Referenced by BleRadioEnergyModel(), ChangeState(), DoGetCurrentA(), GetCurrentState(), and SetBleRadioState().
|
private |
Definition at line 180 of file ble-radio-energy-model.h.
Referenced by BleRadioEnergyModel(), DoDispose(), HandleEnergyDepletion(), and SetEnergyDepletionCallback().
|
private |
Definition at line 183 of file ble-radio-energy-model.h.
Referenced by HandleEnergyRecharged(), and SetEnergyRechargedCallback().
|
private |
Definition at line 167 of file ble-radio-energy-model.h.
Referenced by ChangeState(), DoGetCurrentA(), GetIdleCurrentA(), and SetIdleCurrentA().
|
private |
Definition at line 177 of file ble-radio-energy-model.h.
Referenced by BleRadioEnergyModel(), and ChangeState().
|
private |
Definition at line 174 of file ble-radio-energy-model.h.
Referenced by BleRadioEnergyModel(), and ChangeState().
|
private |
Definition at line 176 of file ble-radio-energy-model.h.
Referenced by BleRadioEnergyModel(), and ChangeState().
|
private |
Definition at line 166 of file ble-radio-energy-model.h.
Referenced by ChangeState(), DoGetCurrentA(), GetOffCurrentA(), and SetOffCurrentA().
Definition at line 186 of file ble-radio-energy-model.h.
Referenced by SetPhy().
|
private |
Definition at line 165 of file ble-radio-energy-model.h.
Referenced by ChangeState(), DoGetCurrentA(), GetRxCurrentA(), and SetRxCurrentA().
|
private |
Definition at line 161 of file ble-radio-energy-model.h.
Referenced by BleRadioEnergyModel(), ChangeState(), DoDispose(), and SetEnergySource().
|
private |
Definition at line 170 of file ble-radio-energy-model.h.
Referenced by ChangeState(), GetTotalEnergyConsumption(), and GetTypeId().
|
private |
Definition at line 164 of file ble-radio-energy-model.h.
Referenced by ChangeState(), DoGetCurrentA(), GetTxCurrentA(), and SetTxCurrentA().