View | Details | Raw Unified | Return to bug 2809
Collapse All | Expand All

(-)a/examples/energy/energy-model-example.cc (+11 lines)
 Lines 119-124    Link Here 
119
  LogComponentEnable ("WifiRadioEnergyModel", LOG_LEVEL_DEBUG);
119
  LogComponentEnable ("WifiRadioEnergyModel", LOG_LEVEL_DEBUG);
120
   */
120
   */
121
121
122
  LogComponentEnable ("EnergyExample", LogLevel (LOG_PREFIX_TIME | LOG_PREFIX_NODE | LOG_LEVEL_INFO));
123
122
  std::string phyMode ("DsssRate1Mbps");
124
  std::string phyMode ("DsssRate1Mbps");
123
  double Prss = -80;            // dBm
125
  double Prss = -80;            // dBm
124
  uint32_t PpacketSize = 200;   // bytes
126
  uint32_t PpacketSize = 200;   // bytes
 Lines 266-271    Link Here 
266
268
267
  Simulator::Stop (Seconds (10.0));
269
  Simulator::Stop (Seconds (10.0));
268
  Simulator::Run ();
270
  Simulator::Run ();
271
272
  for (DeviceEnergyModelContainer::Iterator iter = deviceModels.Begin (); iter != deviceModels.End (); iter ++)
273
    {
274
      double energyConsumed = (*iter)->GetTotalEnergyConsumption ();
275
      NS_LOG_UNCOND ("End of simulation (" << Simulator::Now ().GetSeconds ()
276
                     << "s) Total energy consumed by radio = " << energyConsumed << "J");
277
      NS_ASSERT (energyConsumed <= 0.1);
278
    }
279
269
  Simulator::Destroy ();
280
  Simulator::Destroy ();
270
281
271
  return 0;
282
  return 0;
(-)a/examples/energy/energy-model-with-harvesting-example.cc (-9 / +18 lines)
 Lines 126-158    Link Here 
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
 Lines 331-336    Link Here 
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;

Return to bug 2809