mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix the Diveplan Creation.
Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
parent
07898f277c
commit
0a27f124fd
1 changed files with 31 additions and 18 deletions
|
@ -191,6 +191,17 @@ static void update_cylinder_pressure(struct dive *d, int old_depth, int new_dept
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct sample *create_sample(struct divecomputer &dc, int time, depth_t depth, bool entered)
|
||||||
|
{
|
||||||
|
struct sample *sample = prepare_sample(&dc);
|
||||||
|
sample->time.seconds = time;
|
||||||
|
sample->depth = depth;
|
||||||
|
sample->manually_entered = entered;
|
||||||
|
sample->sac.mliter = entered ? prefs.bottomsac : prefs.decosac;
|
||||||
|
|
||||||
|
return sample;
|
||||||
|
}
|
||||||
|
|
||||||
/* overwrite the data in dive
|
/* overwrite the data in dive
|
||||||
* return false if something goes wrong */
|
* return false if something goes wrong */
|
||||||
static void create_dive_from_plan(struct diveplan &diveplan, struct dive *dive, struct divecomputer *dc, bool track_gas)
|
static void create_dive_from_plan(struct diveplan &diveplan, struct dive *dive, struct divecomputer *dc, bool track_gas)
|
||||||
|
@ -257,34 +268,36 @@ static void create_dive_from_plan(struct diveplan &diveplan, struct dive *dive,
|
||||||
report_error("Invalid cylinder in create_dive_from_plan(): %d", dp.cylinderid);
|
report_error("Invalid cylinder in create_dive_from_plan(): %d", dp.cylinderid);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
sample = prepare_sample(dc);
|
|
||||||
sample[-1].setpoint.mbar = po2;
|
sample->setpoint.mbar = po2;
|
||||||
if (po2)
|
if (po2)
|
||||||
sample[-1].o2sensor[0].mbar = po2;
|
sample->o2sensor[0].mbar = po2;
|
||||||
sample->time.seconds = lasttime + 1;
|
type = get_effective_divemode(*dc, *cyl);
|
||||||
sample->depth = lastdepth;
|
|
||||||
sample->manually_entered = dp.entered;
|
sample = create_sample(*dc, lasttime + 1, lastdepth, dp.entered);
|
||||||
sample->sac.mliter = dp.entered ? prefs.bottomsac : prefs.decosac;
|
|
||||||
lastcylid = dp.cylinderid;
|
lastcylid = dp.cylinderid;
|
||||||
}
|
}
|
||||||
if (dp.divemode != type) {
|
if (dp.divemode != type) {
|
||||||
type = dp.divemode;
|
type = dp.divemode;
|
||||||
add_event(dc, lasttime, SAMPLE_EVENT_BOOKMARK, 0, type, "modechange");
|
if ((dc->divemode == CCR && prefs.allowOcGasAsDiluent && cyl->cylinder_use == OC_GAS) || dc->divemode == PSCR)
|
||||||
|
add_event(dc, lasttime, SAMPLE_EVENT_BOOKMARK, 0, type, "modechange");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create sample */
|
|
||||||
sample = prepare_sample(dc);
|
|
||||||
/* set po2 at beginning of this segment */
|
/* set po2 at beginning of this segment */
|
||||||
/* and keep it valid for last sample - where it likely doesn't matter */
|
/* and keep it valid for last sample - where it likely doesn't matter */
|
||||||
sample[-1].setpoint.mbar = po2;
|
|
||||||
sample->setpoint.mbar = po2;
|
sample->setpoint.mbar = po2;
|
||||||
sample->time.seconds = lasttime = time;
|
|
||||||
if (dp.entered) last_manual_point = dp.time;
|
sample = create_sample(*dc, time, depth, dp.entered);
|
||||||
sample->depth = lastdepth = depth;
|
sample->setpoint.mbar = po2;
|
||||||
sample->manually_entered = dp.entered;
|
if (dp.entered)
|
||||||
sample->sac.mliter = dp.entered ? prefs.bottomsac : prefs.decosac;
|
last_manual_point = time;
|
||||||
if (track_gas && !sample[-1].setpoint.mbar) { /* Don't track gas usage for CCR legs of dive */
|
lastdepth = depth;
|
||||||
update_cylinder_pressure(dive, sample[-1].depth.mm, depth.mm, time - sample[-1].time.seconds,
|
lasttime = time;
|
||||||
|
|
||||||
|
if (track_gas) {
|
||||||
|
if (!sample[-1].setpoint.mbar) /* Don't track gas usage for CCR legs of dive */
|
||||||
|
update_cylinder_pressure(dive, sample[-1].depth.mm, depth.mm, time - sample[-1].time.seconds,
|
||||||
dp.entered ? diveplan.bottomsac : diveplan.decosac, cyl, !dp.entered, type);
|
dp.entered ? diveplan.bottomsac : diveplan.decosac, cyl, !dp.entered, type);
|
||||||
if (cyl->type.workingpressure.mbar)
|
if (cyl->type.workingpressure.mbar)
|
||||||
sample->pressure[0].mbar = cyl->end.mbar;
|
sample->pressure[0].mbar = cyl->end.mbar;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue