[PATCH 2/2] Add initial rudimentary no-fly time calculation

Linus Torvalds torvalds at linux-foundation.org
Fri Feb 8 10:25:28 PST 2013


On Feb 9, 2013 3:45 AM, "Robert C. Helling" <helling at lmu.de> wrote:
>
> Then I found the problem: tissue_tolerance_calc() assumes to find the
surface pressure as
>
> double surface = dive->dc.surface_pressure.mbar / 1000.0;
>
> Except that seems not to be set, at least it always reads a 0.0. Where
should that be set? Shall we always set it to 1013mbar or do we do
something better?

Aahh. The danger of fields that only exist on some dive computers...

Yes, we should just default to 1.013 if the dive computer doesn't actually
give an explicit surface pressure.

And it is possible that we should just full that field by default (we do
for the salinity field, I think) if the dive computer doesn't give it, and
then just not save it at all when it matches the default.

It is nice to see if some field is actually supported by a dive computer or
not, but I doubt that is worth the pain of noticing that we used zero
instead of the default value (SURFACE_PRESSURE) and the calculations
"worked" but gave the wrong answer.

Or we could just add a helper function fit this, like so many other things.

   double surface_pressure(struct dive *dive)
   {
      return (dive->dc.surface_pressure.mbar ?: SURFACE_PRESSURE) /1000.0;
   }

or something very similar.

That would allow us to keep the "dive computer gives actual surface
pressure information" thing explicitly visible, while having a good way to
get it.

Of course, it is a per-divecomputer thing, and we can have multiple dive
computers, so maybe just pass in the dc as the argument instead..

       Linus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130209/9a22ac48/attachment.html>


More information about the subsurface mailing list