diff options
author | Willem Ferguson <willemferguson@zoology.up.ac.za> | 2018-04-02 17:16:07 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-05-14 23:47:00 +0300 |
commit | cf377beb2ea13833fa4a867b9c99153ecd9fff22 (patch) | |
tree | 4412c032ab354d5593ed064d362d1ca2d8ec9a46 /core/profile.c | |
parent | 9b4728c7a96edf48f7150bec943fb8484d9332cd (diff) | |
download | subsurface-cf377beb2ea13833fa4a867b9c99153ecd9fff22.tar.gz |
Incorporate bailout events in CCR & PSCR gas calculations.
This is a first step to interpret bailout events.
1) The event structures have a new attribute: divemode.
Currently interpreted dive modes are OC, CCR, PSCR.
2) When doing fill_pressures(), the calculation is aware
of divemode. When divemode is OC (==bailout), then
the appropriate calculations of gas pressures are done.
3) Two new functions get_next_divemodechange() and
get_divemode_at_time() are created to find divemode
changes in the events linked list and to determine
the dive mode at any point during the dive.
4) fill_pressures gets a small amendment to facilitate
the correct calculations, depending on divemode.
The cases where fill_pressures() is used *outside the planner*
are changed. The result is that, for dives with bailout, the
correct gas pressures are shown on the dive profile. The
deco for bailout dives is not yet correct. This is the
next step.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Diffstat (limited to 'core/profile.c')
-rw-r--r-- | core/profile.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/core/profile.c b/core/profile.c index 1bdb8e956..bfe8c223c 100644 --- a/core/profile.c +++ b/core/profile.c @@ -1200,19 +1200,25 @@ static int calculate_ccr_po2(struct plot_data *entry, struct divecomputer *dc) static void calculate_gas_information_new(struct dive *dive, struct divecomputer *dc, struct plot_info *pi) { int i; + enum dive_comp_type current_divemode; double amb_pressure; struct gasmix *gasmix = NULL; - struct event *ev = NULL; + struct event *nextev, *evg = NULL, *evd = dc->events; + + current_divemode = dc->divemode; + nextev = get_next_divemodechange(&evd); for (i = 1; i < pi->nr; i++) { int fn2, fhe; struct plot_data *entry = pi->entry + i; - gasmix = get_gasmix(dive, dc, entry->sec, &ev, gasmix); - + gasmix = get_gasmix(dive, dc, entry->sec, &evg, gasmix); + if (nextev && (entry->sec > nextev->time.seconds)) { // If there are divemode changes and sample time + current_divemode = nextev->divemode; // has reached that of the current divemode event, then set the + nextev = get_next_divemodechange(&evd); // current divemode and find the next divemode event + } amb_pressure = depth_to_bar(entry->depth, dive); - - fill_pressures(&entry->pressures, amb_pressure, gasmix, entry->o2pressure.mbar / 1000.0, dive->dc.divemode); + fill_pressures(&entry->pressures, amb_pressure, gasmix, (current_divemode == OC) ? 0.0 : entry->o2pressure.mbar / 1000.0, current_divemode); fn2 = (int)(1000.0 * entry->pressures.n2 / amb_pressure); fhe = (int)(1000.0 * entry->pressures.he / amb_pressure); if (dc->divemode == PSCR) // OC pO2 is calulated for PSCR with or without external PO2 monitoring. |