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-source.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010 Network Security Lab, University of Washington, Seattle.
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Authors: Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu>
18
*/
19
20
#ifndef BASIC_ENERGY_SOURCE_H
21
#define BASIC_ENERGY_SOURCE_H
22
23
#include "
energy-source.h
"
24
25
#include "ns3/event-id.h"
26
#include "ns3/nstime.h"
27
#include "ns3/traced-value.h"
28
29
namespace
ns3
30
{
31
namespace
energy
32
{
33
34
/**
35
* \ingroup energy
36
* BasicEnergySource decreases/increases remaining energy stored in itself in
37
* linearly.
38
*
39
*/
40
class
BasicEnergySource
:
public
EnergySource
41
{
42
public
:
43
/**
44
* \brief Get the type ID.
45
* \return The object TypeId.
46
*/
47
static
TypeId
GetTypeId
();
48
BasicEnergySource
();
49
~BasicEnergySource
()
override
;
50
51
/**
52
* \return Initial energy stored in energy source, in Joules.
53
*
54
* Implements GetInitialEnergy.
55
*/
56
double
GetInitialEnergy
()
const override
;
57
58
/**
59
* \returns Supply voltage at the energy source.
60
*
61
* Implements GetSupplyVoltage.
62
*/
63
double
GetSupplyVoltage
()
const override
;
64
65
/**
66
* \return Remaining energy in energy source, in Joules
67
*
68
* Implements GetRemainingEnergy.
69
*/
70
double
GetRemainingEnergy
()
override
;
71
72
/**
73
* \returns Energy fraction.
74
*
75
* Implements GetEnergyFraction.
76
*/
77
double
GetEnergyFraction
()
override
;
78
79
/**
80
* Implements UpdateEnergySource.
81
*/
82
void
UpdateEnergySource
()
override
;
83
84
/**
85
* \param initialEnergyJ Initial energy, in Joules
86
*
87
* Sets initial energy stored in the energy source. Note that initial energy
88
* is assumed to be set before simulation starts and is set only once per
89
* simulation.
90
*/
91
void
SetInitialEnergy
(
double
initialEnergyJ);
92
93
/**
94
* \param supplyVoltageV Supply voltage at the energy source, in Volts.
95
*
96
* Sets supply voltage of the energy source.
97
*/
98
void
SetSupplyVoltage
(
double
supplyVoltageV);
99
100
/**
101
* \param interval Energy update interval.
102
*
103
* This function sets the interval between each energy update.
104
*/
105
void
SetEnergyUpdateInterval
(
Time
interval);
106
107
/**
108
* \returns The interval between each energy update.
109
*/
110
Time
GetEnergyUpdateInterval
()
const
;
111
112
private
:
113
/// Defined in ns3::Object
114
void
DoInitialize
()
override
;
115
116
/// Defined in ns3::Object
117
void
DoDispose
()
override
;
118
119
/**
120
* Handles the remaining energy going to zero event. This function notifies
121
* all the energy models aggregated to the node about the energy being
122
* depleted. Each energy model is then responsible for its own handler.
123
*/
124
void
HandleEnergyDrainedEvent
();
125
126
/**
127
* Handles the remaining energy exceeding the high threshold after it went
128
* below the low threshold. This function notifies all the energy models
129
* aggregated to the node about the energy being recharged. Each energy model
130
* is then responsible for its own handler.
131
*/
132
void
HandleEnergyRechargedEvent
();
133
134
/**
135
* Calculates remaining energy. This function uses the total current from all
136
* device models to calculate the amount of energy to decrease. The energy to
137
* decrease is given by:
138
* energy to decrease = total current * supply voltage * time duration
139
* This function subtracts the calculated energy to decrease from remaining
140
* energy.
141
*/
142
void
CalculateRemainingEnergy
();
143
144
private
:
145
double
m_initialEnergyJ
;
//!< initial energy, in Joules
146
double
m_supplyVoltageV
;
//!< supply voltage, in Volts
147
double
m_lowBatteryTh
;
//!< low battery threshold, as a fraction of the initial energy
148
double
m_highBatteryTh
;
//!< high battery threshold, as a fraction of the initial energy
149
/**
150
* set to true when the remaining energy goes below the low threshold,
151
* set to false again when the remaining energy exceeds the high threshold
152
*/
153
bool
m_depleted
;
154
TracedValue<double>
m_remainingEnergyJ
;
//!< remaining energy, in Joules
155
EventId
m_energyUpdateEvent
;
//!< energy update event
156
Time
m_lastUpdateTime
;
//!< last update time
157
Time
m_energyUpdateInterval
;
//!< energy update interval
158
};
159
160
}
// namespace energy
161
}
// namespace ns3
162
163
#endif
/* BASIC_ENERGY_SOURCE_H */
ns3::EventId
An identifier for simulation events.
Definition:
event-id.h:56
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:105
ns3::TracedValue
Trace classes with value semantics.
Definition:
traced-value.h:116
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::energy::BasicEnergySource
BasicEnergySource decreases/increases remaining energy stored in itself in linearly.
Definition:
basic-energy-source.h:41
ns3::energy::BasicEnergySource::m_lowBatteryTh
double m_lowBatteryTh
low battery threshold, as a fraction of the initial energy
Definition:
basic-energy-source.h:147
ns3::energy::BasicEnergySource::m_initialEnergyJ
double m_initialEnergyJ
initial energy, in Joules
Definition:
basic-energy-source.h:145
ns3::energy::BasicEnergySource::m_lastUpdateTime
Time m_lastUpdateTime
last update time
Definition:
basic-energy-source.h:156
ns3::energy::BasicEnergySource::GetEnergyFraction
double GetEnergyFraction() override
Definition:
basic-energy-source.cc:145
ns3::energy::BasicEnergySource::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
basic-energy-source.cc:37
ns3::energy::BasicEnergySource::GetSupplyVoltage
double GetSupplyVoltage() const override
Definition:
basic-energy-source.cc:122
ns3::energy::BasicEnergySource::GetRemainingEnergy
double GetRemainingEnergy() override
Definition:
basic-energy-source.cc:136
ns3::energy::BasicEnergySource::m_energyUpdateInterval
Time m_energyUpdateInterval
energy update interval
Definition:
basic-energy-source.h:157
ns3::energy::BasicEnergySource::m_energyUpdateEvent
EventId m_energyUpdateEvent
energy update event
Definition:
basic-energy-source.h:155
ns3::energy::BasicEnergySource::BasicEnergySource
BasicEnergySource()
Definition:
basic-energy-source.cc:79
ns3::energy::BasicEnergySource::SetInitialEnergy
void SetInitialEnergy(double initialEnergyJ)
Definition:
basic-energy-source.cc:92
ns3::energy::BasicEnergySource::m_depleted
bool m_depleted
set to true when the remaining energy goes below the low threshold, set to false again when the remai...
Definition:
basic-energy-source.h:153
ns3::energy::BasicEnergySource::~BasicEnergySource
~BasicEnergySource() override
Definition:
basic-energy-source.cc:86
ns3::energy::BasicEnergySource::m_remainingEnergyJ
TracedValue< double > m_remainingEnergyJ
remaining energy, in Joules
Definition:
basic-energy-source.h:154
ns3::energy::BasicEnergySource::DoDispose
void DoDispose() override
Defined in ns3::Object.
Definition:
basic-energy-source.cc:199
ns3::energy::BasicEnergySource::SetSupplyVoltage
void SetSupplyVoltage(double supplyVoltageV)
Definition:
basic-energy-source.cc:101
ns3::energy::BasicEnergySource::SetEnergyUpdateInterval
void SetEnergyUpdateInterval(Time interval)
Definition:
basic-energy-source.cc:108
ns3::energy::BasicEnergySource::GetEnergyUpdateInterval
Time GetEnergyUpdateInterval() const
Definition:
basic-energy-source.cc:115
ns3::energy::BasicEnergySource::GetInitialEnergy
double GetInitialEnergy() const override
Definition:
basic-energy-source.cc:129
ns3::energy::BasicEnergySource::HandleEnergyDrainedEvent
void HandleEnergyDrainedEvent()
Handles the remaining energy going to zero event.
Definition:
basic-energy-source.cc:206
ns3::energy::BasicEnergySource::UpdateEnergySource
void UpdateEnergySource() override
Implements UpdateEnergySource.
Definition:
basic-energy-source.cc:154
ns3::energy::BasicEnergySource::CalculateRemainingEnergy
void CalculateRemainingEnergy()
Calculates remaining energy.
Definition:
basic-energy-source.cc:222
ns3::energy::BasicEnergySource::m_highBatteryTh
double m_highBatteryTh
high battery threshold, as a fraction of the initial energy
Definition:
basic-energy-source.h:148
ns3::energy::BasicEnergySource::HandleEnergyRechargedEvent
void HandleEnergyRechargedEvent()
Handles the remaining energy exceeding the high threshold after it went below the low threshold.
Definition:
basic-energy-source.cc:214
ns3::energy::BasicEnergySource::DoInitialize
void DoInitialize() override
Defined in ns3::Object.
Definition:
basic-energy-source.cc:192
ns3::energy::BasicEnergySource::m_supplyVoltageV
double m_supplyVoltageV
supply voltage, in Volts
Definition:
basic-energy-source.h:146
ns3::energy::EnergySource
Energy source base class.
Definition:
energy-source.h:88
energy-source.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
energy
model
basic-energy-source.h
Generated on Tue May 28 2024 23:35:17 for ns-3 by
1.9.6