author | Vedran Miletić <rivanvx@gmail.com> |
Fri, 19 Apr 2013 22:39:55 +0200 | |
changeset 9703 | 681f35b212ff |
parent 7385 | 10beb0e53130 |
child 10883 | d919e7194e23 |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7238
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
6429 | 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 |
||
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
21 |
#ifndef BASIC_ENERGY_SOURCE_H |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
22 |
#define BASIC_ENERGY_SOURCE_H |
6429 | 23 |
|
24 |
#include "ns3/traced-value.h" |
|
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
25 |
#include "ns3/nstime.h" |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
26 |
#include "ns3/event-id.h" |
6429 | 27 |
#include "energy-source.h" |
28 |
||
29 |
namespace ns3 { |
|
30 |
||
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
31 |
/** |
7238
85a7e87bb4cc
Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents:
6938
diff
changeset
|
32 |
* \ingroup energy |
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
33 |
* BasicEnergySource decreases/increases remaining energy stored in itself in |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
34 |
* linearly. |
7238
85a7e87bb4cc
Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents:
6938
diff
changeset
|
35 |
* |
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
36 |
*/ |
6429 | 37 |
class BasicEnergySource : public EnergySource |
38 |
{ |
|
39 |
public: |
|
40 |
static TypeId GetTypeId (void); |
|
41 |
BasicEnergySource (); |
|
42 |
virtual ~BasicEnergySource (); |
|
43 |
||
44 |
/** |
|
45 |
* \return Initial energy stored in energy source, in Joules. |
|
46 |
* |
|
47 |
* Implements GetInitialEnergy. |
|
48 |
*/ |
|
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
49 |
virtual double GetInitialEnergy (void) const; |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
50 |
|
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
51 |
/** |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
52 |
* \returns Supply voltage at the energy source. |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
53 |
* |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
54 |
* Implements GetSupplyVoltage. |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
55 |
*/ |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
56 |
virtual double GetSupplyVoltage (void) const; |
6429 | 57 |
|
58 |
/** |
|
59 |
* \return Remaining energy in energy source, in Joules |
|
60 |
* |
|
61 |
* Implements GetRemainingEnergy. |
|
62 |
*/ |
|
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
63 |
virtual double GetRemainingEnergy (void); |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
64 |
|
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
65 |
/** |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
66 |
* \returns Energy fraction. |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
67 |
* |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
68 |
* Implements GetEnergyFraction. |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
69 |
*/ |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
70 |
virtual double GetEnergyFraction (void); |
6429 | 71 |
|
72 |
/** |
|
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
73 |
* Implements UpdateEnergySource. |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
74 |
*/ |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
75 |
virtual void UpdateEnergySource (void); |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
76 |
|
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
77 |
/** |
6553
fb5ad9c7755a
update release notes and fix doxygen warnings
Josh Pelkey <jpelkey@gatech.edu>
parents:
6535
diff
changeset
|
78 |
* \param initialEnergyJ Initial energy, in Joules |
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
79 |
* |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
80 |
* Sets initial energy stored in the energy source. Note that initial energy |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
81 |
* is assumed to be set before simulation starts and is set only once per |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
82 |
* simulation. |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
83 |
*/ |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
84 |
void SetInitialEnergy (double initialEnergyJ); |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
85 |
|
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
86 |
/** |
6553
fb5ad9c7755a
update release notes and fix doxygen warnings
Josh Pelkey <jpelkey@gatech.edu>
parents:
6535
diff
changeset
|
87 |
* \param supplyVoltageV Supply voltage at the energy source, in Volts. |
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
88 |
* |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
89 |
* Sets supply voltage of the energy source. |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
90 |
*/ |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
91 |
void SetSupplyVoltage (double supplyVoltageV); |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
92 |
|
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
93 |
/** |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
94 |
* \param interval Energy update interval. |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
95 |
* |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
96 |
* This function sets the interval between each energy update. |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
97 |
*/ |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
98 |
void SetEnergyUpdateInterval (Time interval); |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
99 |
|
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
100 |
/** |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
101 |
* \returns The interval between each energy update. |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
102 |
*/ |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
103 |
Time GetEnergyUpdateInterval (void) const; |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
104 |
|
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
105 |
|
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
106 |
private: |
6699
d8909a1fd0ff
RV battery model and WiFi energy example
He Wu <mdzz@u.washington.edu>
parents:
6553
diff
changeset
|
107 |
/// Defined in ns3::Object |
9703
681f35b212ff
Rename Start and DoStart methods to Initialize and DoInitialize
Vedran Miletić <rivanvx@gmail.com>
parents:
7385
diff
changeset
|
108 |
void DoInitialize (void); |
6699
d8909a1fd0ff
RV battery model and WiFi energy example
He Wu <mdzz@u.washington.edu>
parents:
6553
diff
changeset
|
109 |
|
d8909a1fd0ff
RV battery model and WiFi energy example
He Wu <mdzz@u.washington.edu>
parents:
6553
diff
changeset
|
110 |
/// Defined in ns3::Object |
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
111 |
void DoDispose (void); |
6429 | 112 |
|
113 |
/** |
|
114 |
* Handles the remaining energy going to zero event. This function notifies |
|
115 |
* all the energy models aggregated to the node about the energy being |
|
116 |
* depleted. Each energy model is then responsible for its own handler. |
|
117 |
*/ |
|
118 |
void HandleEnergyDrainedEvent (void); |
|
119 |
||
120 |
/** |
|
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
121 |
* Calculates remaining energy. This function uses the total current from all |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
122 |
* device models to calculate the amount of energy to decrease. The energy to |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
123 |
* decrease is given by: |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
124 |
* energy to decrease = total current * supply voltage * time duration |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
125 |
* This function subtracts the calculated energy to decrease from remaining |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
126 |
* energy. |
6429 | 127 |
*/ |
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
128 |
void CalculateRemainingEnergy (void); |
6429 | 129 |
|
130 |
private: |
|
131 |
double m_initialEnergyJ; // initial energy, in Joules |
|
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
132 |
double m_supplyVoltageV; // supply voltage, in Volts |
6429 | 133 |
TracedValue<double> m_remainingEnergyJ; // remaining energy, in Joules |
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
134 |
EventId m_energyUpdateEvent; // energy update event |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
135 |
Time m_lastUpdateTime; // last update time |
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
136 |
Time m_energyUpdateInterval; // energy update interval |
6429 | 137 |
|
138 |
}; |
|
139 |
||
140 |
} // namespace ns3 |
|
141 |
||
6535
0a90ef2b29a9
Apply energy model changes of http://codereview.appspot.com/1008043/show patchset 13
He Wu <mdzz@u.washington.edu>
parents:
6445
diff
changeset
|
142 |
#endif /* BASIC_ENERGY_SOURCE_H */ |