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 <<
"s BasicEnergyHarvester(" <<
GetNode ()->GetId () <<
"): Updating harvesting power.");
120 double energyHarvested = 0.0;
125 NS_LOG_DEBUG (
"BasicEnergyHarvester: Simulation Finished.");
Simulation virtual time values and global simulation resolution.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Hold variables of type string.
void SetHarvestedPowerUpdateInterval(Time updateInterval)
TracedValue< double > m_harvestedPower
virtual double DoGetPower(void) const
Ptr< Node > GetNode(void) const
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
#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.
void DoInitialize(void)
Defined in ns3::Object.
EventId m_energyHarvestingUpdateEvent
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
TracedValue< double > m_totalEnergyHarvestedJ
AttributeValue implementation for Time.
Time m_harvestedPowerUpdateInterval
Time m_lastHarvestingUpdateTime
void CalculateHarvestedPower(void)
Calculates harvested Power.
void UpdateHarvestedPower(void)
This function is called every m_energyHarvestingUpdateInterval in order to update the amount of power...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static Time Now(void)
Return the current simulation virtual time.
Time GetHarvestedPowerUpdateInterval(void) const
Energy harvester base class.
Ptr< EnergySource > GetEnergySource(void) const
static TypeId GetTypeId(void)
Ptr< RandomVariableStream > m_harvestablePower
void DoDispose(void)
Defined in ns3::Object.
int64_t AssignStreams(int64_t stream)
#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.
virtual ~BasicEnergyHarvester()
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
static bool IsFinished(void)
Check if the simulation should finish.
BasicEnergyHarvester increases remaining energy stored in an associated Energy Source.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.