OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle. | 3 * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle. |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Authors: Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu> | 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.e
du> |
19 */ | 24 */ |
20 | 25 |
| 26 |
21 #ifndef ENERGY_SOURCE_H | 27 #ifndef ENERGY_SOURCE_H |
22 #define ENERGY_SOURCE_H | 28 #define ENERGY_SOURCE_H |
23 | 29 |
24 #include "ns3/object.h" | 30 #include "ns3/object.h" |
25 #include "ns3/ptr.h" | 31 #include "ns3/ptr.h" |
26 #include "ns3/type-id.h" | 32 #include "ns3/type-id.h" |
27 #include "ns3/node.h" | 33 #include "ns3/node.h" |
28 #include "device-energy-model-container.h" // #include "device-energy-model.h" | 34 #include "device-energy-model-container.h" // #include "device-energy-model.h" |
| 35 #include "ns3/energy-harvester.h" |
29 | 36 |
30 namespace ns3 { | 37 namespace ns3 { |
31 | 38 |
32 /** | 39 /** |
33 * \defgroup energy Energy Models | 40 * \defgroup energy Energy Models |
34 * | 41 * |
35 */ | 42 */ |
36 | 43 |
37 /** | 44 /** |
38 * \ingroup energy | 45 * \ingroup energy |
39 * | 46 * |
40 * \brief Energy source base class. | 47 * \brief Energy source base class. |
41 * | 48 * |
(...skipping 19 matching lines...) Expand all Loading... |
61 * DeviceEnergyModel to calculate energy to decrease from the source. Indirect | 68 * DeviceEnergyModel to calculate energy to decrease from the source. Indirect |
62 * energy update interface is typically used by DeviceEnergyModel who knows its | 69 * energy update interface is typically used by DeviceEnergyModel who knows its |
63 * current draw for each of its states. Nonlinear EnergySource also uses this | 70 * current draw for each of its states. Nonlinear EnergySource also uses this |
64 * interface. | 71 * interface. |
65 * | 72 * |
66 * Unit of energy is chosen as Joules since energy models typically calculate | 73 * Unit of energy is chosen as Joules since energy models typically calculate |
67 * energy as (time in seconds * power in Watts). If the energy source stores | 74 * energy as (time in seconds * power in Watts). If the energy source stores |
68 * energy in different units (eg. kWh), a simple converter function should | 75 * energy in different units (eg. kWh), a simple converter function should |
69 * suffice. | 76 * suffice. |
70 */ | 77 */ |
| 78 ·· |
| 79 class EnergyHarvester; |
| 80 ·· |
71 class EnergySource : public Object | 81 class EnergySource : public Object |
72 { | 82 { |
73 public: | 83 public: |
74 static TypeId GetTypeId (void); | 84 static TypeId GetTypeId (void); |
75 EnergySource (); | 85 EnergySource (); |
76 virtual ~EnergySource (); | 86 virtual ~EnergySource (); |
77 | 87 |
78 /** | 88 /** |
79 * \returns Supply voltage of the energy source. | 89 * \returns Supply voltage of the energy source. |
80 * | 90 * |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 * Called by EnergySourceContainer, which is aggregated to the node. | 161 * Called by EnergySourceContainer, which is aggregated to the node. |
152 */ | 162 */ |
153 void InitializeDeviceModels (void); | 163 void InitializeDeviceModels (void); |
154 | 164 |
155 /** | 165 /** |
156 * Calls Dispose () method of the device energy models. Device energy models | 166 * Calls Dispose () method of the device energy models. Device energy models |
157 * are not aggregated to the node, therefore we need to manually start them | 167 * are not aggregated to the node, therefore we need to manually start them |
158 * here. Called by EnergySourceContainer, which is aggregated to the node. | 168 * here. Called by EnergySourceContainer, which is aggregated to the node. |
159 */ | 169 */ |
160 void DisposeDeviceModels (void); | 170 void DisposeDeviceModels (void); |
| 171 ·· |
| 172 /** |
| 173 * \param energyHarvesterPtr Pointer to energy harvester. |
| 174 * |
| 175 * This function connect an energy harvester to the energy source. After the |
| 176 * execution of this method, the pointer to the energy harvester is appended |
| 177 * to the end of a vector of EnergyHarvester pointer. |
| 178 * Note that the order in which different energy harvester are added to the |
| 179 * energy source does not impact the simulation results. |
| 180 */ |
| 181 void ConnectEnergyHarvester (Ptr<EnergyHarvester> energyHarvesterPtr); |
161 | 182 |
162 | 183 |
163 private: | 184 private: |
164 /** | 185 /** |
165 * All child's implementation must call BreakDeviceEnergyModelRefCycle to | 186 * All child's implementation must call BreakDeviceEnergyModelRefCycle to |
166 * ensure reference cycles to DeviceEnergyModel objects are broken. | 187 * ensure reference cycles to DeviceEnergyModel objects are broken. |
167 * | 188 * |
168 * Defined in ns3::Object | 189 * Defined in ns3::Object |
169 */ | 190 */ |
170 virtual void DoDispose (void); | 191 virtual void DoDispose (void); |
171 | 192 |
172 private: | 193 private: |
173 /** | 194 /** |
174 * List of device energy models installed on the same node. | 195 * List of device energy models installed on the same node. |
175 */ | 196 */ |
176 DeviceEnergyModelContainer m_models; | 197 DeviceEnergyModelContainer m_models; |
177 | 198 |
178 /** | 199 /** |
179 * Pointer to node containing this EnergySource. Used by helper class to make | 200 * Pointer to node containing this EnergySource. Used by helper class to make |
180 * sure device models are installed onto the corresponding node. | 201 * sure device models are installed onto the corresponding node. |
181 */ | 202 */ |
182 Ptr<Node> m_node; | 203 Ptr<Node> m_node; |
| 204 ···· |
| 205 /** |
| 206 * Vector of EnergyHarvester pointer connected to the same energy source. |
| 207 * This vector is used by the CalculateTotalCurrent method to determine the |
| 208 * total power provided by the energy harvesters connected to the energy source
. |
| 209 */ |
| 210 std::vector< Ptr<EnergyHarvester> > m_harvesters; |
183 | 211 |
184 | 212 |
185 protected: | 213 protected: |
186 /** | 214 /** |
187 * \returns Total current draw from all DeviceEnergyModels. | 215 * \returns Total current draw from all DeviceEnergyModels. |
188 */ | 216 */ |
189 double CalculateTotalCurrent (void); | 217 double CalculateTotalCurrent (void); |
190 | 218 |
191 /** | 219 /** |
192 * This function notifies all DeviceEnergyModel of energy depletion event. It | 220 * This function notifies all DeviceEnergyModel of energy depletion event. It |
(...skipping 10 matching lines...) Expand all Loading... |
203 * Normally this work will be completed by the DoDispose function. However it | 231 * Normally this work will be completed by the DoDispose function. However it |
204 * will be overridden in the child class. Hence we introduced this function. | 232 * will be overridden in the child class. Hence we introduced this function. |
205 */ | 233 */ |
206 void BreakDeviceEnergyModelRefCycle (void); | 234 void BreakDeviceEnergyModelRefCycle (void); |
207 | 235 |
208 }; | 236 }; |
209 | 237 |
210 } // namespace ns3 | 238 } // namespace ns3 |
211 | 239 |
212 #endif /* ENERGY_SOURCE_H */ | 240 #endif /* ENERGY_SOURCE_H */ |
OLD | NEW |