A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
23
namespace
ns3
24
{
25
namespace
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
*/
39
class
BasicEnergyHarvester
:
public
EnergyHarvester
40
{
41
public
:
42
/**
43
* \brief Get the type ID.
44
* \return The object TypeId.
45
*/
46
static
TypeId
GetTypeId
();
47
48
BasicEnergyHarvester
();
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
*/
75
Time
GetHarvestedPowerUpdateInterval
()
const
;
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
*/
96
void
CalculateHarvestedPower
();
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
*/
109
void
UpdateHarvestedPower
();
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) */
ns3::EventId
An identifier for simulation events.
Definition
event-id.h:45
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
ns3::TracedValue
Trace classes with value semantics.
Definition
traced-value.h:105
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::energy::BasicEnergyHarvester
BasicEnergyHarvester increases remaining energy stored in an associated Energy Source.
Definition
basic-energy-harvester.h:40
ns3::energy::BasicEnergyHarvester::m_harvestedPowerUpdateInterval
Time m_harvestedPowerUpdateInterval
harvestable energy update interval
Definition
basic-energy-harvester.h:119
ns3::energy::BasicEnergyHarvester::DoGetPower
double DoGetPower() const override
Definition
basic-energy-harvester.cc:171
ns3::energy::BasicEnergyHarvester::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
basic-energy-harvester.cc:28
ns3::energy::BasicEnergyHarvester::m_totalEnergyHarvestedJ
TracedValue< double > m_totalEnergyHarvestedJ
total harvested energy, in Joule
Definition
basic-energy-harvester.h:115
ns3::energy::BasicEnergyHarvester::m_harvestablePower
Ptr< RandomVariableStream > m_harvestablePower
Random variable for the harvestable power.
Definition
basic-energy-harvester.h:112
ns3::energy::BasicEnergyHarvester::CalculateHarvestedPower
void CalculateHarvestedPower()
Calculates harvested Power.
Definition
basic-energy-harvester.cc:160
ns3::energy::BasicEnergyHarvester::DoInitialize
void DoInitialize() override
Defined in ns3::Object.
Definition
basic-energy-harvester.cc:144
ns3::energy::BasicEnergyHarvester::UpdateHarvestedPower
void UpdateHarvestedPower()
This function is called every m_energyHarvestingUpdateInterval in order to update the amount of power...
Definition
basic-energy-harvester.cc:104
ns3::energy::BasicEnergyHarvester::BasicEnergyHarvester
BasicEnergyHarvester()
Definition
basic-energy-harvester.cc:61
ns3::energy::BasicEnergyHarvester::~BasicEnergyHarvester
~BasicEnergyHarvester() override
Definition
basic-energy-harvester.cc:72
ns3::energy::BasicEnergyHarvester::GetHarvestedPowerUpdateInterval
Time GetHarvestedPowerUpdateInterval() const
Definition
basic-energy-harvester.cc:93
ns3::energy::BasicEnergyHarvester::m_lastHarvestingUpdateTime
Time m_lastHarvestingUpdateTime
last harvesting time
Definition
basic-energy-harvester.h:118
ns3::energy::BasicEnergyHarvester::DoDispose
void DoDispose() override
Defined in ns3::Object.
Definition
basic-energy-harvester.cc:154
ns3::energy::BasicEnergyHarvester::m_harvestedPower
TracedValue< double > m_harvestedPower
current harvested power, in Watt
Definition
basic-energy-harvester.h:114
ns3::energy::BasicEnergyHarvester::AssignStreams
int64_t AssignStreams(int64_t stream)
Definition
basic-energy-harvester.cc:78
ns3::energy::BasicEnergyHarvester::SetHarvestedPowerUpdateInterval
void SetHarvestedPowerUpdateInterval(Time updateInterval)
Definition
basic-energy-harvester.cc:86
ns3::energy::BasicEnergyHarvester::m_energyHarvestingUpdateEvent
EventId m_energyHarvestingUpdateEvent
energy harvesting event
Definition
basic-energy-harvester.h:117
ns3::energy::EnergyHarvester
Energy harvester base class.
Definition
energy-harvester.h:36
device-energy-model.h
energy-harvester.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
energy
model
basic-energy-harvester.h
Generated on Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0