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
virtual void ChangeState(int newState)
Changes state of the AcousticModemEnergyModel.
AcousticModemEnergyModel()
keep track of time values and allow control of global simulation resolution
virtual ~AcousticModemEnergyModel()
virtual void HandleEnergyDepletion(void)
Handles energy depletion.
#define NS_LOG_FUNCTION(parameters)
virtual double DoGetCurrentA(void) const
Base class for device energy models.
virtual double GetTotalEnergyConsumption(void) const
#define NS_ASSERT(condition)
AcousticModemEnergyDepletionCallback m_energyDepletionCallback
void SetIdlePowerW(double idlePowerW)
NS_LOG_COMPONENT_DEFINE("AcousticModemEnergyModel")
bool IsStateTransitionValid(const int destState)
#define NS_FATAL_ERROR(msg)
fatal error handling
double GetSeconds(void) const
void SetEnergyDepletionCallback(AcousticModemEnergyDepletionCallback callback)
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
void SetTxPowerW(double txPowerW)
Ptr< NetDevice > GetDevice(uint32_t index) const
void SetRxPowerW(double rxPowerW)
virtual void SetEnergySource(Ptr< EnergySource > source)
Sets pointer to EnergySouce installed on node.
static TypeId GetTypeId(void)
Ptr< EnergySource > m_source
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Net device for UAN models.
int64_t GetNanoSeconds(void) const
uint32_t GetId(void) const
double GetSleepPowerW(void) const
double GetTxPowerW(void) const
virtual Ptr< Node > GetNode(void) const
Gets pointer to node.
#define NS_LOG_DEBUG(msg)
virtual void SetNode(Ptr< Node > node)
Sets pointer to node.
void SetSleepPowerW(double sleepPowerW)
int GetCurrentState(void) const
Hold an floating point type.
double GetIdlePowerW(void) const
a unique identifier for an interface.
void SetMicroModemState(const int state)
TracedValue< double > m_totalEnergyConsumption
TypeId SetParent(TypeId tid)