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 */
double Discharge(double load, Time t)
Discharges the battery.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void SetOpenCircuitVoltage(double voltage)
Sets open circuit voltage of battery.
Time m_samplingInterval
(1 / sampling interval) = sampling frequency
Time GetSamplingInterval(void) const
virtual double GetSupplyVoltage(void) const
Introspection did not find any typical Config paths.
Definition: energy-source.h:81
double GetBeta(void) const
void SetBeta(double beta)
Sets the beta value for the battery model.
virtual double GetInitialEnergy(void) const
void HandleEnergyDrainedEvent(void)
Handles the remaining energy going to zero event.
void SetNumOfTerms(int num)
Sets the number of terms of the infinite sum for estimating battery level.
void SetCutoffVoltage(double voltage)
Sets cutoff voltage of battery.
double GetAlpha(void) const
virtual void DoInitialize(void)
Defined in ns3::Object.
Time GetLifetime(void) const
void SetSamplingInterval(Time interval)
std::vector< Time > m_timeStamps
virtual void DoDispose(void)
Defined in ns3::Object.
double RvModelAFunction(Time t, Time sk, Time sk_1, double beta)
RV model A function.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TracedValue< Time > m_lifetime
static TypeId GetTypeId(void)
An identifier for simulation events.
Definition: event-id.h:53
TracedValue< double > m_batteryLevel
Battery level is defined as: output of Discharge function / alpha value.
virtual double GetRemainingEnergy(void)
virtual void UpdateEnergySource(void)
Implements UpdateEnergySource.
double GetOpenCircuitVoltage(void) const
Rakhmatov Vrudhula non-linear battery model.
int GetNumOfTerms(void) const
std::vector< double > m_load
a unique identifier for an interface.
Definition: type-id.h:58
double GetCutoffVoltage(void) const
void SetAlpha(double alpha)
Sets the alpha value for the battery model.
virtual double GetEnergyFraction(void)
double GetBatteryLevel(void)