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

(-)a/src/energy/model/simple-device-energy-model.cc (-1 / +9 lines)
 Lines 85-91    Link Here 
85
SimpleDeviceEnergyModel::GetTotalEnergyConsumption (void) const
85
SimpleDeviceEnergyModel::GetTotalEnergyConsumption (void) const
86
{
86
{
87
  NS_LOG_FUNCTION (this);
87
  NS_LOG_FUNCTION (this);
88
  return m_totalEnergyConsumption;
88
  Time duration = Simulator::Now () - m_lastUpdateTime;
89
90
  double energyToDecrease = 0.0;
91
  double supplyVoltage = m_source->GetSupplyVoltage ();
92
  energyToDecrease = duration.GetSeconds () * m_actualCurrentA * supplyVoltage;
93
94
  m_source->UpdateEnergySource ();
95
96
  return m_totalEnergyConsumption + energyToDecrease;
89
}
97
}
90
98
91
void
99
void
(-)a/src/wifi/model/wifi-radio-energy-model.cc (-1 / +35 lines)
 Lines 120-126    Link Here 
120
WifiRadioEnergyModel::GetTotalEnergyConsumption (void) const
120
WifiRadioEnergyModel::GetTotalEnergyConsumption (void) const
121
{
121
{
122
  NS_LOG_FUNCTION (this);
122
  NS_LOG_FUNCTION (this);
123
  return m_totalEnergyConsumption;
123
124
  Time duration = Simulator::Now () - m_lastUpdateTime;
125
  NS_ASSERT (duration.GetNanoSeconds () >= 0); // check if duration is valid
126
127
  // energy to decrease = current * voltage * time
128
  double energyToDecrease = 0.0;
129
  double supplyVoltage = m_source->GetSupplyVoltage ();
130
  switch (m_currentState)
131
    {
132
    case WifiPhy::IDLE:
133
      energyToDecrease = duration.GetSeconds () * m_idleCurrentA * supplyVoltage;
134
      break;
135
    case WifiPhy::CCA_BUSY:
136
      energyToDecrease = duration.GetSeconds () * m_ccaBusyCurrentA * supplyVoltage;
137
      break;
138
    case WifiPhy::TX:
139
      energyToDecrease = duration.GetSeconds () * m_txCurrentA * supplyVoltage;
140
      break;
141
    case WifiPhy::RX:
142
      energyToDecrease = duration.GetSeconds () * m_rxCurrentA * supplyVoltage;
143
      break;
144
    case WifiPhy::SWITCHING:
145
      energyToDecrease = duration.GetSeconds () * m_switchingCurrentA * supplyVoltage;
146
      break;
147
    case WifiPhy::SLEEP:
148
      energyToDecrease = duration.GetSeconds () * m_sleepCurrentA * supplyVoltage;
149
      break;
150
    default:
151
      NS_FATAL_ERROR ("WifiRadioEnergyModel:Undefined radio state: " << m_currentState);
152
    }
153
154
  // notify energy source
155
  m_source->UpdateEnergySource ();
156
157
  return m_totalEnergyConsumption + energyToDecrease;
124
}
158
}
125
159
126
double
160
double

Return to bug 2807