14#include "ns3/double.h"
15#include "ns3/energy-source.h"
17#include "ns3/simulator.h"
18#include "ns3/trace-source-accessor.h"
31 TypeId(
"ns3::AcousticModemEnergyModel")
33 .AddConstructor<AcousticModemEnergyModel>()
34 .AddAttribute(
"TxPowerW",
35 "The modem Tx power in Watts",
40 .AddAttribute(
"RxPowerW",
41 "The modem Rx power in Watts",
46 .AddAttribute(
"IdlePowerW",
47 "The modem Idle power in Watts",
52 .AddAttribute(
"SleepPowerW",
53 "The modem Sleep power in Watts",
59 "TotalEnergyConsumption",
60 "Total energy consumption of the modem device.",
62 "ns3::TracedValueCallback::Double");
178 NS_LOG_DEBUG(
"AcousticModemEnergyModel:Setting NULL energy depletion callback!");
189 NS_LOG_DEBUG(
"AcousticModemEnergyModel:Setting NULL energy recharge callback!");
204 double energyToDecrease = 0.0;
221 energyToDecrease = 0;
224 NS_FATAL_ERROR(
"AcousticModemEnergyModel:Undefined radio state!");
243 NS_LOG_DEBUG(
"AcousticModemEnergyModel:Total energy consumption at node #"
259 dev->GetPhy()->EnergyDepletionHandler();
275 dev->GetPhy()->EnergyRechargeHandler();
304 double supplyVoltage =
m_source->GetSupplyVoltage();
306 double stateCurrent = 0.0;
325 NS_FATAL_ERROR(
"AcousticModemEnergyModel:Undefined radio state!");
345 std::string stateName;
361 stateName =
"DISABLED";
364 NS_LOG_DEBUG(
"AcousticModemEnergyModel:Switching to state: " << stateName <<
" at time = "
369 NS_FATAL_ERROR(
"AcousticModemEnergyModel:Invalid state transition!");
double GetTotalEnergyConsumption() const override
void SetEnergyRechargeCallback(AcousticModemEnergyRechargeCallback callback)
double m_rxPowerW
The receiver power, in watts.
double m_idlePowerW
The idle power, in watts.
void SetRxPowerW(double rxPowerW)
Set the receiving power of the modem.
Time m_lastUpdateTime
Time stamp of previous energy update.
void HandleEnergyRecharged() override
Handles energy recharged.
static TypeId GetTypeId()
Register this type.
double m_txPowerW
The transmitter power, in watts.
TracedValue< double > m_totalEnergyConsumption
The total energy consumed by this model.
void SetEnergySource(Ptr< energy::EnergySource > source) override
void SetMicroModemState(const int state)
virtual Ptr< Node > GetNode() const
Gets pointer to node.
void HandleEnergyDepletion() override
Handles energy depletion.
virtual void SetNode(Ptr< Node > node)
Sets pointer to node.
~AcousticModemEnergyModel() override
Dummy destructor, see DoDispose.
double DoGetCurrentA() const override
int m_currentState
Current modem state.
AcousticModemEnergyModel()
Constructor.
AcousticModemEnergyDepletionCallback m_energyDepletionCallback
Energy depletion callback.
double GetTxPowerW() const
Get the transmission power of the modem.
void ChangeState(int newState) override
Changes state of the AcousticModemEnergyModel.
void SetIdlePowerW(double idlePowerW)
Set the idle state power of the modem.
Ptr< energy::EnergySource > m_source
The energy source.
void DoDispose() override
Destructor implementation.
double m_sleepPowerW
The sleep power, in watts.
void SetSleepPowerW(double sleepPowerW)
Set the sleep power of the modem.
void SetEnergyDepletionCallback(AcousticModemEnergyDepletionCallback callback)
double GetRxPowerW() const
Get the receiving power.
double GetSleepPowerW() const
Get the sleep state power of the modem.
double GetIdlePowerW() const
Get the idle power of the modem.
int GetCurrentState() const
Get the current state of the modem.
AcousticModemEnergyRechargeCallback m_energyRechargeCallback
Energy recharge callback.
void SetTxPowerW(double txPowerW)
Set the transmission power of the modem.
void HandleEnergyChanged() override
Handles energy changed.
bool IsStateTransitionValid(const int destState)
Ptr< Node > m_node
The node hosting this transducer.
void Nullify()
Discard the implementation, set it to null.
bool IsNull() const
Check for null implementation.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Net device for UAN models.
Base class for device energy models.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeDoubleChecker()
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)