A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
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
38
class
BasicEnergySource
:
public
EnergySource
39
{
40
public
:
45
static
TypeId
GetTypeId
();
46
BasicEnergySource
();
47
~BasicEnergySource
()
override
;
48
54
double
GetInitialEnergy
()
const override
;
55
61
double
GetSupplyVoltage
()
const override
;
62
68
double
GetRemainingEnergy
()
override
;
69
75
double
GetEnergyFraction
()
override
;
76
80
void
UpdateEnergySource
()
override
;
81
89
void
SetInitialEnergy
(
double
initialEnergyJ);
90
96
void
SetSupplyVoltage
(
double
supplyVoltageV);
97
103
void
SetEnergyUpdateInterval
(
Time
interval);
104
108
Time
GetEnergyUpdateInterval
()
const
;
109
110
private
:
112
void
DoInitialize
()
override
;
113
115
void
DoDispose
()
override
;
116
122
void
HandleEnergyDrainedEvent
();
123
130
void
HandleEnergyRechargedEvent
();
131
140
void
CalculateRemainingEnergy
();
141
142
private
:
143
double
m_initialEnergyJ
;
144
double
m_supplyVoltageV
;
145
double
m_lowBatteryTh
;
146
double
m_highBatteryTh
;
151
bool
m_depleted
;
152
TracedValue<double>
m_remainingEnergyJ
;
153
EventId
m_energyUpdateEvent
;
154
Time
m_lastUpdateTime
;
155
Time
m_energyUpdateInterval
;
156
};
157
158
}
// namespace ns3
159
160
#endif
/* BASIC_ENERGY_SOURCE_H */
ns3::BasicEnergySource
BasicEnergySource decreases/increases remaining energy stored in itself in linearly.
Definition:
basic-energy-source.h:39
ns3::BasicEnergySource::HandleEnergyRechargedEvent
void HandleEnergyRechargedEvent()
Handles the remaining energy exceeding the high threshold after it went below the low threshold.
Definition:
basic-energy-source.cc:213
ns3::BasicEnergySource::SetEnergyUpdateInterval
void SetEnergyUpdateInterval(Time interval)
Definition:
basic-energy-source.cc:107
ns3::BasicEnergySource::BasicEnergySource
BasicEnergySource()
Definition:
basic-energy-source.cc:78
ns3::BasicEnergySource::GetSupplyVoltage
double GetSupplyVoltage() const override
Definition:
basic-energy-source.cc:121
ns3::BasicEnergySource::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
basic-energy-source.cc:36
ns3::BasicEnergySource::m_energyUpdateInterval
Time m_energyUpdateInterval
energy update interval
Definition:
basic-energy-source.h:155
ns3::BasicEnergySource::m_initialEnergyJ
double m_initialEnergyJ
initial energy, in Joules
Definition:
basic-energy-source.h:143
ns3::BasicEnergySource::m_lowBatteryTh
double m_lowBatteryTh
low battery threshold, as a fraction of the initial energy
Definition:
basic-energy-source.h:145
ns3::BasicEnergySource::GetRemainingEnergy
double GetRemainingEnergy() override
Definition:
basic-energy-source.cc:135
ns3::BasicEnergySource::GetEnergyFraction
double GetEnergyFraction() override
Definition:
basic-energy-source.cc:144
ns3::BasicEnergySource::HandleEnergyDrainedEvent
void HandleEnergyDrainedEvent()
Handles the remaining energy going to zero event.
Definition:
basic-energy-source.cc:205
ns3::BasicEnergySource::m_lastUpdateTime
Time m_lastUpdateTime
last update time
Definition:
basic-energy-source.h:154
ns3::BasicEnergySource::GetInitialEnergy
double GetInitialEnergy() const override
Definition:
basic-energy-source.cc:128
ns3::BasicEnergySource::SetSupplyVoltage
void SetSupplyVoltage(double supplyVoltageV)
Definition:
basic-energy-source.cc:100
ns3::BasicEnergySource::DoDispose
void DoDispose() override
Defined in ns3::Object.
Definition:
basic-energy-source.cc:198
ns3::BasicEnergySource::m_energyUpdateEvent
EventId m_energyUpdateEvent
energy update event
Definition:
basic-energy-source.h:153
ns3::BasicEnergySource::DoInitialize
void DoInitialize() override
Defined in ns3::Object.
Definition:
basic-energy-source.cc:191
ns3::BasicEnergySource::~BasicEnergySource
~BasicEnergySource() override
Definition:
basic-energy-source.cc:85
ns3::BasicEnergySource::m_remainingEnergyJ
TracedValue< double > m_remainingEnergyJ
remaining energy, in Joules
Definition:
basic-energy-source.h:152
ns3::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:151
ns3::BasicEnergySource::m_highBatteryTh
double m_highBatteryTh
high battery threshold, as a fraction of the initial energy
Definition:
basic-energy-source.h:146
ns3::BasicEnergySource::UpdateEnergySource
void UpdateEnergySource() override
Implements UpdateEnergySource.
Definition:
basic-energy-source.cc:153
ns3::BasicEnergySource::GetEnergyUpdateInterval
Time GetEnergyUpdateInterval() const
Definition:
basic-energy-source.cc:114
ns3::BasicEnergySource::SetInitialEnergy
void SetInitialEnergy(double initialEnergyJ)
Definition:
basic-energy-source.cc:91
ns3::BasicEnergySource::m_supplyVoltageV
double m_supplyVoltageV
supply voltage, in Volts
Definition:
basic-energy-source.h:144
ns3::BasicEnergySource::CalculateRemainingEnergy
void CalculateRemainingEnergy()
Calculates remaining energy.
Definition:
basic-energy-source.cc:221
ns3::EnergySource
Definition:
energy-source.h:87
ns3::EventId
An identifier for simulation events.
Definition:
event-id.h:55
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:105
ns3::TracedValue< double >
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
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 Sun Mar 3 2024 17:10:57 for ns-3 by
1.9.1