Don't calculate SAC-rates for negative pressure changes

They happen - maybe the cylinder actually warmed up, or maybe the user
entered just a ending pressure without a starting pressure.  Regardless,
just ignore cylinder pressure changes that go up.

Also ignore cylinders with a zero ending pressure: that's really a
*missing* pressure rather than an actual zero pressure.  As Dirk says,
the scuba regulators don't even work without a healthy positive pressure
differential, so even when you breathe down a tank to "empty", it won't
be at zero pressure (this is true even with gauge pressure, where zero
means "atmospheric pressure").

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2014-04-26 10:55:17 -07:00 committed by Dirk Hohndel
parent cd98e4f6db
commit 0c5ec1d6db
3 changed files with 4 additions and 2 deletions

View file

@ -157,7 +157,7 @@ static int get_local_sac(struct plot_data *entry1, struct plot_data *entry2, str
return 0;
a.mbar = GET_PRESSURE(entry1);
b.mbar = GET_PRESSURE(entry2);
if (!a.mbar || !b.mbar)
if (!b.mbar || a.mbar <= b.mbar)
return 0;
/* Mean pressure in ATM */