A Discrete-Event Network Simulator
API
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 
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:
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
228 
229  int m_numOfTerms; // # of terms for infinite sum in battery level estimation
230 
248 
249  double m_lowBatteryTh; // low battery threshold, as a fraction of the initial energy
250 
256 
257  TracedValue<Time> m_lifetime; // time of death of the battery
258 };
259 
260 } // namespace ns3
261 
262 #endif /* RV_BATTERY_MODEL_H */
ns3::RvBatteryModel::SetCutoffVoltage
void SetCutoffVoltage(double voltage)
Sets cutoff voltage of battery.
Definition: rv-battery-model.cc:220
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::RvBatteryModel::Discharge
double Discharge(double load, Time t)
Discharges the battery.
Definition: rv-battery-model.cc:321
ns3::EventId
An identifier for simulation events.
Definition: event-id.h:54
ns3::RvBatteryModel::GetSupplyVoltage
virtual double GetSupplyVoltage(void) const
Definition: rv-battery-model.cc:118
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::RvBatteryModel
Rakhmatov Vrudhula non-linear battery model.
Definition: rv-battery-model.h:51
ns3::RvBatteryModel::DoInitialize
virtual void DoInitialize(void)
Defined in ns3::Object.
Definition: rv-battery-model.cc:298
ns3::RvBatteryModel::GetRemainingEnergy
virtual double GetRemainingEnergy(void)
Definition: rv-battery-model.cc:126
ns3::RvBatteryModel::GetBatteryLevel
double GetBatteryLevel(void)
Definition: rv-battery-model.cc:265
ns3::RvBatteryModel::GetTypeId
static TypeId GetTypeId(void)
Definition: rv-battery-model.cc:36
ns3::RvBatteryModel::SetSamplingInterval
void SetSamplingInterval(Time interval)
Definition: rv-battery-model.cc:191
ns3::RvBatteryModel::SetBeta
void SetBeta(double beta)
Sets the beta value for the battery model.
Definition: rv-battery-model.cc:250
ns3::RvBatteryModel::m_previousLoad
double m_previousLoad
Definition: rv-battery-model.h:224
ns3::RvBatteryModel::m_cutoffVoltage
double m_cutoffVoltage
Definition: rv-battery-model.h:220
ns3::RvBatteryModel::GetEnergyFraction
virtual double GetEnergyFraction(void)
Definition: rv-battery-model.cc:134
ns3::RvBatteryModel::SetOpenCircuitVoltage
void SetOpenCircuitVoltage(double voltage)
Sets open circuit voltage of battery.
Definition: rv-battery-model.cc:205
ns3::RvBatteryModel::RvBatteryModel
RvBatteryModel()
Definition: rv-battery-model.cc:95
ns3::RvBatteryModel::SetNumOfTerms
void SetNumOfTerms(int num)
Sets the number of terms of the infinite sum for estimating battery level.
Definition: rv-battery-model.cc:280
ns3::RvBatteryModel::m_currentSampleEvent
EventId m_currentSampleEvent
Definition: rv-battery-model.h:255
ns3::RvBatteryModel::GetLifetime
Time GetLifetime(void) const
Definition: rv-battery-model.cc:273
ns3::RvBatteryModel::m_lifetime
TracedValue< Time > m_lifetime
Definition: rv-battery-model.h:257
ns3::RvBatteryModel::HandleEnergyDrainedEvent
void HandleEnergyDrainedEvent(void)
Handles the remaining energy going to zero event.
Definition: rv-battery-model.cc:313
ns3::RvBatteryModel::~RvBatteryModel
virtual ~RvBatteryModel()
Definition: rv-battery-model.cc:105
sample-rng-plot.alpha
alpha
Definition: sample-rng-plot.py:37
ns3::EnergySource
Introspection did not find any typical Config paths.
Definition: energy-source.h:82
ns3::RvBatteryModel::m_openCircuitVoltage
double m_openCircuitVoltage
Definition: rv-battery-model.h:219
ns3::RvBatteryModel::m_load
std::vector< double > m_load
Definition: rv-battery-model.h:225
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::RvBatteryModel::m_alpha
double m_alpha
Definition: rv-battery-model.h:221
energy-source.h
ns3::RvBatteryModel::DoDispose
virtual void DoDispose(void)
Defined in ns3::Object.
Definition: rv-battery-model.cc:306
ns3::RvBatteryModel::GetInitialEnergy
virtual double GetInitialEnergy(void) const
Definition: rv-battery-model.cc:111
ns3::RvBatteryModel::m_numOfTerms
int m_numOfTerms
Definition: rv-battery-model.h:229
ns3::RvBatteryModel::GetOpenCircuitVoltage
double GetOpenCircuitVoltage(void) const
Definition: rv-battery-model.cc:213
ns3::RvBatteryModel::RvModelAFunction
double RvModelAFunction(Time t, Time sk, Time sk_1, double beta)
RV model A function.
Definition: rv-battery-model.cc:367
ns3::RvBatteryModel::GetSamplingInterval
Time GetSamplingInterval(void) const
Definition: rv-battery-model.cc:198
ns3::TracedValue< double >
ns3::RvBatteryModel::m_beta
double m_beta
Definition: rv-battery-model.h:222
ns3::RvBatteryModel::GetCutoffVoltage
double GetCutoffVoltage(void) const
Definition: rv-battery-model.cc:228
ns3::RvBatteryModel::GetBeta
double GetBeta(void) const
Definition: rv-battery-model.cc:258
ns3::RvBatteryModel::SetAlpha
void SetAlpha(double alpha)
Sets the alpha value for the battery model.
Definition: rv-battery-model.cc:235
ns3::RvBatteryModel::m_batteryLevel
TracedValue< double > m_batteryLevel
Battery level is defined as: output of Discharge function / alpha value.
Definition: rv-battery-model.h:247
ns3::RvBatteryModel::UpdateEnergySource
virtual void UpdateEnergySource(void)
Implements UpdateEnergySource.
Definition: rv-battery-model.cc:141
ns3::RvBatteryModel::m_lastSampleTime
Time m_lastSampleTime
Definition: rv-battery-model.h:227
ns3::RvBatteryModel::GetAlpha
double GetAlpha(void) const
Definition: rv-battery-model.cc:243
ns3::RvBatteryModel::m_samplingInterval
Time m_samplingInterval
(1 / sampling interval) = sampling frequency
Definition: rv-battery-model.h:254
ns3::RvBatteryModel::GetNumOfTerms
int GetNumOfTerms(void) const
Definition: rv-battery-model.cc:287
ns3::RvBatteryModel::m_lowBatteryTh
double m_lowBatteryTh
Definition: rv-battery-model.h:249
ns3::RvBatteryModel::m_timeStamps
std::vector< Time > m_timeStamps
Definition: rv-battery-model.h:226