25 #include "ns3/double.h"
26 #include "ns3/energy-source.h"
28 #include "ns3/simulator.h"
29 #include "ns3/trace-source-accessor.h"
42 TypeId(
"ns3::AcousticModemEnergyModel")
44 .AddConstructor<AcousticModemEnergyModel>()
45 .AddAttribute(
"TxPowerW",
46 "The modem Tx power in Watts",
50 MakeDoubleChecker<double>())
51 .AddAttribute(
"RxPowerW",
52 "The modem Rx power in Watts",
56 MakeDoubleChecker<double>())
57 .AddAttribute(
"IdlePowerW",
58 "The modem Idle power in Watts",
62 MakeDoubleChecker<double>())
63 .AddAttribute(
"SleepPowerW",
64 "The modem Sleep power in Watts",
68 MakeDoubleChecker<double>())
70 "TotalEnergyConsumption",
71 "Total energy consumption of the modem device.",
73 "ns3::TracedValueCallback::Double");
189 NS_LOG_DEBUG(
"AcousticModemEnergyModel:Setting NULL energy depletion callback!");
200 NS_LOG_DEBUG(
"AcousticModemEnergyModel:Setting NULL energy recharge callback!");
215 double energyToDecrease = 0.0;
232 energyToDecrease = 0;
235 NS_FATAL_ERROR(
"AcousticModemEnergyModel:Undefined radio state!");
254 NS_LOG_DEBUG(
"AcousticModemEnergyModel:Total energy consumption at node #"
270 dev->GetPhy()->EnergyDepletionHandler();
286 dev->GetPhy()->EnergyRechargeHandler();
315 double supplyVoltage =
m_source->GetSupplyVoltage();
317 double stateCurrent = 0.0;
336 NS_FATAL_ERROR(
"AcousticModemEnergyModel:Undefined radio state!");
356 std::string stateName;
372 stateName =
"DISABLED";
375 NS_LOG_DEBUG(
"AcousticModemEnergyModel:Switching to state: " << stateName <<
" at time = "
380 NS_FATAL_ERROR(
"AcousticModemEnergyModel:Invalid state transition!");
double GetTotalEnergyConsumption() const override
Ptr< EnergySource > m_source
The energy source.
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 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.
void SetEnergySource(Ptr< EnergySource > source) override
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.
Base class for device energy models.
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.
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.
#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 AttributeAccessor > MakeDoubleAccessor(T1 a1)