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

(-)a/src/uan/model/acoustic-modem-energy-model.cc (-6 / +12 lines)
 Lines 79-84    Link Here 
79
  m_energyDepletionCallback.Nullify ();
79
  m_energyDepletionCallback.Nullify ();
80
  m_node = 0;
80
  m_node = 0;
81
  m_source = 0;
81
  m_source = 0;
82
  m_supplyVoltage = 0;
82
}
83
}
83
84
84
AcousticModemEnergyModel::~AcousticModemEnergyModel ()
85
AcousticModemEnergyModel::~AcousticModemEnergyModel ()
 Lines 200-219    Link Here 
200
201
201
  // energy to decrease = current * voltage * time
202
  // energy to decrease = current * voltage * time
202
  double energyToDecrease = 0.0;
203
  double energyToDecrease = 0.0;
203
  double supplyVoltage = m_source->GetSupplyVoltage ();
204
  m_supplyVoltage = m_source->GetSupplyVoltage ();
204
  switch (m_currentState)
205
  switch (m_currentState)
205
    {
206
    {
206
    case UanPhy::TX:
207
    case UanPhy::TX:
207
      energyToDecrease = duration.GetSeconds () * m_txPowerW * supplyVoltage;
208
      energyToDecrease = duration.GetSeconds () * m_txPowerW * m_supplyVoltage;
208
      break;
209
      break;
209
    case UanPhy::RX:
210
    case UanPhy::RX:
210
      energyToDecrease = duration.GetSeconds () * m_rxPowerW * supplyVoltage;
211
      energyToDecrease = duration.GetSeconds () * m_rxPowerW * m_supplyVoltage;
211
      break;
212
      break;
212
    case UanPhy::IDLE:
213
    case UanPhy::IDLE:
213
      energyToDecrease = duration.GetSeconds () * m_idlePowerW * supplyVoltage;
214
      energyToDecrease = duration.GetSeconds () * m_idlePowerW * m_supplyVoltage;
214
      break;
215
      break;
215
    case UanPhy::SLEEP:
216
    case UanPhy::SLEEP:
216
      energyToDecrease = duration.GetSeconds () * m_sleepPowerW * supplyVoltage;
217
      energyToDecrease = duration.GetSeconds () * m_sleepPowerW * m_supplyVoltage;
217
      break;
218
      break;
218
    default:
219
    default:
219
      NS_FATAL_ERROR ("AcousticModemEnergyModel:Undefined radio state!");
220
      NS_FATAL_ERROR ("AcousticModemEnergyModel:Undefined radio state!");
 Lines 261-266    Link Here 
261
{
262
{
262
  NS_LOG_FUNCTION (this);
263
  NS_LOG_FUNCTION (this);
263
  m_node = 0;
264
  m_node = 0;
265
  m_supplyVoltage = m_source->GetSupplyVoltage ();
264
  m_source = 0;
266
  m_source = 0;
265
  m_energyDepletionCallback.Nullify ();
267
  m_energyDepletionCallback.Nullify ();
266
}
268
}
 Lines 270-276    Link Here 
270
{
272
{
271
  NS_LOG_FUNCTION (this);
273
  NS_LOG_FUNCTION (this);
272
274
273
  double supplyVoltage = m_source->GetSupplyVoltage ();
275
  double supplyVoltage = m_supplyVoltage;
276
  if (m_source != NULL)
277
    {
278
      supplyVoltage = m_source->GetSupplyVoltage ();
279
    }
274
  NS_ASSERT (supplyVoltage != 0.0);
280
  NS_ASSERT (supplyVoltage != 0.0);
275
  double stateCurrent = 0.0;
281
  double stateCurrent = 0.0;
276
  switch (m_currentState)
282
  switch (m_currentState)
(-)a/src/uan/model/acoustic-modem-energy-model.h (+1 lines)
 Lines 206-211    Link Here 
206
private:
206
private:
207
  Ptr<Node> m_node;            //!< The node hosting this transducer.
207
  Ptr<Node> m_node;            //!< The node hosting this transducer.
208
  Ptr<EnergySource> m_source;  //!< The energy source.
208
  Ptr<EnergySource> m_source;  //!< The energy source.
209
  double m_supplyVoltage;      //!< The current energy source supply voltage
209
210
210
  // Member variables for power consumption in different modem states.
211
  // Member variables for power consumption in different modem states.
211
  double m_txPowerW;           //!< The transmitter power, in watts.
212
  double m_txPowerW;           //!< The transmitter power, in watts.

Return to bug 2310