Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(730)

Unified Diff: src/energy/model/basic-energy-source.cc

Issue 254120043: LR-WPAN ContikiMAC
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/lr-wpan/doc/lr-wpan.rst » ('j') | src/lr-wpan/examples/lr-wpan-contikimac-test.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/energy/model/basic-energy-source.cc
===================================================================
--- a/src/energy/model/basic-energy-source.cc
+++ b/src/energy/model/basic-energy-source.cc
@@ -230,7 +230,15 @@
NS_ASSERT (duration.GetSeconds () >= 0);
// energy = current * voltage * time
double energyToDecreaseJ = totalCurrentA * m_supplyVoltageV * duration.GetSeconds ();
- m_remainingEnergyJ -= energyToDecreaseJ;
+ double remainingEnergyJ = m_remainingEnergyJ - energyToDecreaseJ;
+ if (remainingEnergyJ <= 0)
+ {
+ m_remainingEnergyJ = 0; // energy never goes below 0
+ }
+ else
+ {
+ m_remainingEnergyJ -= energyToDecreaseJ;
+ }
NS_LOG_DEBUG ("BasicEnergySource:Remaining energy = " << m_remainingEnergyJ);
}
« no previous file with comments | « no previous file | src/lr-wpan/doc/lr-wpan.rst » ('j') | src/lr-wpan/examples/lr-wpan-contikimac-test.cc » ('J')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b