A Discrete-Event Network Simulator
API
li-ion-energy-source.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 Andrea Sacco
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  * Author: Andrea Sacco <andrea.sacco85@gmail.com>
19  */
20 
21 #ifndef LI_ION_ENERGY_SOURCE_H
22 #define LI_ION_ENERGY_SOURCE_H
23 
24 #include "ns3/traced-value.h"
25 #include "ns3/energy-source.h"
26 #include "ns3/nstime.h"
27 #include "ns3/event-id.h"
28 
29 namespace ns3 {
30 
73 {
74 public:
75  static TypeId GetTypeId (void);
77  virtual ~LiIonEnergySource ();
78 
84  virtual double GetInitialEnergy (void) const;
85 
92  void SetInitialEnergy (double initialEnergyJ);
93 
99  virtual double GetSupplyVoltage (void) const;
100 
107  void SetInitialSupplyVoltage (double supplyVoltageV);
108 
114  virtual double GetRemainingEnergy (void);
115 
121  virtual double GetEnergyFraction (void);
122 
128  virtual void DecreaseRemainingEnergy (double energyJ);
129 
135  virtual void IncreaseRemainingEnergy (double energyJ);
136 
140  virtual void UpdateEnergySource (void);
141 
147  void SetEnergyUpdateInterval (Time interval);
148 
152  Time GetEnergyUpdateInterval (void) const;
153 private:
154  void DoInitialize (void);
155  void DoDispose (void);
156 
162  void HandleEnergyDrainedEvent (void);
163 
172  void CalculateRemainingEnergy (void);
173 
181  double GetVoltage (double current) const;
182 
183 private:
184  double m_initialEnergyJ; // initial energy, in Joules
185  TracedValue<double> m_remainingEnergyJ; // remaining energy, in Joules
186  double m_drainedCapacity; // capacity drained from the cell, in Ah
187  double m_supplyVoltageV; // actual voltage of the cell
188  double m_lowBatteryTh; // low battery threshold, as a fraction of the initial energy
189  EventId m_energyUpdateEvent; // energy update event
190  Time m_lastUpdateTime; // last update time
191  Time m_energyUpdateInterval; // energy update interval
192  double m_eFull; // initial voltage of the cell, in Volts
193  double m_eNom; // nominal voltage of the cell, in Volts
194  double m_eExp; // cell voltage at the end of the exponential zone, in Volts
195  double m_internalResistance; // internal resistance of the cell, in Ohms
196  double m_qRated; // rated capacity of the cell, in Ah
197  double m_qNom; // cell capacity at the end of the nominal zone, in Ah
198  double m_qExp; // capacity value at the end of the exponential zone, in Ah
199  double m_typCurrent; // typical discharge current used to fit the curves
200  double m_minVoltTh; // minimum threshold voltage to consider the battery depleted
201 };
202 
203 } // namespace ns3
204 
205 #endif /* LI_ION_ENERGY_SOURCE_H */
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
virtual double GetSupplyVoltage(void) const
void SetEnergyUpdateInterval(Time interval)
virtual double GetEnergyFraction(void)
Introspection did not find any typical Config paths.
Definition: energy-source.h:81
void DoDispose(void)
All child&#39;s implementation must call BreakDeviceEnergyModelRefCycle to ensure reference cycles to Dev...
virtual void UpdateEnergySource(void)
Implements UpdateEnergySource.
static TypeId GetTypeId(void)
void CalculateRemainingEnergy(void)
Calculates remaining energy.
virtual double GetRemainingEnergy(void)
TracedValue< double > m_remainingEnergyJ
double GetVoltage(double current) const
Time GetEnergyUpdateInterval(void) const
void SetInitialSupplyVoltage(double supplyVoltageV)
void HandleEnergyDrainedEvent(void)
Handles the remaining energy going to zero event.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
An identifier for simulation events.
Definition: event-id.h:53
virtual void DecreaseRemainingEnergy(double energyJ)
virtual void IncreaseRemainingEnergy(double energyJ)
void SetInitialEnergy(double initialEnergyJ)
Model a generic Lithium Ion Battery basing on [1][2].
void DoInitialize(void)
Initialize() implementation.
a unique identifier for an interface.
Definition: type-id.h:58
virtual double GetInitialEnergy(void) const