A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
basic-energy-harvester.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Wireless Communications and Networking Group (WCNG),
3 * University of Rochester, Rochester, NY, USA.
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Author: Cristiano Tapparello <cristiano.tapparello@rochester.edu>
8 */
9
10#ifndef BASIC_ENERGY_HARVESTER
11#define BASIC_ENERGY_HARVESTER
12
13#include "device-energy-model.h"
14#include "energy-harvester.h"
15
16#include "ns3/event-id.h"
17#include "ns3/nstime.h"
18#include "ns3/random-variable-stream.h"
19#include "ns3/traced-value.h"
20
21#include <iostream>
22
23namespace ns3
24{
25namespace energy
26{
27
28/**
29 * \ingroup energy
30 * BasicEnergyHarvester increases remaining energy stored in an associated
31 * Energy Source. The BasicEnergyHarvester implements a simple model in which
32 * the amount of power provided by the harvester varies over time according
33 * to a customizable generic random variable and time update intervals.
34 *
35 * Unit of power is chosen as Watt since energy models typically calculate
36 * energy as (time in seconds * power in Watt).
37 *
38 */
40{
41 public:
42 /**
43 * \brief Get the type ID.
44 * \return The object TypeId.
45 */
46 static TypeId GetTypeId();
47
49
50 /**
51 * \param updateInterval Energy harvesting update interval.
52 *
53 * BasicEnergyHarvester constructor function that sets the interval
54 * between each update of the value of the power harvested by this
55 * energy harvester.
56 */
57 BasicEnergyHarvester(Time updateInterval);
58
59 ~BasicEnergyHarvester() override;
60
61 /**
62 * \param updateInterval Energy harvesting update interval.
63 *
64 * This function sets the interval between each update of the value of the
65 * power harvested by this energy harvester.
66 */
67 void SetHarvestedPowerUpdateInterval(Time updateInterval);
68
69 /**
70 * \returns The interval between each update of the harvested power.
71 *
72 * This function returns the interval between each update of the value of the
73 * power harvested by this energy harvester.
74 */
76
77 /**
78 * \param stream Random variable stream number.
79 * \returns The number of stream indices assigned by this model.
80 *
81 * This function sets the stream number to be used by the random variable that
82 * determines the amount of power that can be harvested by this energy harvester.
83 */
84 int64_t AssignStreams(int64_t stream);
85
86 private:
87 /// Defined in ns3::Object
88 void DoInitialize() override;
89
90 /// Defined in ns3::Object
91 void DoDispose() override;
92
93 /**
94 * Calculates harvested Power.
95 */
97
98 /**
99 * \returns m_harvestedPower The power currently provided by the Basic Energy Harvester.
100 * Implements DoGetPower defined in EnergyHarvester.
101 */
102 double DoGetPower() const override;
103
104 /**
105 * This function is called every m_energyHarvestingUpdateInterval in order to
106 * update the amount of power that will be provided by the harvester in the
107 * next interval.
108 */
110
111 private:
112 Ptr<RandomVariableStream> m_harvestablePower; //!< Random variable for the harvestable power
113
114 TracedValue<double> m_harvestedPower; //!< current harvested power, in Watt
115 TracedValue<double> m_totalEnergyHarvestedJ; //!< total harvested energy, in Joule
116
117 EventId m_energyHarvestingUpdateEvent; //!< energy harvesting event
118 Time m_lastHarvestingUpdateTime; //!< last harvesting time
119 Time m_harvestedPowerUpdateInterval; //!< harvestable energy update interval
120};
121
122} // namespace energy
123} // namespace ns3
124
125#endif /* defined(BASIC_ENERGY_HARVESTER) */
An identifier for simulation events.
Definition event-id.h:45
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Trace classes with value semantics.
a unique identifier for an interface.
Definition type-id.h:48
BasicEnergyHarvester increases remaining energy stored in an associated Energy Source.
Time m_harvestedPowerUpdateInterval
harvestable energy update interval
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...
Time m_lastHarvestingUpdateTime
last harvesting time
void DoDispose() override
Defined in ns3::Object.
TracedValue< double > m_harvestedPower
current harvested power, in Watt
void SetHarvestedPowerUpdateInterval(Time updateInterval)
EventId m_energyHarvestingUpdateEvent
energy harvesting event
Energy harvester base class.
Every class exported by the ns3 library is enclosed in the ns3 namespace.