[PATCH] Only calculate with he when he is present in event

Anton Lundin glance at acc.umu.se
Tue Sep 17 23:56:11 UTC 2013


On 17 September, 2013 - Dirk Hohndel wrote:

> On Tue, 2013-09-17 at 08:25 +0200, Anton Lundin wrote:
> > Old gasswitch events only contains O2, so don't look at he part when
> > there is no he in the event.
> 
> I don't think I agree with this change. If the gas change doesn't have
> He in it, regardless whether it's old or new, then we have to assume
> that there is no He in the gas (we do that everywhere else). Otherwise
> we'd match a switch to EAN28 with a (26/50) switch.
> 
> Can you explain the specific case where this triggered a bug for you?

I was mostly debugging things for "Bugfix plot of ceiling violation" and
tested with dives/test15.xml that contains gasswitches without he in
them.

The thing is that we use 11 (SAMPLE_EVENT_GASCHANGE) aka, the one with
only oxygen in for ex. add_gas_switch_event and add_initial_gaschange,
when its actually a 25 (SAMPLE_EVENT_GASCHANGE2).

I have prepared a patch for the event types and sending it now. I have
also reworked this patch to actually look at the event type to figure
out if we should look at the he-part or not.


//Anton


> > Signed-off-by: Anton Lundin <glance at acc.umu.se>
> > ---
> >  profile.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/profile.c b/profile.c
> > index eb6be2c..e0e9bad 100644
> > --- a/profile.c
> > +++ b/profile.c
> > @@ -646,7 +646,14 @@ static int get_cylinder_index(struct dive *dive, struct event *ev)
> >  
> >  		delta_o2 = get_o2(&cyl->gasmix) - target_o2;
> >  		delta_he = get_he(&cyl->gasmix) - target_he;
> > -		distance = delta_o2 * delta_o2 + delta_he * delta_he;
> > +		distance = delta_o2 * delta_o2;
> > +
> > +		/* If we don't have he in the gas-change event,
> > +		 * its probably a old gas-change event that only contains o2,
> > +		 * so don't compare the he-part when looking for the right gas.
> > +		 */
> > +		if (target_he != 0)
> > +			distance += delta_he * delta_he;
> >  		if (distance >= score)
> >  			continue;
> >  		score = distance;
> 

-- 
Anton Lundin	+46702-161604


More information about the subsurface mailing list