23 #include "ns3/assert.h"
25 #include "ns3/pointer.h"
26 #include "ns3/simulator.h"
27 #include "ns3/string.h"
28 #include "ns3/trace-source-accessor.h"
41 TypeId(
"ns3::BasicEnergyHarvester")
43 .SetGroupName(
"Energy")
45 .AddAttribute(
"PeriodicHarvestedPowerUpdateInterval",
46 "Time between two consecutive periodic updates of the harvested power. "
47 "By default, the value is updated every 1 s",
52 .AddAttribute(
"HarvestablePower",
53 "The harvestable power [Watts] that the energy harvester is allowed to "
54 "harvest. By default, the model will allow to harvest an amount of power "
55 "defined by a uniformly distributed random variable in 0 and 2.0 Watts",
56 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=2.0]"),
58 MakePointerChecker<RandomVariableStream>())
59 .AddTraceSource(
"HarvestedPower",
60 "Harvested power by the BasicEnergyHarvester.",
62 "ns3::TracedValueCallback::Double")
63 .AddTraceSource(
"TotalEnergyHarvested",
64 "Total energy harvested by the harvester.",
66 "ns3::TracedValueCallback::Double");
117 <<
"): Updating harvesting power.");
123 double energyHarvested = 0.0;
128 NS_LOG_DEBUG(
"BasicEnergyHarvester: Simulation Finished.");
BasicEnergyHarvester increases remaining energy stored in an associated Energy Source.
Time m_lastHarvestingUpdateTime
last harvesting time
void UpdateHarvestedPower()
This function is called every m_energyHarvestingUpdateInterval in order to update the amount of power...
TracedValue< double > m_harvestedPower
current harvested power, in Watt
Ptr< RandomVariableStream > m_harvestablePower
Random variable for the harvestable power.
double DoGetPower() const override
static TypeId GetTypeId()
Get the type ID.
void DoInitialize() override
Defined in ns3::Object.
void SetHarvestedPowerUpdateInterval(Time updateInterval)
TracedValue< double > m_totalEnergyHarvestedJ
total harvested energy, in Joule
void DoDispose() override
Defined in ns3::Object.
int64_t AssignStreams(int64_t stream)
Time GetHarvestedPowerUpdateInterval() const
void CalculateHarvestedPower()
Calculates harvested Power.
EventId m_energyHarvestingUpdateEvent
energy harvesting event
~BasicEnergyHarvester() override
Time m_harvestedPowerUpdateInterval
harvestable energy update interval
Energy harvester base class.
Ptr< EnergySource > GetEnergySource() const
Ptr< Node > GetNode() const
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
virtual double GetValue()=0
Get the next random value drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static bool IsFinished()
Check if the simulation should finish.
static Time Now()
Return the current simulation virtual time.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#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.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.