A Discrete-Event Network Simulator
API
rv-battery-model.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 RV_BATTERY_MODEL_H
21 #define RV_BATTERY_MODEL_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 
52 {
53  public:
58  static TypeId GetTypeId();
60  ~RvBatteryModel() override;
61 
67  double GetInitialEnergy() const override;
68 
74  double GetSupplyVoltage() const override;
75 
81  double GetRemainingEnergy() override;
82 
89  double GetEnergyFraction() override;
90 
95  void UpdateEnergySource() override;
96 
102  void SetSamplingInterval(Time interval);
103 
107  Time GetSamplingInterval() const;
108 
114  void SetOpenCircuitVoltage(double voltage);
115 
119  double GetOpenCircuitVoltage() const;
120 
126  void SetCutoffVoltage(double voltage);
127 
131  double GetCutoffVoltage() const;
132 
138  void SetAlpha(double alpha);
139 
143  double GetAlpha() const;
144 
150  void SetBeta(double beta);
151 
155  double GetBeta() const;
156 
160  double GetBatteryLevel();
161 
165  Time GetLifetime() const;
166 
173  void SetNumOfTerms(int num);
174 
179  int GetNumOfTerms() const;
180 
181  private:
183  void DoInitialize() override;
184 
186  void DoDispose() override;
187 
194 
208  double Discharge(double load, Time t);
209 
221  double RvModelAFunction(Time t, Time sk, Time sk_1, double beta);
222 
223  private:
226  double m_alpha;
227  double m_beta;
228 
229  double m_previousLoad;
230  std::vector<double> m_load;
231  std::vector<Time> m_timeStamps;
233 
235 
253 
254  double m_lowBatteryTh;
255 
262 
264 };
265 
266 } // namespace ns3
267 
268 #endif /* RV_BATTERY_MODEL_H */
An identifier for simulation events.
Definition: event-id.h:55
Rakhmatov Vrudhula non-linear battery model.
double m_lowBatteryTh
low battery threshold, as a fraction of the initial energy
void DoDispose() override
Defined in ns3::Object.
double m_openCircuitVoltage
Open circuit voltage (in Volts)
double GetBeta() const
void SetNumOfTerms(int num)
Sets the number of terms of the infinite sum for estimating battery level.
double m_cutoffVoltage
Cutoff voltage (in Volts)
EventId m_currentSampleEvent
Current sample event.
void SetSamplingInterval(Time interval)
Time m_lastSampleTime
Last sample time.
double GetCutoffVoltage() const
static TypeId GetTypeId()
Get the type ID.
double m_previousLoad
load value (total current) of previous sampling
std::vector< Time > m_timeStamps
time stamps of load profile
int m_numOfTerms
Number# of terms for infinite sum in battery level estimation.
double Discharge(double load, Time t)
Discharges the battery.
Time GetSamplingInterval() const
void SetCutoffVoltage(double voltage)
Sets cutoff voltage of battery.
void SetBeta(double beta)
Sets the beta value for the battery model.
double GetEnergyFraction() override
double GetInitialEnergy() const override
double GetOpenCircuitVoltage() const
std::vector< double > m_load
load profile
TracedValue< Time > m_lifetime
time of death of the battery
Time m_samplingInterval
Sampling interval.
void SetOpenCircuitVoltage(double voltage)
Sets open circuit voltage of battery.
double RvModelAFunction(Time t, Time sk, Time sk_1, double beta)
RV model A function.
void SetAlpha(double alpha)
Sets the alpha value for the battery model.
void HandleEnergyDrainedEvent()
Handles the remaining energy going to zero event.
double GetAlpha() const
void DoInitialize() override
Defined in ns3::Object.
double m_alpha
alpha value of RV model, in Coulomb
double GetSupplyVoltage() const override
TracedValue< double > m_batteryLevel
Battery level is defined as: output of Discharge function / alpha value.
void UpdateEnergySource() override
Implements UpdateEnergySource.
double GetRemainingEnergy() override
double m_beta
beta value of RV model, in second^-1
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.