Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 * call dispose method here. | 130 * call dispose method here. |
131 */ | 131 */ |
132 DeviceEnergyModelContainer::Iterator i; | 132 DeviceEnergyModelContainer::Iterator i; |
133 for (i = m_models.Begin (); i != m_models.End (); i++) | 133 for (i = m_models.Begin (); i != m_models.End (); i++) |
134 { | 134 { |
135 (*i)->Dispose (); | 135 (*i)->Dispose (); |
136 } | 136 } |
137 } | 137 } |
138 ·· | 138 ·· |
139 void | 139 void |
140 EnergySource::AppendEnergyHarvester (Ptr<EnergyHarvester> energyHarvesterPtr) | 140 EnergySource::ConnectEnergyHarvester (Ptr<EnergyHarvester> energyHarvesterPtr) |
141 { | 141 { |
142 NS_LOG_FUNCTION (this << energyHarvesterPtr); | 142 NS_LOG_FUNCTION (this << energyHarvesterPtr); |
143 NS_ASSERT (energyHarvesterPtr != NULL); // energy harvester must exist | 143 NS_ASSERT (energyHarvesterPtr != NULL); // energy harvester must exist |
144 m_harvesters.push_back (energyHarvesterPtr); | 144 m_harvesters.push_back (energyHarvesterPtr); |
145 } | 145 } |
146 | 146 |
147 /* | 147 /* |
148 * Private function starts here. | 148 * Private function starts here. |
149 */ | 149 */ |
150 | 150 |
(...skipping 13 matching lines...) Expand all Loading... | |
164 { | 164 { |
165 NS_LOG_FUNCTION (this); | 165 NS_LOG_FUNCTION (this); |
166 double totalCurrentA = 0.0; | 166 double totalCurrentA = 0.0; |
167 DeviceEnergyModelContainer::Iterator i; | 167 DeviceEnergyModelContainer::Iterator i; |
168 for (i = m_models.Begin (); i != m_models.End (); i++) | 168 for (i = m_models.Begin (); i != m_models.End (); i++) |
169 { | 169 { |
170 totalCurrentA += (*i)->GetCurrentA (); | 170 totalCurrentA += (*i)->GetCurrentA (); |
171 } | 171 } |
172 ·· | 172 ·· |
173 double totalHarvestedPower = 0.0; | 173 double totalHarvestedPower = 0.0; |
174 ·· | |
175 NS_LOG_DEBUG ("EnergySource("<< GetNode ()->GetId () << "): Total harvested po wer = " << totalHarvestedPower); | |
Stefano Avallone
2014/07/21 15:57:48
totalHarvestedPower is always zero here. Shouldn't
cristiano.tapparello
2014/09/04 00:36:31
Definitely, thanks for catching this!
On 2014/07/
| |
176 ·· | 174 ·· |
177 std::vector< Ptr<EnergyHarvester> >::const_iterator harvester; | 175 std::vector< Ptr<EnergyHarvester> >::const_iterator harvester; |
178 for (harvester = m_harvesters.begin (); harvester != m_harvesters.end (); harv ester++) | 176 for (harvester = m_harvesters.begin (); harvester != m_harvesters.end (); harv ester++) |
179 { | 177 { |
180 totalHarvestedPower += (*harvester)->GetPower (); | 178 totalHarvestedPower += (*harvester)->GetPower (); |
181 } | 179 } |
182 ·· | 180 ·· |
181 NS_LOG_DEBUG ("EnergySource("<< GetNode ()->GetId () << "): Total harvested po wer = " << totalHarvestedPower); | |
182 | |
183 double currentHarvestersA = totalHarvestedPower / GetSupplyVoltage (); | 183 double currentHarvestersA = totalHarvestedPower / GetSupplyVoltage (); |
184 NS_LOG_DEBUG ("EnergySource("<< GetNode ()->GetId () << "): Current from harve sters = " << currentHarvestersA); | 184 NS_LOG_DEBUG ("EnergySource("<< GetNode ()->GetId () << "): Current from harve sters = " << currentHarvestersA); |
185 ·· | 185 ·· |
186 totalCurrentA -= currentHarvestersA; | 186 totalCurrentA -= currentHarvestersA; |
187 ·· | 187 ·· |
188 return totalCurrentA; | 188 return totalCurrentA; |
189 } | 189 } |
190 | 190 |
191 void | 191 void |
192 EnergySource::NotifyEnergyDrained (void) | 192 EnergySource::NotifyEnergyDrained (void) |
(...skipping 10 matching lines...) Expand all Loading... | |
203 void | 203 void |
204 EnergySource::BreakDeviceEnergyModelRefCycle (void) | 204 EnergySource::BreakDeviceEnergyModelRefCycle (void) |
205 { | 205 { |
206 NS_LOG_FUNCTION (this); | 206 NS_LOG_FUNCTION (this); |
207 m_models.Clear (); | 207 m_models.Clear (); |
208 m_harvesters.clear (); | 208 m_harvesters.clear (); |
209 m_node = NULL; | 209 m_node = NULL; |
210 } | 210 } |
211 | 211 |
212 } // namespace ns3 | 212 } // namespace ns3 |
LEFT | RIGHT |