Planner: don't set cylinder start and end pressure when adding dive

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-07-04 11:40:02 -07:00
parent d4e3745370
commit cc86d68c86
4 changed files with 7 additions and 7 deletions

2
dive.h
View file

@ -741,7 +741,7 @@ extern bool no_weightsystems(weightsystem_t *ws);
extern bool weightsystems_equal(weightsystem_t *ws1, weightsystem_t *ws2);
extern void remove_cylinder(struct dive *dive, int idx);
extern void remove_weightsystem(struct dive *dive, int idx);
extern void reset_cylinders(struct dive *dive);
extern void reset_cylinders(struct dive *dive, bool track_gas);
/*
* String handling.

View file

@ -231,8 +231,8 @@ void remove_weightsystem(struct dive *dive, int idx)
}
/* when planning a dive we need to make sure that all cylinders have a sane depth assigned
* and that the pressures are reset to start = end = workingpressure */
void reset_cylinders(struct dive *dive)
* and if we are tracking gas consumption the pressures need to be reset to start = end = workingpressure */
void reset_cylinders(struct dive *dive, bool track_gas)
{
int i;
pressure_t pO2 = {.mbar = 1400};
@ -243,7 +243,7 @@ void reset_cylinders(struct dive *dive)
continue;
if (cyl->depth.mm == 0) /* if the gas doesn't give a mod, assume conservative pO2 */
cyl->depth = gas_mod(&cyl->gasmix, pO2, M_OR_FT(3,10));
if (cyl->type.workingpressure.mbar)
if (track_gas && cyl->type.workingpressure.mbar)
cyl->start.mbar = cyl->end.mbar = cyl->type.workingpressure.mbar;
cyl->gas_used.mliter = 0;
}

View file

@ -260,7 +260,7 @@ static void create_dive_from_plan(struct diveplan *diveplan, bool track_gas)
#endif
// reset the cylinders and clear out the samples and events of the
// displayed dive so we can restart
reset_cylinders(&displayed_dive);
reset_cylinders(&displayed_dive, track_gas);
dc = &displayed_dive.dc;
free(dc->sample);
dc->sample = NULL;

View file

@ -143,7 +143,7 @@ void DivePlannerPointsModel::setupCylinders()
// take the used cylinders from the selected dive as starting point
CylindersModel::instance()->copyFromDive(current_dive);
copy_cylinders(current_dive, &displayed_dive, true);
reset_cylinders(&displayed_dive);
reset_cylinders(&displayed_dive, true);
return;
}
if (!same_string(prefs.default_cylinder, "")) {
@ -154,7 +154,7 @@ void DivePlannerPointsModel::setupCylinders()
displayed_dive.cylinder[0].type.size.mliter = 11100;
displayed_dive.cylinder[0].type.workingpressure.mbar = 207000;
}
reset_cylinders(&displayed_dive);
reset_cylinders(&displayed_dive, false);
CylindersModel::instance()->copyFromDive(&displayed_dive);
}