12#include "ns3/assert.h"
14#include "ns3/pointer.h"
15#include "ns3/simulator.h"
16#include "ns3/string.h"
17#include "ns3/trace-source-accessor.h"
31 TypeId(
"ns3::energy::BasicEnergyHarvester")
34 .SetGroupName(
"Energy")
36 .AddAttribute(
"PeriodicHarvestedPowerUpdateInterval",
37 "Time between two consecutive periodic updates of the harvested power. "
38 "By default, the value is updated every 1 s",
43 .AddAttribute(
"HarvestablePower",
44 "The harvestable power [Watts] that the energy harvester is allowed to "
45 "harvest. By default, the model will allow to harvest an amount of power "
46 "defined by a uniformly distributed random variable in 0 and 2.0 Watts",
47 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=2.0]"),
50 .AddTraceSource(
"HarvestedPower",
51 "Harvested power by the BasicEnergyHarvester.",
53 "ns3::TracedValueCallback::Double")
54 .AddTraceSource(
"TotalEnergyHarvested",
55 "Total energy harvested by the harvester.",
57 "ns3::TracedValueCallback::Double");
108 <<
"): Updating harvesting power.");
114 double energyHarvested = 0.0;
119 NS_LOG_DEBUG(
"BasicEnergyHarvester: Simulation Finished.");
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 AddDeprecatedName(const std::string &name)
Add an deprecated name for a TypeId.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
BasicEnergyHarvester increases remaining energy stored in an associated Energy Source.
Time m_harvestedPowerUpdateInterval
harvestable energy update interval
double DoGetPower() const override
static TypeId GetTypeId()
Get the type ID.
TracedValue< double > m_totalEnergyHarvestedJ
total harvested energy, in Joule
Ptr< RandomVariableStream > m_harvestablePower
Random variable for the harvestable power.
void CalculateHarvestedPower()
Calculates harvested Power.
void DoInitialize() override
Defined in ns3::Object.
void UpdateHarvestedPower()
This function is called every m_energyHarvestingUpdateInterval in order to update the amount of power...
~BasicEnergyHarvester() override
Time GetHarvestedPowerUpdateInterval() const
Time m_lastHarvestingUpdateTime
last harvesting time
void DoDispose() override
Defined in ns3::Object.
TracedValue< double > m_harvestedPower
current harvested power, in Watt
int64_t AssignStreams(int64_t stream)
void SetHarvestedPowerUpdateInterval(Time updateInterval)
EventId m_energyHarvestingUpdateEvent
energy harvesting event
Energy harvester base class.
Ptr< EnergySource > GetEnergySource() const
Ptr< Node > GetNode() const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
#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 AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.