mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
874754e22b
commit
e32ba4d6d8
5 changed files with 50 additions and 11 deletions
18
profile.c
18
profile.c
|
|
@ -378,6 +378,19 @@ static int set_cylinder_index(struct plot_info *pi, int i, int cylinderindex, un
|
|||
return i;
|
||||
}
|
||||
|
||||
/* normally the first cylinder has index 0... if not, we need to fix this up here */
|
||||
static int set_first_cylinder_index(struct plot_info *pi, int i, int cylinderindex, unsigned int end)
|
||||
{
|
||||
while (i < pi->nr) {
|
||||
struct plot_data *entry = pi->entry + i;
|
||||
if (entry->sec > end)
|
||||
break;
|
||||
entry->cylinderindex = cylinderindex;
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static void check_gas_change_events(struct dive *dive, struct divecomputer *dc, struct plot_info *pi)
|
||||
{
|
||||
int i = 0, cylinderindex = 0;
|
||||
|
|
@ -386,6 +399,11 @@ static void check_gas_change_events(struct dive *dive, struct divecomputer *dc,
|
|||
if (!ev)
|
||||
return;
|
||||
|
||||
// for dive computers that tell us their first gas as an event on the first sample
|
||||
// we need to make sure things are setup correctly
|
||||
if ((cylinderindex = explicit_first_cylinder(dive, dc)) != 0)
|
||||
set_first_cylinder_index(pi, 0, cylinderindex, ~0u);
|
||||
|
||||
do {
|
||||
i = set_cylinder_index(pi, i, cylinderindex, ev->time.seconds);
|
||||
cylinderindex = get_cylinder_index(dive, ev);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue