25 #include "ns3/assert.h"
26 #include "ns3/pointer.h"
27 #include "ns3/string.h"
28 #include "ns3/trace-source-accessor.h"
29 #include "ns3/simulator.h"
42 .SetGroupName (
"Energy")
44 .AddAttribute (
"PeriodicHarvestedPowerUpdateInterval",
45 "Time between two consecutive periodic updates of the harvested power. By default, the value is updated every 1 s",
50 .AddAttribute (
"HarvestablePower",
51 "The harvestable power [Watts] that the energy harvester is allowed to harvest. By default, the model will allow to harvest an amount of power defined by a uniformly distributed random variable in 0 and 2.0 Watts",
52 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=2.0]"),
54 MakePointerChecker<RandomVariableStream> ())
55 .AddTraceSource (
"HarvestedPower",
56 "Harvested power by the BasicEnergyHarvester.",
58 "ns3::TracedValueCallback::Double")
59 .AddTraceSource (
"TotalEnergyHarvested",
60 "Total energy harvested by the harvester.",
62 "ns3::TracedValueCallback::Double")
114 <<
" BasicEnergyHarvester(" <<
GetNode ()->GetId () <<
"): Updating harvesting power.");
120 double energyHarvested = 0.0;
125 NS_LOG_DEBUG (
"BasicEnergyHarvester: Simulation Finished.");
BasicEnergyHarvester increases remaining energy stored in an associated Energy Source.
Time m_lastHarvestingUpdateTime
last harvesting time
TracedValue< double > m_harvestedPower
current harvested power, in Watt
Ptr< RandomVariableStream > m_harvestablePower
Random variable for the harvestable power.
virtual double DoGetPower(void) const
Time GetHarvestedPowerUpdateInterval(void) const
void DoDispose(void)
Defined in ns3::Object.
void SetHarvestedPowerUpdateInterval(Time updateInterval)
TracedValue< double > m_totalEnergyHarvestedJ
total harvested energy, in Joule
int64_t AssignStreams(int64_t stream)
void UpdateHarvestedPower(void)
This function is called every m_energyHarvestingUpdateInterval in order to update the amount of power...
EventId m_energyHarvestingUpdateEvent
energy harvesting event
static TypeId GetTypeId(void)
Get the type ID.
void CalculateHarvestedPower(void)
Calculates harvested Power.
virtual ~BasicEnergyHarvester()
Time m_harvestedPowerUpdateInterval
harvestable energy update interval
void DoInitialize(void)
Defined in ns3::Object.
Energy harvester base class.
Ptr< Node > GetNode(void) const
Ptr< EnergySource > GetEnergySource(void) const
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static bool IsFinished(void)
Check if the simulation should finish.
static Time Now(void)
Return the current simulation virtual time.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
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,...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#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 AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.