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 
79 class EnergyHarvester;
80 
81 class EnergySource : public Object
82 {
83 public:
84  static TypeId GetTypeId (void);
85  EnergySource ();
86  virtual ~EnergySource ();
87 
94  virtual double GetSupplyVoltage (void) const = 0;
95 
102  virtual double GetInitialEnergy (void) const = 0;
103 
107  virtual double GetRemainingEnergy (void) = 0;
108 
114  virtual double GetEnergyFraction (void) = 0;
115 
121  virtual void UpdateEnergySource (void) = 0;
122 
128  void SetNode (Ptr<Node> node);
129 
136  Ptr<Node> GetNode (void) const;
137 
144  void AppendDeviceEnergyModel (Ptr<DeviceEnergyModel> deviceEnergyModelPtr);
145 
151 
157 
163  void InitializeDeviceModels (void);
164 
170  void DisposeDeviceModels (void);
171 
181  void ConnectEnergyHarvester (Ptr<EnergyHarvester> energyHarvesterPtr);
182 
183 
184 private:
191  virtual void DoDispose (void);
192 
193 private:
198 
204 
210  std::vector< Ptr<EnergyHarvester> > m_harvesters;
211 
212 
213 protected:
217  double CalculateTotalCurrent (void);
218 
223  void NotifyEnergyDrained (void);
224 
229  void NotifyEnergyRecharged (void);
230 
235  void NotifyEnergyChanged (void);
236 
246  void BreakDeviceEnergyModelRefCycle (void);
247 
248 };
249 
250 } // namespace ns3
251 
252 #endif /* ENERGY_SOURCE_H */
Introspection did not find any typical Config paths.
Definition: energy-source.h:81
Holds a vector of ns3::DeviceEnergyModel pointers.
virtual void UpdateEnergySource(void)=0
This function goes through the list of DeviceEnergyModels to obtain total current draw at the energy ...
virtual double GetInitialEnergy(void) const =0
void BreakDeviceEnergyModelRefCycle(void)
This function is called to break reference cycle between EnergySource and DeviceEnergyModel.
void NotifyEnergyRecharged(void)
This function notifies all DeviceEnergyModel of energy recharged event.
void NotifyEnergyChanged(void)
This function notifies all DeviceEnergyModel of energy changed event.
virtual void DoDispose(void)
All child&#39;s implementation must call BreakDeviceEnergyModelRefCycle to ensure reference cycles to Dev...
static TypeId GetTypeId(void)
double CalculateTotalCurrent(void)
void ConnectEnergyHarvester(Ptr< EnergyHarvester > energyHarvesterPtr)
void InitializeDeviceModels(void)
Calls Start () method of the device energy models.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void AppendDeviceEnergyModel(Ptr< DeviceEnergyModel > deviceEnergyModelPtr)
virtual ~EnergySource()
Ptr< Node > m_node
Pointer to node containing this EnergySource.
virtual double GetRemainingEnergy(void)=0
void NotifyEnergyDrained(void)
This function notifies all DeviceEnergyModel of energy depletion event.
virtual double GetEnergyFraction(void)=0
std::vector< Ptr< EnergyHarvester > > m_harvesters
Vector of EnergyHarvester pointer connected to the same energy source.
DeviceEnergyModelContainer m_models
List of device energy models installed on the same node.
void DisposeDeviceModels(void)
Calls Dispose () method of the device energy models.
DeviceEnergyModelContainer FindDeviceEnergyModels(TypeId tid)
A base class which provides memory management and object aggregation.
Definition: object.h:87
void SetNode(Ptr< Node > node)
Sets pointer to node containing this EnergySource.
a unique identifier for an interface.
Definition: type-id.h:58
Ptr< Node > GetNode(void) const
virtual double GetSupplyVoltage(void) const =0