[PATCH 2/2] Add type for gaschange events, if missing

Anton Lundin glance at acc.umu.se
Sat Jul 12 05:21:03 PDT 2014


On 12 July, 2014 - Miika Turkia wrote:

> On Sat, Jul 12, 2014 at 2:24 PM, Anton Lundin <glance at acc.umu.se> wrote:
> 
> > On 12 July, 2014 - Miika Turkia wrote:
> >
> > > Subsurface has saved gas change events without type attribute at some
> > > point. Thus we need to add the type when reading in log files, if it is
> > > missing. (Gas change logic relies on the type field nowadays.)
> > >
> > > Fixes #617
> > > Fixes #600
> > >
> > > Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
> > > ---
> > >  parse-xml.c | 6 ++++++
> > >  1 file changed, 6 insertions(+)
> > >
> > > diff --git a/parse-xml.c b/parse-xml.c
> > > index 5375e32..606e251 100644
> > > --- a/parse-xml.c
> > > +++ b/parse-xml.c
> > > @@ -1337,6 +1337,12 @@ static void event_end(void)
> > >                               pic->offset.seconds =
> > cur_event.time.seconds;
> > >                               dive_add_picture(cur_dive, pic);
> > >                       } else {
> > > +                             /* At some point gas change events did not
> > have any type. Thus we need to add
> > > +                              * one on import, if we encounter the type
> > one missing.
> > > +                              */
> > > +                             if (cur_event.type == 0 && strcmp(
> > cur_event.name, "gaschange") == 0)
> > > +                                     cur_event.type = 25;
> >
> > I would prefer if we used SAMPLE_EVENT_GASCHANGE2 instead of the enum
> > number.
> >
> > Are you sure they are of type GASCHANGE2, aka with He? I would guess
> > they where of type GASCHANGE , aka the ones without any He info.
> >
> 
> All the test dives use type 25 even though there is no helium in them and
> manually added gas change event uses hard coded 25 as well, so I didn't
> realize it should change based on gas. I'll send a fix shortly...
> 

It depends on what format the source of the event was talking. There are
DC's that only tell us the o2 content, even if the gas had a he-part.

If you look at the get_cylinder_index function, if its a
SAMPLE_EVENT_GASCHANGE, just don't care about any he-parts when were
looking for the matching gas, eg:

If a dive had a gaslist like:
* 21/35
* AIR

Then a SAMPLE_EVENT_GASCHANGE with o2 = 21% would return the 21/35, its
the fist best match, but a SAMPLE_EVENT_GASCHANGE2 with o2 = 21% he = 0%
would return the air because the 21/35 has helium in it and the event
says that the gas shouldn't have any helium in it.


I would say in the unknown event type case, if the event data has a he
part then its definitely a SAMPLE_EVENT_GASCHANGE2, otherwise i would
guess at a SAMPLE_EVENT_GASCHANGE, and let get_cylinder_index figure the
rest out.

//Anton


-- 
Anton Lundin	+46702-161604


More information about the subsurface mailing list