Hi Rick,

> On 26 Oct 2015, at 10:25, Rick Walsh <[email protected]> wrote:
> 
> So, using your observation that it converges fast, I realized we don't 
> actually need to calculate tts for every sample point.  We just need to 
> calculate tts for the final sample, iif the ceiling has been broken.  We can 
> then take deco_time = time from max ceiling depth until the ceiling clears, 
> or would have cleared.
> 
> See patches attached.  More testing is needed, and feedback welcome.

I think this makes much more sense. Just a few comments/questions for patch 1:

1) I think deco_time is defined, at least in the prose of the VPM-B documents 
as the time at which at least one tissue is off-gassing. Given that we have to 
go through all samples, can’t we just detect off-gassing in add_segment by 
checking if at least one oversat is negative, i.e. start with

bool off_gassing = false

and then in the loop

off_gassing ||= (pn2_oversat < 0) || (phe_oversat <0);

and finally change add_segment from void to bool by returning off_gassing. Then 
we can simply add all the time for all segments the we added which return true.

2) I don’t really understand what you are doing with 
first_ceiling_pressure_set. It seems to me you want to pick up the first step 
after the maximum of the ceiling. So you look for a segment where the ceiling 
goes up but in the previous step it didn’t. Why don’t you simply memorise the 
last step where the ceiling gets deeper (it should be the previous), by getting 
rid of first_ceiling_pressure_set and simply doing

if (entry->ceiling > first_ceiling) {
        first_ceiling = entry->ceiling;
        first_ceiling_pressure.mbar = depth_to_mbar(first_ceiling, dive);
}

This would give you the value for the maximum ceiling.

3) I am a bit worried that the last hunk copies quite a bit of non-trivial 
code. Wouldn’t it be possible to factor this out, i.e. do it with a loop or as 
a separate function that the logic is in the source only once? Otherwise, we 
are almost guaranteed that when changing the code in the future we will end up 
with two inconsistent copies.

But all this in the end is cosmetic, I like what the code is doing.

Best
Robert

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to