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!");
virtual void ChangeState(int newState)
Changes state of the AcousticModemEnergyModel.
AcousticModemEnergyModel()
Constructor.
Simulation virtual time values and global simulation resolution.
virtual ~AcousticModemEnergyModel()
Dummy destructor, see DoDispose.
virtual void HandleEnergyDepletion(void)
Handles energy depletion.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
double m_idlePowerW
The idle power, in watts.
uint32_t GetId(void) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Base class for device energy models.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
double m_rxPowerW
The receiver power, in watts.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
AcousticModemEnergyDepletionCallback m_energyDepletionCallback
Energy depletion callback.
void SetIdlePowerW(double idlePowerW)
Set the idle state power of the modem.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
bool IsStateTransitionValid(const int destState)
Ptr< Node > m_node
The node hosting this transducer.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
virtual void HandleEnergyChanged(void)
Handles energy changed.
int GetCurrentState(void) const
Get the current state of the modem.
void SetEnergyDepletionCallback(AcousticModemEnergyDepletionCallback callback)
void SetEnergyRechargeCallback(AcousticModemEnergyRechargeCallback callback)
double m_sleepPowerW
The sleep power, in watts.
void SetTxPowerW(double txPowerW)
Set the transmission power of the modem.
void SetRxPowerW(double rxPowerW)
Set the receiving power of the modem.
virtual void SetEnergySource(Ptr< EnergySource > source)
static TypeId GetTypeId(void)
Register this type.
virtual Ptr< Node > GetNode(void) const
Gets pointer to node.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
int m_currentState
Current modem state.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Ptr< EnergySource > m_source
The energy source.
void DoDispose(void)
Destructor implementation.
virtual double DoGetCurrentA(void) const
static Time Now(void)
Return the current simulation virtual time.
double GetTxPowerW(void) const
Get the transmission power of the modem.
Net device for UAN models.
double GetRxPowerW(void) const
Get the receiving power.
double GetSleepPowerW(void) const
Get the sleep state power of the modem.
virtual double GetTotalEnergyConsumption(void) const
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Time m_lastUpdateTime
Time stamp of previous energy update.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
AcousticModemEnergyRechargeCallback m_energyRechargeCallback
Energy recharge callback.
virtual void SetNode(Ptr< Node > node)
Sets pointer to node.
virtual void HandleEnergyRecharged(void)
Handles energy recharged.
void Nullify(void)
Discard the implementation, set it to null.
double GetIdlePowerW(void) const
Get the idle power of the modem.
void SetSleepPowerW(double sleepPowerW)
Set the sleep power of the modem.
bool IsNull(void) const
Check for null implementation.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
double m_txPowerW
The transmitter power, in watts.
a unique identifier for an interface.
void SetMicroModemState(const int state)
TracedValue< double > m_totalEnergyConsumption
The total energy consumed by this model.
TypeId SetParent(TypeId tid)
Set the parent TypeId.