22 #include "ns3/double.h"
23 #include "ns3/simulator.h"
24 #include "ns3/trace-source-accessor.h"
39 .AddConstructor<WifiRadioEnergyModel> ()
40 .AddAttribute (
"IdleCurrentA",
41 "The default radio Idle current in Ampere.",
45 MakeDoubleChecker<double> ())
46 .AddAttribute (
"CcaBusyCurrentA",
47 "The default radio CCA Busy State current in Ampere.",
51 MakeDoubleChecker<double> ())
52 .AddAttribute (
"TxCurrentA",
53 "The radio Tx current in Ampere.",
57 MakeDoubleChecker<double> ())
58 .AddAttribute (
"RxCurrentA",
59 "The radio Rx current in Ampere.",
63 MakeDoubleChecker<double> ())
64 .AddAttribute (
"SwitchingCurrentA",
65 "The default radio Channel Switch current in Ampere.",
69 MakeDoubleChecker<double> ())
70 .AddTraceSource (
"TotalEnergyConsumption",
71 "Total energy consumption of the radio device.",
195 NS_LOG_DEBUG (
"WifiRadioEnergyModel:Setting NULL energy depletion callback!");
209 double energyToDecrease = 0.0;
210 double supplyVoltage =
m_source->GetSupplyVoltage ();
245 NS_LOG_DEBUG (
"WifiRadioEnergyModel:Total energy consumption is " <<
253 NS_LOG_DEBUG (
"WifiRadioEnergyModel:Energy is depleted!");
306 std::string stateName;
313 stateName =
"CCA_BUSY";
322 stateName =
"SWITCHING";
325 NS_LOG_DEBUG (
"WifiRadioEnergyModel:Switching to state: " << stateName <<
356 NS_FATAL_ERROR (
"WifiRadioEnergyModelPhyListener:Change state callback not set!");
368 NS_FATAL_ERROR (
"WifiRadioEnergyModelPhyListener:Change state callback not set!");
379 NS_FATAL_ERROR (
"WifiRadioEnergyModelPhyListener:Change state callback not set!");
390 NS_FATAL_ERROR (
"WifiRadioEnergyModelPhyListener:Change state callback not set!");
404 NS_FATAL_ERROR (
"WifiRadioEnergyModelPhyListener:Change state callback not set!");
418 NS_FATAL_ERROR (
"WifiRadioEnergyModelPhyListener:Change state callback not set!");
436 NS_FATAL_ERROR (
"WifiRadioEnergyModelPhyListener:Change state callback not set!");
void SetWifiRadioState(const WifiPhy::State state)
keep track of time values and allow control of global simulation resolution
static TypeId GetTypeId(void)
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
TracedValue< double > m_totalEnergyConsumption
Base class for device energy models.
NS_LOG_COMPONENT_DEFINE("WifiRadioEnergyModel")
#define NS_ASSERT(condition)
virtual void ChangeState(int newState)
Changes state of the WifiRadioEnergyMode.
WifiRadioEnergyModelPhyListener * m_listener
virtual ~WifiRadioEnergyModelPhyListener()
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
virtual double GetTotalEnergyConsumption(void) const
virtual void NotifyTxStart(Time duration)
Switches the WifiRadioEnergyModel to TX state and switches back to IDLE after TX duration.
WifiRadioEnergyModelPhyListener * GetPhyListener(void)
void SetRxCurrentA(double rxCurrentA)
virtual void NotifyRxEndOk(void)
Switches the WifiRadioEnergyModel back to IDLE state.
#define NS_FATAL_ERROR(msg)
fatal error handling
void SetCcaBusyCurrentA(double ccaBusyCurrentA)
double GetSeconds(void) const
double GetCcaBusyCurrentA(void) const
void SetChangeStateCallback(DeviceEnergyModel::ChangeStateCallback callback)
Sets the change state callback. Used by helper class.
WifiPhy::State m_currentState
Ptr< EnergySource > m_source
virtual void NotifySwitchingStart(Time duration)
virtual void NotifyMaybeCcaBusyStart(Time duration)
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
WifiRadioEnergyModelPhyListener()
virtual void NotifyRxEndError(void)
Switches the WifiRadioEnergyModel back to IDLE state.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
WifiPhy::State GetCurrentState(void) const
DeviceEnergyModel::ChangeStateCallback m_changeStateCallback
EventId m_switchToIdleEvent
virtual void SetEnergySource(Ptr< EnergySource > source)
Sets pointer to EnergySouce installed on node.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
double GetTxCurrentA(void) const
double GetRxCurrentA(void) const
void SetTxCurrentA(double txCurrentA)
virtual void NotifyRxStart(Time duration)
Switches the WifiRadioEnergyModel to RX state.
int64_t GetNanoSeconds(void) const
void SetEnergyDepletionCallback(WifiRadioEnergyDepletionCallback callback)
#define NS_LOG_DEBUG(msg)
WifiRadioEnergyDepletionCallback m_energyDepletionCallback
double GetIdleCurrentA(void) const
virtual void ChangeState(int newState)=0
void SetSwitchingCurrentA(double switchingCurrentA)
double m_switchingCurrentA
virtual double DoGetCurrentA(void) const
Hold an floating point type.
virtual ~WifiRadioEnergyModel()
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
void SetIdleCurrentA(double idleCurrentA)
double GetSwitchingCurrentA(void) const
virtual void HandleEnergyDepletion(void)
Handles energy depletion.