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

Dirk Hohndel dirk at hohndel.org
Fri Feb 8 12:02:44 PST 2013


Linus Torvalds <torvalds at linux-foundation.org> writes:

> 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.

Should have read all email first. This is MUCH nicer. I did something
similar for duration so I suggest we first collect the valid readings,
do an average of the ones that aren't 0 (I happen to have two computers
that both give surface pressure but never agree) and only if that
results in 0 should we return SURFACE_PRESSURE...

I would just want this to return int (as we only use doubles in deco.c)

I'll commit a change like this in a moment.

> 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..

No, see above. I think you want to pass in the dive and walk the list of
divecomputers.

/D


More information about the subsurface mailing list