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 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 void DoDispose (void); | 111 void DoDispose (void); |
112 | 112 |
113 /** | 113 /** |
114 * Handles the remaining energy going to zero event. This function notifies | 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 | 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. | 116 * depleted. Each energy model is then responsible for its own handler. |
117 */ | 117 */ |
118 void HandleEnergyDrainedEvent (void); | 118 void HandleEnergyDrainedEvent (void); |
119 | 119 |
120 /** | 120 /** |
| 121 * Handles the remaining energy exceeding the high threshold after it went |
| 122 * below the low threshold. This function notifies all the energy models |
| 123 * aggregated to the node about the energy being recharged. Each energy model |
| 124 * is then responsible for its own handler. |
| 125 */ |
| 126 void HandleEnergyRechargedEvent (void); |
| 127 |
| 128 /** |
121 * Calculates remaining energy. This function uses the total current from all | 129 * Calculates remaining energy. This function uses the total current from all |
122 * device models to calculate the amount of energy to decrease. The energy to | 130 * device models to calculate the amount of energy to decrease. The energy to |
123 * decrease is given by: | 131 * decrease is given by: |
124 * energy to decrease = total current * supply voltage * time duration | 132 * energy to decrease = total current * supply voltage * time duration |
125 * This function subtracts the calculated energy to decrease from remaining | 133 * This function subtracts the calculated energy to decrease from remaining |
126 * energy. | 134 * energy. |
127 */ | 135 */ |
128 void CalculateRemainingEnergy (void); | 136 void CalculateRemainingEnergy (void); |
129 | 137 |
130 private: | 138 private: |
131 double m_initialEnergyJ; // initial energy, in Joules | 139 double m_initialEnergyJ; // initial energy, in Joules |
132 double m_supplyVoltageV; // supply voltage, in Volts | 140 double m_supplyVoltageV; // supply voltage, in Volts |
133 double m_lowBatteryTh; // low battery threshold, as a fractio
n of the initial energy | 141 double m_lowBatteryTh; // low battery threshold, as a fractio
n of the initial energy |
| 142 double m_highBatteryTh; // high battery threshold, as a fracti
on of the initial energy |
| 143 bool m_depleted; // set to true when the remaining ener
gy goes below the low threshold, |
| 144 // set to false again when the remaini
ng energy exceeds the high threshold |
134 TracedValue<double> m_remainingEnergyJ; // remaining energy, in Joules | 145 TracedValue<double> m_remainingEnergyJ; // remaining energy, in Joules |
135 EventId m_energyUpdateEvent; // energy update event | 146 EventId m_energyUpdateEvent; // energy update event |
136 Time m_lastUpdateTime; // last update time | 147 Time m_lastUpdateTime; // last update time |
137 Time m_energyUpdateInterval; // energy update interval | 148 Time m_energyUpdateInterval; // energy update interval |
138 | 149 |
139 }; | 150 }; |
140 | 151 |
141 } // namespace ns3 | 152 } // namespace ns3 |
142 | 153 |
143 #endif /* BASIC_ENERGY_SOURCE_H */ | 154 #endif /* BASIC_ENERGY_SOURCE_H */ |
OLD | NEW |