|
|
| 126 |
void |
126 |
void |
| 127 |
RemainingEnergy (double oldValue, double remainingEnergy) |
127 |
RemainingEnergy (double oldValue, double remainingEnergy) |
| 128 |
{ |
128 |
{ |
| 129 |
std::cout << Simulator::Now ().GetSeconds () |
129 |
NS_LOG_UNCOND (Simulator::Now ().GetSeconds () |
| 130 |
<< "s Current remaining energy = " << remainingEnergy << "J" << std::endl; |
130 |
<< "s Current remaining energy = " << remainingEnergy << "J"); |
| 131 |
} |
131 |
} |
| 132 |
|
132 |
|
| 133 |
/// Trace function for total energy consumption at node. |
133 |
/// Trace function for total energy consumption at node. |
| 134 |
void |
134 |
void |
| 135 |
TotalEnergy (double oldValue, double totalEnergy) |
135 |
TotalEnergy (double oldValue, double totalEnergy) |
| 136 |
{ |
136 |
{ |
| 137 |
std::cout << Simulator::Now ().GetSeconds () |
137 |
NS_LOG_UNCOND (Simulator::Now ().GetSeconds () |
| 138 |
<< "s Total energy consumed by radio = " << totalEnergy << "J" << std::endl; |
138 |
<< "s Total energy consumed by radio = " << totalEnergy << "J"); |
| 139 |
} |
139 |
} |
| 140 |
|
140 |
|
| 141 |
/// Trace function for the power harvested by the energy harvester. |
141 |
/// Trace function for the power harvested by the energy harvester. |
| 142 |
void |
142 |
void |
| 143 |
HarvestedPower (double oldValue, double harvestedPower) |
143 |
HarvestedPower (double oldValue, double harvestedPower) |
| 144 |
{ |
144 |
{ |
| 145 |
std::cout << Simulator::Now ().GetSeconds () |
145 |
NS_LOG_UNCOND (Simulator::Now ().GetSeconds () |
| 146 |
<< "s Current harvested power = " << harvestedPower << " W" << std::endl; |
146 |
<< "s Current harvested power = " << harvestedPower << " W"); |
| 147 |
} |
147 |
} |
| 148 |
|
148 |
|
| 149 |
/// Trace function for the total energy harvested by the node. |
149 |
/// Trace function for the total energy harvested by the node. |
| 150 |
void |
150 |
void |
| 151 |
TotalEnergyHarvested (double oldValue, double TotalEnergyHarvested) |
151 |
TotalEnergyHarvested (double oldValue, double TotalEnergyHarvested) |
| 152 |
{ |
152 |
{ |
| 153 |
std::cout << Simulator::Now ().GetSeconds () |
153 |
NS_LOG_UNCOND (Simulator::Now ().GetSeconds () |
| 154 |
<< "s Total energy harvested by harvester = " |
154 |
<< "s Total energy harvested by harvester = " |
| 155 |
<< TotalEnergyHarvested << " J" << std::endl; |
155 |
<< TotalEnergyHarvested << " J"); |
| 156 |
} |
156 |
} |
| 157 |
|
157 |
|
| 158 |
|
158 |
|
|
|
| 331 |
|
331 |
|
| 332 |
Simulator::Stop (Seconds (10.0)); |
332 |
Simulator::Stop (Seconds (10.0)); |
| 333 |
Simulator::Run (); |
333 |
Simulator::Run (); |
|
|
334 |
|
| 335 |
for (DeviceEnergyModelContainer::Iterator iter = deviceModels.Begin (); iter != deviceModels.End (); iter ++) |
| 336 |
{ |
| 337 |
double energyConsumed = (*iter)->GetTotalEnergyConsumption (); |
| 338 |
NS_LOG_UNCOND ("End of simulation (" << Simulator::Now ().GetSeconds () |
| 339 |
<< "s) Total energy consumed by radio = " << energyConsumed << "J"); |
| 340 |
NS_ASSERT (energyConsumed <= 1.0); |
| 341 |
} |
| 342 |
|
| 334 |
Simulator::Destroy (); |
343 |
Simulator::Destroy (); |
| 335 |
|
344 |
|
| 336 |
return 0; |
345 |
return 0; |