22 #include "ns3/double.h"
23 #include "ns3/simulator.h"
24 #include "ns3/trace-source-accessor.h"
25 #include "ns3/energy-source.h"
26 #include "ns3/uan-phy.h"
27 #include "ns3/uan-net-device.h"
39 static TypeId tid =
TypeId (
"ns3::AcousticModemEnergyModel")
41 .AddConstructor<AcousticModemEnergyModel> ()
42 .AddAttribute (
"TxPowerW",
43 "The modem Tx power in Watts",
47 MakeDoubleChecker<double> ())
48 .AddAttribute (
"RxPowerW",
49 "The modem Rx power in Watts",
53 MakeDoubleChecker<double> ())
54 .AddAttribute (
"IdlePowerW",
55 "The modem Idle power in Watts",
59 MakeDoubleChecker<double> ())
60 .AddAttribute (
"SleepPowerW",
61 "The modem Sleep power in Watts",
65 MakeDoubleChecker<double> ())
66 .AddTraceSource (
"TotalEnergyConsumption",
67 "Total energy consumption of the modem device.",
69 "ns3::TracedValueCallback::Double")
187 NS_LOG_DEBUG (
"AcousticModemEnergyModel:Setting NULL energy depletion callback!");
199 NS_LOG_DEBUG (
"AcousticModemEnergyModel:Setting NULL energy recharge callback!");
214 double energyToDecrease = 0.0;
231 energyToDecrease = 0;
234 NS_FATAL_ERROR (
"AcousticModemEnergyModel:Undefined radio state!");
253 NS_LOG_DEBUG (
"AcousticModemEnergyModel:Total energy consumption at node #" <<
261 NS_LOG_DEBUG (
"AcousticModemEnergyModel:Energy is depleted at node #" <<
270 dev->GetPhy ()->EnergyDepletionHandler ();
278 NS_LOG_DEBUG (
"AcousticModemEnergyModel:Energy is recharged at node #" <<
287 dev->GetPhy ()->EnergyRechargeHandler ();
317 double supplyVoltage =
m_source->GetSupplyVoltage ();
319 double stateCurrent = 0.0;
338 NS_FATAL_ERROR (
"AcousticModemEnergyModel:Undefined radio state!");
358 std::string stateName;
374 stateName =
"DISABLED";
377 NS_LOG_DEBUG (
"AcousticModemEnergyModel:Switching to state: " << stateName <<
382 NS_FATAL_ERROR (
"AcousticModemEnergyModel:Invalid state transition!");
Ptr< EnergySource > m_source
The energy source.
void SetEnergyRechargeCallback(AcousticModemEnergyRechargeCallback callback)
double m_rxPowerW
The receiver power, in watts.
double GetRxPowerW(void) const
Get the receiving power.
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 DoDispose(void)
Destructor implementation.
double m_txPowerW
The transmitter power, in watts.
double GetIdlePowerW(void) const
Get the idle power of the modem.
TracedValue< double > m_totalEnergyConsumption
The total energy consumed by this model.
void SetMicroModemState(const int state)
virtual void SetNode(Ptr< Node > node)
Sets pointer to node.
virtual double DoGetCurrentA(void) const
virtual ~AcousticModemEnergyModel()
Dummy destructor, see DoDispose.
int m_currentState
Current modem state.
static TypeId GetTypeId(void)
Register this type.
AcousticModemEnergyModel()
Constructor.
virtual double GetTotalEnergyConsumption(void) const
AcousticModemEnergyDepletionCallback m_energyDepletionCallback
Energy depletion callback.
double GetSleepPowerW(void) const
Get the sleep state power of the modem.
void SetIdlePowerW(double idlePowerW)
Set the idle state power of the modem.
virtual void HandleEnergyDepletion(void)
Handles energy depletion.
virtual void HandleEnergyRecharged(void)
Handles energy recharged.
double m_sleepPowerW
The sleep power, in watts.
virtual void ChangeState(int newState)
Changes state of the AcousticModemEnergyModel.
void SetSleepPowerW(double sleepPowerW)
Set the sleep power of the modem.
void SetEnergyDepletionCallback(AcousticModemEnergyDepletionCallback callback)
virtual Ptr< Node > GetNode(void) const
Gets pointer to node.
AcousticModemEnergyRechargeCallback m_energyRechargeCallback
Energy recharge callback.
void SetTxPowerW(double txPowerW)
Set the transmission power of the modem.
virtual void SetEnergySource(Ptr< EnergySource > source)
int GetCurrentState(void) const
Get the current state of the modem.
bool IsStateTransitionValid(const int destState)
double GetTxPowerW(void) const
Get the transmission power of the modem.
virtual void HandleEnergyChanged(void)
Handles energy changed.
Ptr< Node > m_node
The node hosting this transducer.
bool IsNull(void) const
Check for null implementation.
void Nullify(void)
Discard the implementation, set it to null.
Base class for device energy models.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
uint32_t GetId(void) const
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
static Time Now(void)
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
int64_t GetNanoSeconds(void) 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,...
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#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.