Improve tank handling for Cobalt

This isn't Cobalt specific, this is specific to dive computers that
indicate the first tank that's in use with a gaschange event that
coincides with the first sample.

We need to make sure that we suppress showing that gas change event
(regardless which cylinder it goes to) and instead set the correct
cylinder index from the very start of the dive.

This works with the test data I have and doesn't seem to break thing with
any of the files that I tried... but I'm worried that this is not the
right way to do things.

Fixes #742

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-10-28 13:48:15 -07:00
parent 874754e22b
commit e32ba4d6d8
5 changed files with 50 additions and 11 deletions

View file

@ -127,16 +127,13 @@ bool DiveEventItem::shouldBeHidden()
struct event *event = internalEvent;
/*
* Gas change events - particularly at the beginning of a dive - are
* special. It's just the dive computer specifying the initial gas.
*
* Don't bother showing them if they match the first gas already
* Some gas change events are special. Some dive computers just tell us the initial gas this way.
* Don't bother showing those
*/
if (!strcmp(event->name, "gaschange") && event->time.seconds <= 30) {
struct dive *dive = &displayed_dive;
if (dive && get_cylinder_index(dive, event) == 0)
return true;
}
struct sample *first_sample = &get_dive_dc(&displayed_dive, dc_number)->sample[0];
if (!strcmp(event->name, "gaschange") && (event->time.seconds < 30 || event->time.seconds == first_sample->time.seconds))
return true;
for (int i = 0; i < evn_used; i++) {
if (!strcmp(event->name, ev_namelist[i].ev_name) && ev_namelist[i].plot_ev == false)
return true;