A Discrete-Event Network Simulator
API
energy-source.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  * Copyright (c) 2014 Wireless Communications and Networking Group (WCNG),
20  * University of Rochester, Rochester, NY, USA.
21  *
22  * Modifications made by: Cristiano Tapparello <cristiano.tapparello@rochester.edu>
23  */
24 
25 #ifndef ENERGY_SOURCE_H
26 #define ENERGY_SOURCE_H
27 
28 #include "device-energy-model-container.h" // #include "device-energy-model.h"
29 #include "energy-harvester.h"
30 
31 #include "ns3/node.h"
32 #include "ns3/object.h"
33 #include "ns3/ptr.h"
34 #include "ns3/type-id.h"
35 
36 namespace ns3
37 {
38 
84 class EnergyHarvester;
85 
86 class EnergySource : public Object
87 {
88  public:
93  static TypeId GetTypeId();
94  EnergySource();
95  ~EnergySource() override;
96 
103  virtual double GetSupplyVoltage() const = 0;
104 
111  virtual double GetInitialEnergy() const = 0;
112 
116  virtual double GetRemainingEnergy() = 0;
117 
123  virtual double GetEnergyFraction() = 0;
124 
130  virtual void UpdateEnergySource() = 0;
131 
137  void SetNode(Ptr<Node> node);
138 
145  Ptr<Node> GetNode() const;
146 
153  void AppendDeviceEnergyModel(Ptr<DeviceEnergyModel> deviceEnergyModelPtr);
154 
160 
166 
172  void InitializeDeviceModels();
173 
179  void DisposeDeviceModels();
180 
190  void ConnectEnergyHarvester(Ptr<EnergyHarvester> energyHarvesterPtr);
191 
192  private:
199  void DoDispose() override;
200 
201  private:
206 
212 
218  std::vector<Ptr<EnergyHarvester>> m_harvesters;
219 
220  protected:
224  double CalculateTotalCurrent();
225 
230  void NotifyEnergyDrained();
231 
236  void NotifyEnergyRecharged();
237 
242  void NotifyEnergyChanged();
243 
254 };
255 
256 } // namespace ns3
257 
258 #endif /* ENERGY_SOURCE_H */
Holds a vector of ns3::DeviceEnergyModel pointers.
void AppendDeviceEnergyModel(Ptr< DeviceEnergyModel > deviceEnergyModelPtr)
void ConnectEnergyHarvester(Ptr< EnergyHarvester > energyHarvesterPtr)
void DisposeDeviceModels()
Calls Dispose () method of the device energy models.
virtual double GetInitialEnergy() const =0
double CalculateTotalCurrent()
virtual double GetEnergyFraction()=0
void NotifyEnergyRecharged()
This function notifies all DeviceEnergyModel of energy recharged event.
void InitializeDeviceModels()
Calls Start () method of the device energy models.
virtual double GetRemainingEnergy()=0
DeviceEnergyModelContainer m_models
List of device energy models installed on the same node.
Ptr< Node > m_node
Pointer to node containing this EnergySource.
void NotifyEnergyChanged()
This function notifies all DeviceEnergyModel of energy changed event.
void BreakDeviceEnergyModelRefCycle()
This function is called to break reference cycle between EnergySource and DeviceEnergyModel.
virtual void UpdateEnergySource()=0
This function goes through the list of DeviceEnergyModels to obtain total current draw at the energy ...
void NotifyEnergyDrained()
This function notifies all DeviceEnergyModel of energy depletion event.
std::vector< Ptr< EnergyHarvester > > m_harvesters
Vector of EnergyHarvester pointer connected to the same energy source.
Ptr< Node > GetNode() const
static TypeId GetTypeId()
Get the type ID.
DeviceEnergyModelContainer FindDeviceEnergyModels(TypeId tid)
~EnergySource() override
void DoDispose() override
All child's implementation must call BreakDeviceEnergyModelRefCycle to ensure reference cycles to Dev...
void SetNode(Ptr< Node > node)
Sets pointer to node containing this EnergySource.
virtual double GetSupplyVoltage() const =0
A base class which provides memory management and object aggregation.
Definition: object.h:89
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.