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