|
Bugzilla – Full Text Bug Listing |
| Summary: | AcousticModemEnergyModel::ChangeState | ||
|---|---|---|---|
| Product: | ns-3 | Reporter: | Hossam Khader <hossamkhader> |
| Component: | uan | Assignee: | Andrea Sacco <andrea.sacco85> |
| Status: | RESOLVED DUPLICATE | ||
| Severity: | normal | CC: | andrea.sacco85, cristiano.tapparello, ns-bugs, pdbarnes, tommaso.pecorella |
| Priority: | P5 | ||
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | All | ||
|
Description
Hossam Khader
2016-02-26 16:21:25 UTC
Indeed, Amps = Watts * Seconds, the Volts is already included. If we want to have a voltage-dependent model, we'd need to specify the current drawn by the modem in each state in Amperes, just like the Wi-Fi model does. Please have a look at the below code.
void
AcousticModemEnergyModel::ChangeState (int newState)
{
NS_LOG_FUNCTION (this << newState);
// NS_ASSERT (IsStateTransitionValid ((MicroModemState) newState));
Time duration = Simulator::Now () - m_lastUpdateTime;
NS_ASSERT (duration.GetNanoSeconds () >= 0); // check if duration is valid
// energy to decrease = current * voltage * time
double energyToDecrease = 0.0;
double supplyVoltage = m_source->GetSupplyVoltage ();
switch (m_currentState)
{
case UanPhy::TX:
energyToDecrease = duration.GetSeconds () * m_txPowerW;
m_txCurrentA = m_txPowerW / supplyVoltage;
break;
case UanPhy::RX:
energyToDecrease = duration.GetSeconds () * m_rxPowerW;
m_rxCurrentA = m_rxPowerW / supplyVoltage;
break;
case UanPhy::IDLE:
energyToDecrease = duration.GetSeconds () * m_idlePowerW;
m_idleCurrentA = m_idlePowerW / supplyVoltage;
break;
case UanPhy::SLEEP:
energyToDecrease = duration.GetSeconds () * m_sleepPowerW;
m_sleepCurrentA = m_sleepPowerW / supplyVoltage;
break;
default:
NS_FATAL_ERROR ("AcousticModemEnergyModel:Undefined radio state!");
}
// update total energy consumption
m_totalEnergyConsumption += energyToDecrease;
// update last update time stamp
m_lastUpdateTime = Simulator::Now ();
// notify energy source
m_source->UpdateEnergySource ();
// update current state & last update time stamp
SetMicroModemState (newState);
// some debug message
NS_LOG_DEBUG ("AcousticModemEnergyModel:Total energy consumption at node #" <<
m_node->GetId () << " is " << m_totalEnergyConsumption << "J");
}
double
AcousticModemEnergyModel::DoGetCurrentA (void) const
{
NS_LOG_FUNCTION (this);
switch (m_currentState)
{
case UanPhy::TX:
return m_txCurrentA;
case UanPhy::RX:
return m_rxCurrentA;
case UanPhy::IDLE:
return m_idleCurrentA;
case UanPhy::SLEEP:
return m_sleepCurrentA;
default:
NS_FATAL_ERROR ("AcousticModemEnergyModel:Undefined radio state!");
}
}
This is a duplicate of Bug 1631 https://www.nsnam.org/bugzilla/0. My suggestion is to remove the multiplication by supplyVoltage as suggested both here and in 1631. Andrea, do you agree on this? |