A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
rv-battery-model.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2010 Network Security Lab, University of Washington, Seattle.
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
* Authors: Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu>
19
*/
20
21
#ifndef RV_BATTERY_MODEL_H
22
#define RV_BATTERY_MODEL_H
23
24
#include "ns3/traced-value.h"
25
#include "ns3/nstime.h"
26
#include "ns3/event-id.h"
27
#include "
energy-source.h
"
28
29
namespace
ns3 {
30
50
class
RvBatteryModel
:
public
EnergySource
51
{
52
public
:
53
static
TypeId
GetTypeId
(
void
);
54
RvBatteryModel
();
55
virtual
~RvBatteryModel
();
56
62
virtual
double
GetInitialEnergy
(
void
)
const
;
63
69
virtual
double
GetSupplyVoltage
(
void
)
const
;
70
76
virtual
double
GetRemainingEnergy
(
void
);
77
84
virtual
double
GetEnergyFraction
(
void
);
85
90
virtual
void
UpdateEnergySource
(
void
);
91
97
void
SetSamplingInterval
(
Time
interval);
98
102
Time
GetSamplingInterval
(
void
)
const
;
103
109
void
SetOpenCircuitVoltage
(
double
voltage);
110
114
double
GetOpenCircuitVoltage
(
void
)
const
;
115
121
void
SetCutoffVoltage
(
double
voltage);
122
126
double
GetCutoffVoltage
(
void
)
const
;
127
133
void
SetAlpha
(
double
alpha);
134
138
double
GetAlpha
(
void
)
const
;
139
145
void
SetBeta
(
double
beta);
146
150
double
GetBeta
(
void
)
const
;
151
155
double
GetBatteryLevel
(
void
);
156
160
Time
GetLifetime
(
void
)
const
;
161
168
void
SetNumOfTerms
(
int
num);
169
174
int
GetNumOfTerms
(
void
)
const
;
175
176
private
:
178
virtual
void
DoInitialize
(
void
);
179
181
virtual
void
DoDispose
(
void
);
182
188
void
HandleEnergyDrainedEvent
(
void
);
189
203
double
Discharge
(
double
load,
Time
t);
204
216
double
RvModelAFunction
(
Time
t,
Time
sk,
Time
sk_1,
double
beta);
217
218
private
:
219
double
m_openCircuitVoltage
;
220
double
m_cutoffVoltage
;
221
double
m_alpha
;
// alpha value of RV model, in Coulomb
222
double
m_beta
;
// beta value of RV model, in second^-1
223
224
double
m_previousLoad
;
// load value (total current) of previous sampling
225
std::vector<double>
m_load
;
// load profile
226
std::vector<Time>
m_timeStamps
;
// time stamps of load profile
227
Time
m_lastSampleTime
;
228
uint64_t
m_counter
;
229
230
int
m_numOfTerms
;
// # of terms for infinite sum in battery level estimation
231
248
TracedValue<double>
m_batteryLevel
;
249
253
Time
m_samplingInterval
;
254
EventId
m_currentSampleEvent
;
255
256
TracedValue<Time>
m_lifetime
;
// time of death of the battery
257
};
258
259
}
// namespace ns3
260
261
#endif
/* RV_BATTERY_MODEL_H */
src
energy
model
rv-battery-model.h
Generated on Tue May 14 2013 11:08:20 for ns-3 by
1.8.1.2