diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-10-25 11:36:44 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-10-25 13:59:52 -0700 |
commit | 464dd93fe8266e3d0af706a6809f09611bd9f83c (patch) | |
tree | 16114568db6e58ad25e14dd76f5a724a7f33d6e8 /core/dive.c | |
parent | 8212acc9925b28ecd546b01047c6a8fc574326ef (diff) | |
download | subsurface-464dd93fe8266e3d0af706a6809f09611bd9f83c.tar.gz |
cleanup: move fill_pressures from dive.c to gas.c
This function does not access a dive structure.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/dive.c')
-rw-r--r-- | core/dive.c | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/core/dive.c b/core/dive.c index a9c69a3b0..5bb406f08 100644 --- a/core/dive.c +++ b/core/dive.c @@ -1943,51 +1943,6 @@ extern int get_cylinder_idx_by_use(const struct dive *dive, enum cylinderuse cyl return -1; // negative number means cylinder_use_type not found in list of cylinders } -/* fill_pressures(): Compute partial gas pressures in bar from gasmix and ambient pressures, possibly for OC or CCR, to be - * extended to PSCT. This function does the calculations of gas pressures applicable to a single point on the dive profile. - * The structure "pressures" is used to return calculated gas pressures to the calling software. - * Call parameters: po2 = po2 value applicable to the record in calling function - * amb_pressure = ambient pressure applicable to the record in calling function - * *pressures = structure for communicating o2 sensor values from and gas pressures to the calling function. - * *mix = structure containing cylinder gas mixture information. - * divemode = the dive mode pertaining to this point in the dive profile. - * This function called by: calculate_gas_information_new() in profile.c; add_segment() in deco.c. - */ -void fill_pressures(struct gas_pressures *pressures, const double amb_pressure, struct gasmix mix, double po2, enum divemode_t divemode) -{ - if ((divemode != OC) && po2) { // This is a rebreather dive where pressures->o2 is defined - if (po2 >= amb_pressure) { - pressures->o2 = amb_pressure; - pressures->n2 = pressures->he = 0.0; - } else { - pressures->o2 = po2; - if (get_o2(mix) == 1000) { - pressures->he = pressures->n2 = 0; - } else { - pressures->he = (amb_pressure - pressures->o2) * (double)get_he(mix) / (1000 - get_o2(mix)); - pressures->n2 = amb_pressure - pressures->o2 - pressures->he; - } - } - } else { - if (divemode == PSCR) { /* The steady state approximation should be good enough */ - pressures->o2 = get_o2(mix) / 1000.0 * amb_pressure - (1.0 - get_o2(mix) / 1000.0) * prefs.o2consumption / (prefs.bottomsac * prefs.pscr_ratio / 1000.0); - if (pressures->o2 < 0) // He's dead, Jim. - pressures->o2 = 0; - if (get_o2(mix) != 1000) { - pressures->he = (amb_pressure - pressures->o2) * get_he(mix) / (1000.0 - get_o2(mix)); - pressures->n2 = (amb_pressure - pressures->o2) * get_n2(mix) / (1000.0 - get_o2(mix)); - } else { - pressures->he = pressures->n2 = 0; - } - } else { - // Open circuit dives: no gas pressure values available, they need to be calculated - pressures->o2 = get_o2(mix) / 1000.0 * amb_pressure; // These calculations are also used if the CCR calculation above.. - pressures->he = get_he(mix) / 1000.0 * amb_pressure; // ..returned a po2 of zero (i.e. o2 sensor data not resolvable) - pressures->n2 = get_n2(mix) / 1000.0 * amb_pressure; - } - } -} - /* Force an initial gaschange event to the (old) gas #0 */ static void add_initial_gaschange(struct dive *dive, struct divecomputer *dc, int offset, int idx) { |