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 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Cristiano Tapparello <cristiano.tapparello@rochester.edu>
19 */
20
21#ifndef BASIC_ENERGY_HARVESTER
22#define BASIC_ENERGY_HARVESTER
23
24#include "device-energy-model.h"
25#include "energy-harvester.h"
26
27#include "ns3/event-id.h"
28#include "ns3/nstime.h"
29#include "ns3/random-variable-stream.h"
30#include "ns3/traced-value.h"
31
32#include <iostream>
33
34namespace ns3
35{
36
37/**
38 * \ingroup energy
39 * BasicEnergyHarvester increases remaining energy stored in an associated
40 * Energy Source. The BasicEnergyHarvester implements a simple model in which
41 * the amount of power provided by the harvester varies over time according
42 * to a customizable generic random variable and time update intervals.
43 *
44 * Unit of power is chosen as Watt since energy models typically calculate
45 * energy as (time in seconds * power in Watt).
46 *
47 */
49{
50 public:
51 /**
52 * \brief Get the type ID.
53 * \return The object TypeId.
54 */
55 static TypeId GetTypeId();
56
58
59 /**
60 * \param updateInterval Energy harvesting update interval.
61 *
62 * BasicEnergyHarvester constructor function that sets the interval
63 * between each update of the value of the power harvested by this
64 * energy harvester.
65 */
66 BasicEnergyHarvester(Time updateInterval);
67
68 ~BasicEnergyHarvester() override;
69
70 /**
71 * \param updateInterval Energy harvesting update interval.
72 *
73 * This function sets the interval between each update of the value of the
74 * power harvested by this energy harvester.
75 */
76 void SetHarvestedPowerUpdateInterval(Time updateInterval);
77
78 /**
79 * \returns The interval between each update of the harvested power.
80 *
81 * This function returns the interval between each update of the value of the
82 * power harvested by this energy harvester.
83 */
85
86 /**
87 * \param stream Random variable stream number.
88 * \returns The number of stream indices assigned by this model.
89 *
90 * This function sets the stream number to be used by the random variable that
91 * determines the amount of power that can be harvested by this energy harvester.
92 */
93 int64_t AssignStreams(int64_t stream);
94
95 private:
96 /// Defined in ns3::Object
97 void DoInitialize() override;
98
99 /// Defined in ns3::Object
100 void DoDispose() override;
101
102 /**
103 * Calculates harvested Power.
104 */
106
107 /**
108 * \returns m_harvestedPower The power currently provided by the Basic Energy Harvester.
109 * Implements DoGetPower defined in EnergyHarvester.
110 */
111 double DoGetPower() const override;
112
113 /**
114 * This function is called every m_energyHarvestingUpdateInterval in order to
115 * update the amount of power that will be provided by the harvester in the
116 * next interval.
117 */
119
120 private:
121 Ptr<RandomVariableStream> m_harvestablePower; //!< Random variable for the harvestable power
122
123 TracedValue<double> m_harvestedPower; //!< current harvested power, in Watt
124 TracedValue<double> m_totalEnergyHarvestedJ; //!< total harvested energy, in Joule
125
126 EventId m_energyHarvestingUpdateEvent; //!< energy harvesting event
127 Time m_lastHarvestingUpdateTime; //!< last harvesting time
128 Time m_harvestedPowerUpdateInterval; //!< harvestable energy update interval
129};
130
131} // namespace ns3
132
133#endif /* defined(BASIC_ENERGY_HARVESTER) */
BasicEnergyHarvester increases remaining energy stored in an associated Energy Source.
Time m_lastHarvestingUpdateTime
last harvesting time
void UpdateHarvestedPower()
This function is called every m_energyHarvestingUpdateInterval in order to update the amount of power...
TracedValue< double > m_harvestedPower
current harvested power, in Watt
Ptr< RandomVariableStream > m_harvestablePower
Random variable for the harvestable power.
double DoGetPower() const override
static TypeId GetTypeId()
Get the type ID.
void DoInitialize() override
Defined in ns3::Object.
void SetHarvestedPowerUpdateInterval(Time updateInterval)
TracedValue< double > m_totalEnergyHarvestedJ
total harvested energy, in Joule
void DoDispose() override
Defined in ns3::Object.
int64_t AssignStreams(int64_t stream)
void CalculateHarvestedPower()
Calculates harvested Power.
EventId m_energyHarvestingUpdateEvent
energy harvesting event
Time m_harvestedPowerUpdateInterval
harvestable energy update interval
Energy harvester base class.
An identifier for simulation events.
Definition: event-id.h:55
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Trace classes with value semantics.
Definition: traced-value.h:116
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.