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.",
186 NS_LOG_DEBUG (
"AcousticModemEnergyModel:Setting NULL energy depletion callback!");
201 double energyToDecrease = 0.0;
202 double supplyVoltage =
m_source->GetSupplyVoltage ();
218 NS_FATAL_ERROR (
"AcousticModemEnergyModel:Undefined radio state!");
234 NS_LOG_DEBUG (
"AcousticModemEnergyModel:Total energy consumption at node #" <<
242 NS_LOG_DEBUG (
"AcousticModemEnergyModel:Energy is depleted at node #" <<
251 dev->GetPhy ()->EnergyDepletionHandler ();
272 double supplyVoltage =
m_source->GetSupplyVoltage ();
274 double stateCurrent = 0.0;
290 NS_FATAL_ERROR (
"AcousticModemEnergyModel:Undefined radio state!");
310 std::string stateName;
326 NS_LOG_DEBUG (
"AcousticModemEnergyModel:Switching to state: " << stateName <<
331 NS_FATAL_ERROR (
"AcousticModemEnergyModel:Invalid state transition!");
double GetRxPowerW(void) const
Get the recieving power.
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 "...
virtual double DoGetCurrentA(void) const
double m_idlePowerW
The idle power, in watts.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Base class for device energy models.
virtual double GetTotalEnergyConsumption(void) const
double m_rxPowerW
The receiver power, in watts.
bool IsNull(void) const
Check for null implementation.
#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)
fatal error handling
bool IsStateTransitionValid(const int destState)
Ptr< Node > m_node
The node hosting this transducer.
double GetSeconds(void) const
void SetEnergyDepletionCallback(AcousticModemEnergyDepletionCallback callback)
double m_sleepPowerW
The sleep power, in watts.
void SetTxPowerW(double txPowerW)
Set the transmission power of the modem.
Ptr< NetDevice > GetDevice(uint32_t index) const
void SetRxPowerW(double rxPowerW)
Set the receiving power of the modem.
virtual void SetEnergySource(Ptr< EnergySource > source)
static TypeId GetTypeId(void)
Register this type.
int m_currentState
Current modem state.
Ptr< EnergySource > m_source
The energy source.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
static Time Now(void)
Return the "current simulation time".
Net device for UAN models.
int64_t GetNanoSeconds(void) const
uint32_t GetId(void) const
double GetSleepPowerW(void) const
Get the sleep state power of the modem.
double GetTxPowerW(void) const
Get the transmission power of the modem.
virtual Ptr< Node > GetNode(void) const
Gets pointer to node.
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.
virtual void SetNode(Ptr< Node > node)
Sets pointer to node.
void Nullify(void)
Discard the implementation, set it to null.
void SetSleepPowerW(double sleepPowerW)
Set the sleep power of the modem.
int GetCurrentState(void) const
Get the current state of the modem.
Hold a floating point type.
double m_txPowerW
The transmitter power, in watts.
double GetIdlePowerW(void) const
Get the idle power of the modem.
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)