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