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"
40 static TypeId tid =
TypeId (
"ns3::AcousticModemEnergyModel")
42 .AddConstructor<AcousticModemEnergyModel> ()
43 .AddAttribute (
"TxPowerW",
44 "The modem Tx power in Watts",
48 MakeDoubleChecker<double> ())
49 .AddAttribute (
"RxPowerW",
50 "The modem Rx power in Watts",
54 MakeDoubleChecker<double> ())
55 .AddAttribute (
"IdlePowerW",
56 "The modem Idle power in Watts",
60 MakeDoubleChecker<double> ())
61 .AddAttribute (
"SleepPowerW",
62 "The modem Sleep power in Watts",
66 MakeDoubleChecker<double> ())
67 .AddTraceSource (
"TotalEnergyConsumption",
68 "Total energy consumption of the modem device.",
187 NS_LOG_DEBUG (
"AcousticModemEnergyModel:Setting NULL energy depletion callback!");
202 double energyToDecrease = 0.0;
203 double supplyVoltage =
m_source->GetSupplyVoltage ();
219 NS_FATAL_ERROR (
"AcousticModemEnergyModel:Undefined radio state!");
235 NS_LOG_DEBUG (
"AcousticModemEnergyModel:Total energy consumption at node #" <<
243 NS_LOG_DEBUG (
"AcousticModemEnergyModel:Energy is depleted at node #" <<
252 dev->GetPhy ()->EnergyDepletionHandler ();
273 double supplyVoltage =
m_source->GetSupplyVoltage ();
275 double stateCurrent = 0.0;
291 NS_FATAL_ERROR (
"AcousticModemEnergyModel:Undefined radio state!");
311 std::string stateName;
327 NS_LOG_DEBUG (
"AcousticModemEnergyModel:Switching to state: " << stateName <<
332 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.
keep track of time values and allow control of global simulation resolution
virtual ~AcousticModemEnergyModel()
Dummy destructor, see DoDispose.
virtual void HandleEnergyDepletion(void)
Handles energy depletion.
#define NS_LOG_FUNCTION(parameters)
virtual double DoGetCurrentA(void) const
double m_idlePowerW
The idle power, in watts.
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)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
AcousticModemEnergyDepletionCallback m_energyDepletionCallback
Energy depletion callback.
void SetIdlePowerW(double idlePowerW)
Set the idle state power of the modem.
NS_LOG_COMPONENT_DEFINE("AcousticModemEnergyModel")
bool IsStateTransitionValid(const int destState)
Ptr< Node > m_node
The node hosting this transducer.
#define NS_FATAL_ERROR(msg)
fatal error handling
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)
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)