|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
23 #include "ns3/assert.h"
24 #include "ns3/double.h"
25 #include "ns3/trace-source-accessor.h"
26 #include "ns3/simulator.h"
39 .SetGroupName (
"Energy")
41 .AddAttribute (
"BasicEnergySourceInitialEnergyJ",
42 "Initial energy stored in basic energy source.",
46 MakeDoubleChecker<double> ())
47 .AddAttribute (
"BasicEnergySupplyVoltageV",
48 "Initial supply voltage for basic energy source.",
52 MakeDoubleChecker<double> ())
53 .AddAttribute (
"BasicEnergyLowBatteryThreshold",
54 "Low battery threshold for basic energy source.",
57 MakeDoubleChecker<double> ())
58 .AddAttribute (
"BasicEnergyHighBatteryThreshold",
59 "High battery threshold for basic energy source.",
62 MakeDoubleChecker<double> ())
63 .AddAttribute (
"PeriodicEnergyUpdateInterval",
64 "Time between two consecutive periodic energy updates.",
69 .AddTraceSource (
"RemainingEnergy",
70 "Remaining energy at BasicEnergySource.",
72 "ns3::TracedValueCallback::Double")
155 NS_LOG_DEBUG (
"BasicEnergySource:Updating remaining energy.");
227 double energyToDecreaseJ = (totalCurrentA *
m_supplyVoltageV * duration).GetSeconds ();
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
virtual double GetEnergyFraction(void)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
static TypeId GetTypeId(void)
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void NotifyEnergyChanged(void)
This function notifies all DeviceEnergyModel of energy changed event.
void SetSupplyVoltage(double supplyVoltageV)
virtual void UpdateEnergySource(void)
Implements UpdateEnergySource.
void HandleEnergyRechargedEvent(void)
Handles the remaining energy exceeding the high threshold after it went below the low threshold.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
void SetInitialEnergy(double initialEnergyJ)
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void NotifyEnergyDrained(void)
This function notifies all DeviceEnergyModel of energy depletion event.
void DoDispose(void)
Defined in ns3::Object.
double CalculateTotalCurrent(void)
virtual double GetSupplyVoltage(void) const
virtual ~BasicEnergySource()
BasicEnergySource decreases/increases remaining energy stored in itself in linearly.
Time GetEnergyUpdateInterval(void) const
Introspection did not find any typical Config paths.
Time m_energyUpdateInterval
Simulation virtual time values and global simulation resolution.
void CalculateRemainingEnergy(void)
Calculates remaining energy.
virtual double GetInitialEnergy(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.
TracedValue< double > m_remainingEnergyJ
bool IsPositive(void) const
Exactly equivalent to t >= 0.
EventId m_energyUpdateEvent
void BreakDeviceEnergyModelRefCycle(void)
This function is called to break reference cycle between EnergySource and DeviceEnergyModel.
#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.
AttributeValue implementation for Time.
void SetEnergyUpdateInterval(Time interval)
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
void NotifyEnergyRecharged(void)
This function notifies all DeviceEnergyModel of energy recharged event.
void HandleEnergyDrainedEvent(void)
Handles the remaining energy going to zero event.
virtual double GetRemainingEnergy(void)
void DoInitialize(void)
Defined in ns3::Object.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.