mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Cleanup: pass gasmix by value
In a previous commit, the get_gasmix_* functions were changed to return by value. For consistency, also pass gasmix by value. Note that on common 64-bit platforms struct gasmix is the size of a pointer [2 * 32 bit vs. 64 bit] and therefore uses the same space on the stack. On 32-bit platforms, the stack use is probably doubled, but in return a dereference is avoided. Supporting arbitrary gas-mixes (H2, Ar, ...) will be such an invasive change that going back to pointers is probably the least of our worries. This commit is a step in const-ifying input parameters (passing by value is the ultimate way of signaling that the input parameter will not be changed [unless there are references to said parameter]). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
5c4569247a
commit
360f07e453
28 changed files with 214 additions and 215 deletions
|
@ -479,7 +479,7 @@ void calc_crushing_pressure(struct deco_state *ds, double pressure)
|
|||
}
|
||||
|
||||
/* add period_in_seconds at the given pressure and gas to the deco calculation */
|
||||
void add_segment(struct deco_state *ds, double pressure, const struct gasmix *gasmix, int period_in_seconds, int ccpo2, enum divemode_t divemode, int sac)
|
||||
void add_segment(struct deco_state *ds, double pressure, struct gasmix gasmix, int period_in_seconds, int ccpo2, enum divemode_t divemode, int sac)
|
||||
{
|
||||
UNUSED(sac);
|
||||
int ci;
|
||||
|
|
52
core/dive.c
52
core/dive.c
|
@ -1021,7 +1021,7 @@ static void update_min_max_temperatures(struct dive *dive, temperature_t tempera
|
|||
int gas_volume(cylinder_t *cyl, pressure_t p)
|
||||
{
|
||||
double bar = p.mbar / 1000.0;
|
||||
double z_factor = gas_compressibility_factor(&cyl->gasmix, bar);
|
||||
double z_factor = gas_compressibility_factor(cyl->gasmix, bar);
|
||||
return lrint(cyl->type.size.mliter * bar_to_atm(bar) / z_factor);
|
||||
}
|
||||
|
||||
|
@ -1082,7 +1082,7 @@ void update_setpoint_events(struct dive *dive, struct divecomputer *dc)
|
|||
gasmix = get_gasmix_from_event(dive, ev);
|
||||
next = get_next_event(ev, "gaschange");
|
||||
}
|
||||
fill_pressures(&pressures, calculate_depth_to_mbar(dc->sample[i].depth.mm, dc->surface_pressure, 0), &gasmix ,0, dc->divemode);
|
||||
fill_pressures(&pressures, calculate_depth_to_mbar(dc->sample[i].depth.mm, dc->surface_pressure, 0), gasmix ,0, dc->divemode);
|
||||
if (abs(dc->sample[i].setpoint.mbar - (int)(1000 * pressures.o2)) <= 50)
|
||||
dc->sample[i].setpoint.mbar = 0;
|
||||
}
|
||||
|
@ -1112,7 +1112,7 @@ void sanitize_gasmix(struct gasmix *mix)
|
|||
if (!o2)
|
||||
return;
|
||||
/* 20.8% to 21% O2 is just air */
|
||||
if (gasmix_is_air(mix)) {
|
||||
if (gasmix_is_air(*mix)) {
|
||||
mix->o2.permille = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -1231,7 +1231,7 @@ static void sanitize_cylinder_info(struct dive *dive)
|
|||
* Output: i) The icd_data stucture is filled with the delta_N2 and delta_He numbers (as permille).
|
||||
* ii) Function returns a boolean indicating an exceeding of the rule-of-fifths. False = no icd problem.
|
||||
*/
|
||||
bool isobaric_counterdiffusion(struct gasmix *oldgasmix, struct gasmix *newgasmix, struct icd_data *results)
|
||||
bool isobaric_counterdiffusion(struct gasmix oldgasmix, struct gasmix newgasmix, struct icd_data *results)
|
||||
{
|
||||
if (!prefs.show_icd)
|
||||
return false;
|
||||
|
@ -1608,7 +1608,7 @@ static void fixup_dive_pressures(struct dive *dive, struct divecomputer *dc)
|
|||
simplify_dc_pressures(dc);
|
||||
}
|
||||
|
||||
int find_best_gasmix_match(struct gasmix *mix, cylinder_t array[], unsigned int used)
|
||||
int find_best_gasmix_match(struct gasmix mix, cylinder_t array[], unsigned int used)
|
||||
{
|
||||
int i;
|
||||
int best = -1, score = INT_MAX;
|
||||
|
@ -1622,7 +1622,7 @@ int find_best_gasmix_match(struct gasmix *mix, cylinder_t array[], unsigned int
|
|||
match = array + i;
|
||||
if (cylinder_nodata(match))
|
||||
continue;
|
||||
distance = gasmix_distance(mix, &match->gasmix);
|
||||
distance = gasmix_distance(mix, match->gasmix);
|
||||
if (distance >= score)
|
||||
continue;
|
||||
best = i;
|
||||
|
@ -1640,14 +1640,14 @@ static bool validate_gaschange(struct dive *dive, struct event *event)
|
|||
int o2, he, value;
|
||||
|
||||
/* We'll get rid of the per-event gasmix, but for now sanitize it */
|
||||
if (gasmix_is_air(&event->gas.mix))
|
||||
if (gasmix_is_air(event->gas.mix))
|
||||
event->gas.mix.o2.permille = 0;
|
||||
|
||||
/* Do we already have a cylinder index for this gasmix? */
|
||||
if (event->gas.index >= 0)
|
||||
return true;
|
||||
|
||||
index = find_best_gasmix_match(&event->gas.mix, dive->cylinder, 0);
|
||||
index = find_best_gasmix_match(event->gas.mix, dive->cylinder, 0);
|
||||
if (index < 0)
|
||||
return false;
|
||||
|
||||
|
@ -1656,8 +1656,8 @@ static bool validate_gaschange(struct dive *dive, struct event *event)
|
|||
event->gas.mix = dive->cylinder[index].gasmix;
|
||||
|
||||
/* Convert to odd libdivecomputer format */
|
||||
o2 = get_o2(&event->gas.mix);
|
||||
he = get_he(&event->gas.mix);
|
||||
o2 = get_o2(event->gas.mix);
|
||||
he = get_he(event->gas.mix);
|
||||
|
||||
o2 = (o2 + 5) / 10;
|
||||
he = (he + 5) / 10;
|
||||
|
@ -1980,7 +1980,7 @@ static int sort_event(struct event *a, struct event *b)
|
|||
static int same_gas(struct event *a, struct event *b)
|
||||
{
|
||||
if (a->type == b->type && a->flags == b->flags && a->value == b->value && !strcmp(a->name, b->name) &&
|
||||
same_gasmix(&a->gas.mix, &b->gas.mix)) {
|
||||
same_gasmix(a->gas.mix, b->gas.mix)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -2078,7 +2078,7 @@ extern int get_cylinder_idx_by_use(struct dive *dive, enum cylinderuse cylinder_
|
|||
return -1; // negative number means cylinder_use_type not found in list of cylinders
|
||||
}
|
||||
|
||||
int gasmix_distance(const struct gasmix *a, const struct gasmix *b)
|
||||
int gasmix_distance(struct gasmix a, struct gasmix b)
|
||||
{
|
||||
int a_o2 = get_o2(a), b_o2 = get_o2(b);
|
||||
int a_he = get_he(a), b_he = get_he(b);
|
||||
|
@ -2099,7 +2099,7 @@ int gasmix_distance(const struct gasmix *a, const struct gasmix *b)
|
|||
* 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.
|
||||
*/
|
||||
extern void fill_pressures(struct gas_pressures *pressures, const double amb_pressure, const struct gasmix *mix, double po2, enum divemode_t divemode)
|
||||
extern 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) {
|
||||
|
@ -2204,20 +2204,20 @@ void cylinder_renumber(struct dive *dive, int mapping[])
|
|||
dc_cylinder_renumber(dive, dc, mapping);
|
||||
}
|
||||
|
||||
int same_gasmix(struct gasmix *a, struct gasmix *b)
|
||||
int same_gasmix(struct gasmix a, struct gasmix b)
|
||||
{
|
||||
if (gasmix_is_air(a) && gasmix_is_air(b))
|
||||
return 1;
|
||||
return a->o2.permille == b->o2.permille && a->he.permille == b->he.permille;
|
||||
return a.o2.permille == b.o2.permille && a.he.permille == b.he.permille;
|
||||
}
|
||||
|
||||
int same_gasmix_cylinder(cylinder_t *cyl, int cylid, struct dive *dive, bool check_unused)
|
||||
{
|
||||
struct gasmix *mygas = &cyl->gasmix;
|
||||
struct gasmix mygas = cyl->gasmix;
|
||||
for (int i = 0; i < MAX_CYLINDERS; i++) {
|
||||
if (i == cylid || cylinder_none(&dive->cylinder[i]))
|
||||
continue;
|
||||
struct gasmix *gas2 = &dive->cylinder[i].gasmix;
|
||||
struct gasmix gas2 = dive->cylinder[i].gasmix;
|
||||
if (gasmix_distance(mygas, gas2) == 0 && (is_cylinder_used(dive, i) || check_unused))
|
||||
return i;
|
||||
}
|
||||
|
@ -2253,7 +2253,7 @@ static int match_cylinder(cylinder_t *cyl, struct dive *dive, unsigned int avail
|
|||
if (!(available & (1u << i)))
|
||||
continue;
|
||||
target = dive->cylinder + i;
|
||||
if (!same_gasmix(&cyl->gasmix, &target->gasmix))
|
||||
if (!same_gasmix(cyl->gasmix, target->gasmix))
|
||||
continue;
|
||||
if (cyl->cylinder_use != target->cylinder_use)
|
||||
continue;
|
||||
|
@ -4062,10 +4062,10 @@ fraction_t best_he(depth_t depth, struct dive *dive)
|
|||
return fhe;
|
||||
}
|
||||
|
||||
bool gasmix_is_air(const struct gasmix *gasmix)
|
||||
bool gasmix_is_air(struct gasmix gasmix)
|
||||
{
|
||||
int o2 = gasmix->o2.permille;
|
||||
int he = gasmix->he.permille;
|
||||
int o2 = gasmix.o2.permille;
|
||||
int he = gasmix.he.permille;
|
||||
return (he == 0) && (o2 == 0 || ((o2 >= O2_IN_AIR - 1) && (o2 <= O2_IN_AIR + 1)));
|
||||
}
|
||||
|
||||
|
@ -4148,7 +4148,7 @@ int mbar_to_depth(int mbar, struct dive *dive)
|
|||
}
|
||||
|
||||
/* MOD rounded to multiples of roundto mm */
|
||||
depth_t gas_mod(struct gasmix *mix, pressure_t po2_limit, struct dive *dive, int roundto)
|
||||
depth_t gas_mod(struct gasmix mix, pressure_t po2_limit, struct dive *dive, int roundto)
|
||||
{
|
||||
depth_t rounded_depth;
|
||||
|
||||
|
@ -4158,7 +4158,7 @@ depth_t gas_mod(struct gasmix *mix, pressure_t po2_limit, struct dive *dive, int
|
|||
}
|
||||
|
||||
/* Maximum narcotic depth rounded to multiples of roundto mm */
|
||||
depth_t gas_mnd(struct gasmix *mix, depth_t end, struct dive *dive, int roundto)
|
||||
depth_t gas_mnd(struct gasmix mix, depth_t end, struct dive *dive, int roundto)
|
||||
{
|
||||
depth_t rounded_depth;
|
||||
pressure_t ppo2n2;
|
||||
|
@ -4287,7 +4287,7 @@ int dive_has_gps_location(struct dive *dive)
|
|||
return dive_site_has_gps_location(get_dive_site_by_uuid(dive->dive_site_uuid));
|
||||
}
|
||||
|
||||
struct gasmix get_gasmix(struct dive *dive, struct divecomputer *dc, int time, struct event **evp, struct gasmix *gasmix)
|
||||
struct gasmix get_gasmix(struct dive *dive, struct divecomputer *dc, int time, struct event **evp, struct gasmix gasmix)
|
||||
{
|
||||
struct event *ev = *evp;
|
||||
struct gasmix res;
|
||||
|
@ -4298,7 +4298,7 @@ struct gasmix get_gasmix(struct dive *dive, struct divecomputer *dc, int time, s
|
|||
res = dive->cylinder[cyl].gasmix;
|
||||
ev = dc ? get_next_event(dc->events, "gaschange") : NULL;
|
||||
} else {
|
||||
res = *gasmix;
|
||||
res = gasmix;
|
||||
}
|
||||
|
||||
while (ev && ev->time.seconds < time) {
|
||||
|
@ -4314,5 +4314,5 @@ struct gasmix get_gasmix_at_time(struct dive *d, struct divecomputer *dc, durati
|
|||
{
|
||||
struct event *ev = NULL;
|
||||
struct gasmix gasmix = { 0 };
|
||||
return get_gasmix(d, dc, time.seconds, &ev, &gasmix);
|
||||
return get_gasmix(d, dc, time.seconds, &ev, gasmix);
|
||||
}
|
||||
|
|
38
core/dive.h
38
core/dive.h
|
@ -71,7 +71,7 @@ struct icd_data { // This structure provides communication between function isob
|
|||
int dHe; // The change in fraction (permille) of helium during the change
|
||||
};
|
||||
|
||||
extern bool isobaric_counterdiffusion(struct gasmix *oldgasmix, struct gasmix *newgasmix, struct icd_data *results);
|
||||
extern bool isobaric_counterdiffusion(struct gasmix oldgasmix, struct gasmix newgasmix, struct icd_data *results);
|
||||
|
||||
/*
|
||||
* Events are currently based straight on what libdivecomputer gives us.
|
||||
|
@ -114,32 +114,32 @@ extern int units_to_sac(double volume);
|
|||
|
||||
/* Volume in mliter of a cylinder at pressure 'p' */
|
||||
extern int gas_volume(cylinder_t *cyl, pressure_t p);
|
||||
extern double gas_compressibility_factor(struct gasmix *gas, double bar);
|
||||
extern double isothermal_pressure(struct gasmix *gas, double p1, int volume1, int volume2);
|
||||
extern double gas_density(struct gasmix *gas, int pressure);
|
||||
extern int same_gasmix(struct gasmix *a, struct gasmix *b);
|
||||
extern double gas_compressibility_factor(struct gasmix gas, double bar);
|
||||
extern double isothermal_pressure(struct gasmix gas, double p1, int volume1, int volume2);
|
||||
extern double gas_density(struct gasmix gas, int pressure);
|
||||
extern int same_gasmix(struct gasmix a, struct gasmix b);
|
||||
|
||||
static inline int get_o2(const struct gasmix *mix)
|
||||
static inline int get_o2(struct gasmix mix)
|
||||
{
|
||||
return mix->o2.permille ?: O2_IN_AIR;
|
||||
return mix.o2.permille ?: O2_IN_AIR;
|
||||
}
|
||||
|
||||
static inline int get_he(const struct gasmix *mix)
|
||||
static inline int get_he(struct gasmix mix)
|
||||
{
|
||||
return mix->he.permille;
|
||||
return mix.he.permille;
|
||||
}
|
||||
|
||||
struct gas_pressures {
|
||||
double o2, n2, he;
|
||||
};
|
||||
|
||||
extern void fill_pressures(struct gas_pressures *pressures, const double amb_pressure, const struct gasmix *mix, double po2, enum divemode_t dctype);
|
||||
extern void fill_pressures(struct gas_pressures *pressures, const double amb_pressure, struct gasmix mix, double po2, enum divemode_t dctype);
|
||||
|
||||
extern void sanitize_gasmix(struct gasmix *mix);
|
||||
extern int gasmix_distance(const struct gasmix *a, const struct gasmix *b);
|
||||
extern int find_best_gasmix_match(struct gasmix *mix, cylinder_t array[], unsigned int used);
|
||||
extern int gasmix_distance(struct gasmix a, struct gasmix b);
|
||||
extern int find_best_gasmix_match(struct gasmix mix, cylinder_t array[], unsigned int used);
|
||||
|
||||
extern bool gasmix_is_air(const struct gasmix *gasmix);
|
||||
extern bool gasmix_is_air(struct gasmix gasmix);
|
||||
|
||||
/* Linear interpolation between 'a' and 'b', when we are 'part'way into the 'whole' distance from a to b */
|
||||
static inline int interpolate(int a, int b, int part, int whole)
|
||||
|
@ -152,8 +152,8 @@ static inline int interpolate(int a, int b, int part, int whole)
|
|||
return (a+b)/2;
|
||||
}
|
||||
|
||||
void get_gas_string(const struct gasmix *gasmix, char *text, int len);
|
||||
const char *gasname(const struct gasmix *gasmix);
|
||||
void get_gas_string(struct gasmix gasmix, char *text, int len);
|
||||
const char *gasname(struct gasmix gasmix);
|
||||
|
||||
#define MAX_SENSORS 2
|
||||
struct sample // BASE TYPE BYTES UNITS RANGE DESCRIPTION
|
||||
|
@ -396,8 +396,8 @@ extern double depth_to_bar(int depth, struct dive *dive);
|
|||
extern double depth_to_atm(int depth, struct dive *dive);
|
||||
extern int rel_mbar_to_depth(int mbar, struct dive *dive);
|
||||
extern int mbar_to_depth(int mbar, struct dive *dive);
|
||||
extern depth_t gas_mod(struct gasmix *mix, pressure_t po2_limit, struct dive *dive, int roundto);
|
||||
extern depth_t gas_mnd(struct gasmix *mix, depth_t end, struct dive *dive, int roundto);
|
||||
extern depth_t gas_mod(struct gasmix mix, pressure_t po2_limit, struct dive *dive, int roundto);
|
||||
extern depth_t gas_mnd(struct gasmix mix, depth_t end, struct dive *dive, int roundto);
|
||||
|
||||
#define SURFACE_THRESHOLD 750 /* somewhat arbitrary: only below 75cm is it really diving */
|
||||
|
||||
|
@ -663,7 +663,7 @@ struct deco_state {
|
|||
bool icd_warning;
|
||||
};
|
||||
|
||||
extern void add_segment(struct deco_state *ds, double pressure, const struct gasmix *gasmix, int period_in_seconds, int setpoint, enum divemode_t divemode, int sac);
|
||||
extern void add_segment(struct deco_state *ds, double pressure, struct gasmix gasmix, int period_in_seconds, int setpoint, enum divemode_t divemode, int sac);
|
||||
extern void clear_deco(struct deco_state *ds, double surface_pressure);
|
||||
extern void dump_tissues(struct deco_state *ds);
|
||||
extern void set_gf(short gflow, short gfhigh);
|
||||
|
@ -722,7 +722,7 @@ extern struct event *get_next_event(struct event *event, const char *name);
|
|||
* In "evp", pass a pointer to a "struct event *" which is NULL-initialized on first invocation.
|
||||
* On subsequent calls, pass the same "evp" and the "gasmix" from previous calls.
|
||||
*/
|
||||
extern struct gasmix get_gasmix(struct dive *dive, struct divecomputer *dc, int time, struct event **evp, struct gasmix *gasmix);
|
||||
extern struct gasmix get_gasmix(struct dive *dive, struct divecomputer *dc, int time, struct event **evp, struct gasmix gasmix);
|
||||
|
||||
/* Get gasmix at a given time */
|
||||
extern struct gasmix get_gasmix_at_time(struct dive *dive, struct divecomputer *dc, duration_t time);
|
||||
|
|
|
@ -94,8 +94,8 @@ void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2max_p)
|
|||
|
||||
for (i = 0; i < MAX_CYLINDERS; i++) {
|
||||
cylinder_t *cyl = dive->cylinder + i;
|
||||
int o2 = get_o2(&cyl->gasmix);
|
||||
int he = get_he(&cyl->gasmix);
|
||||
int o2 = get_o2(cyl->gasmix);
|
||||
int he = get_he(cyl->gasmix);
|
||||
|
||||
if (!is_cylinder_used(dive, i))
|
||||
continue;
|
||||
|
@ -135,7 +135,7 @@ int total_weight(struct dive *dive)
|
|||
static int active_o2(struct dive *dive, struct divecomputer *dc, duration_t time)
|
||||
{
|
||||
struct gasmix gas = get_gasmix_at_time(dive, dc, time);
|
||||
return get_o2(&gas);
|
||||
return get_o2(gas);
|
||||
}
|
||||
|
||||
/* calculate OTU for a dive - this only takes the first divecomputer into account */
|
||||
|
@ -420,8 +420,8 @@ static void add_dive_to_deco(struct deco_state *ds, struct dive *dive)
|
|||
|
||||
for (j = t0; j < t1; j++) {
|
||||
int depth = interpolate(psample->depth.mm, sample->depth.mm, j - t0, t1 - t0);
|
||||
gasmix = get_gasmix(dive, dc, j, &ev, &gasmix);
|
||||
add_segment(ds, depth_to_bar(depth, dive), &gasmix, 1, sample->setpoint.mbar,
|
||||
gasmix = get_gasmix(dive, dc, j, &ev, gasmix);
|
||||
add_segment(ds, depth_to_bar(depth, dive), gasmix, 1, sample->setpoint.mbar,
|
||||
get_current_divemode(&dive->dc, j, &evd, ¤t_divemode), dive->sac);
|
||||
}
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ int init_decompression(struct deco_state *ds, struct dive *dive)
|
|||
#endif
|
||||
return surface_time;
|
||||
}
|
||||
add_segment(ds, surface_pressure, &air, surface_time, 0, dive->dc.divemode, prefs.decosac);
|
||||
add_segment(ds, surface_pressure, air, surface_time, 0, dive->dc.divemode, prefs.decosac);
|
||||
#if DECO_CALC_DEBUG & 2
|
||||
printf("Tissues after surface intervall of %d:%02u:\n", FRACTION(surface_time, 60));
|
||||
dump_tissues(ds);
|
||||
|
@ -614,7 +614,7 @@ int init_decompression(struct deco_state *ds, struct dive *dive)
|
|||
#endif
|
||||
return surface_time;
|
||||
}
|
||||
add_segment(ds, surface_pressure, &air, surface_time, 0, dive->dc.divemode, prefs.decosac);
|
||||
add_segment(ds, surface_pressure, air, surface_time, 0, dive->dc.divemode, prefs.decosac);
|
||||
#if DECO_CALC_DEBUG & 2
|
||||
printf("Tissues after surface intervall of %d:%02u:\n", FRACTION(surface_time, 60));
|
||||
dump_tissues(ds);
|
||||
|
|
|
@ -81,7 +81,7 @@ bool cylinder_none(void *_data)
|
|||
return cylinder_nodata(cyl) && cylinder_nosamples(cyl);
|
||||
}
|
||||
|
||||
void get_gas_string(const struct gasmix *gasmix, char *text, int len)
|
||||
void get_gas_string(struct gasmix gasmix, char *text, int len)
|
||||
{
|
||||
if (gasmix_is_air(gasmix))
|
||||
snprintf(text, len, "%s", translate("gettextFromC", "air"));
|
||||
|
@ -94,7 +94,7 @@ void get_gas_string(const struct gasmix *gasmix, char *text, int len)
|
|||
}
|
||||
|
||||
/* Returns a static char buffer - only good for immediate use by printf etc */
|
||||
const char *gasname(const struct gasmix *gasmix)
|
||||
const char *gasname(struct gasmix gasmix)
|
||||
{
|
||||
static char gas[64];
|
||||
get_gas_string(gasmix, gas, sizeof(gas));
|
||||
|
@ -216,7 +216,7 @@ void reset_cylinders(struct dive *dive, bool track_gas)
|
|||
if (cylinder_none(cyl))
|
||||
continue;
|
||||
if (cyl->depth.mm == 0) /* if the gas doesn't give a mod, calculate based on prefs */
|
||||
cyl->depth = gas_mod(&cyl->gasmix, decopo2, dive, M_OR_FT(3,10));
|
||||
cyl->depth = gas_mod(cyl->gasmix, decopo2, dive, M_OR_FT(3,10));
|
||||
if (track_gas)
|
||||
cyl->start.mbar = cyl->end.mbar = cyl->type.workingpressure.mbar;
|
||||
cyl->gas_used.mliter = 0;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* NOTE! Helium coefficients are a linear mix operation between the
|
||||
* 323K and one for 273K isotherms, to make everything be at 300K.
|
||||
*/
|
||||
double gas_compressibility_factor(struct gasmix *gas, double bar)
|
||||
double gas_compressibility_factor(struct gasmix gas, double bar)
|
||||
{
|
||||
static const double o2_coefficients[3] = {
|
||||
-7.18092073703e-04,
|
||||
|
@ -69,15 +69,15 @@ double gas_compressibility_factor(struct gasmix *gas, double bar)
|
|||
/* Compute the new pressure when compressing (expanding) volome v1 at pressure p1 bar to volume v2
|
||||
* taking into account the compressebility (to first order) */
|
||||
|
||||
double isothermal_pressure(struct gasmix *gas, double p1, int volume1, int volume2)
|
||||
double isothermal_pressure(struct gasmix gas, double p1, int volume1, int volume2)
|
||||
{
|
||||
double p_ideal = p1 * volume1 / volume2 / gas_compressibility_factor(gas, p1);
|
||||
|
||||
return p_ideal * gas_compressibility_factor(gas, p_ideal);
|
||||
}
|
||||
|
||||
inline double gas_density(struct gasmix *gas, int pressure) {
|
||||
int density = gas->he.permille * HE_DENSITY + gas->o2.permille * O2_DENSITY + (1000 - gas->he.permille - gas->o2.permille) * N2_DENSITY;
|
||||
inline double gas_density(struct gasmix gas, int pressure) {
|
||||
int density = gas.he.permille * HE_DENSITY + gas.o2.permille * O2_DENSITY + (1000 - gas.he.permille - gas.o2.permille) * N2_DENSITY;
|
||||
|
||||
return density * (double) pressure / gas_compressibility_factor(gas, pressure / 1000.0) / SURFACE_PRESSURE / 1000000.0;
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ extern int divinglog_profile(void *handle, int columns, char **data, char **colu
|
|||
cur_sample->pressure[0].mbar = pressure * 100;
|
||||
cur_sample->rbt.seconds = rbt;
|
||||
if (oldcyl != tank) {
|
||||
struct gasmix *mix = &cur_dive->cylinder[tank].gasmix;
|
||||
struct gasmix mix = cur_dive->cylinder[tank].gasmix;
|
||||
int o2 = get_o2(mix);
|
||||
int he = get_he(mix);
|
||||
|
||||
|
|
|
@ -652,7 +652,7 @@ void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int second
|
|||
if (idx < 0 || idx >= MAX_CYLINDERS)
|
||||
return;
|
||||
/* The gas switch event format is insane for historical reasons */
|
||||
struct gasmix *mix = &dive->cylinder[idx].gasmix;
|
||||
struct gasmix mix = dive->cylinder[idx].gasmix;
|
||||
int o2 = get_o2(mix);
|
||||
int he = get_he(mix);
|
||||
struct event *ev;
|
||||
|
@ -665,7 +665,7 @@ void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int second
|
|||
ev = add_event(dc, seconds, he ? SAMPLE_EVENT_GASCHANGE2 : SAMPLE_EVENT_GASCHANGE, 0, value, "gaschange");
|
||||
if (ev) {
|
||||
ev->gas.index = idx;
|
||||
ev->gas.mix = *mix;
|
||||
ev->gas.mix = mix;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -95,12 +95,12 @@ int get_cylinderid_at_time(struct dive *dive, struct divecomputer *dc, duration_
|
|||
return cylinder_idx;
|
||||
}
|
||||
|
||||
int get_gasidx(struct dive *dive, struct gasmix *mix)
|
||||
int get_gasidx(struct dive *dive, struct gasmix mix)
|
||||
{
|
||||
return find_best_gasmix_match(mix, dive->cylinder, 0);
|
||||
}
|
||||
|
||||
void interpolate_transition(struct deco_state *ds, struct dive *dive, duration_t t0, duration_t t1, depth_t d0, depth_t d1, const struct gasmix *gasmix, o2pressure_t po2, enum divemode_t divemode)
|
||||
void interpolate_transition(struct deco_state *ds, struct dive *dive, duration_t t0, duration_t t1, depth_t d0, depth_t d1, struct gasmix gasmix, o2pressure_t po2, enum divemode_t divemode)
|
||||
{
|
||||
int32_t j;
|
||||
|
||||
|
@ -176,7 +176,7 @@ int tissue_at_end(struct deco_state *ds, struct dive *dive, struct deco_state **
|
|||
}
|
||||
|
||||
divemode = get_current_divemode(&dive->dc, t0.seconds + 1, &evdm, &divemode);
|
||||
interpolate_transition(ds, dive, t0, t1, lastdepth, sample->depth, &gas, setpoint, divemode);
|
||||
interpolate_transition(ds, dive, t0, t1, lastdepth, sample->depth, gas, setpoint, divemode);
|
||||
psample = sample;
|
||||
t0 = t1;
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ void fill_default_cylinder(cylinder_t *cyl)
|
|||
cyl->type.size.mliter = lrint(cuft_to_l(ti->cuft) * 1000 / bar_to_atm(psi_to_bar(ti->psi)));
|
||||
}
|
||||
// MOD of air
|
||||
cyl->depth = gas_mod(&cyl->gasmix, pO2, &displayed_dive, 1);
|
||||
cyl->depth = gas_mod(cyl->gasmix, pO2, &displayed_dive, 1);
|
||||
}
|
||||
|
||||
/* calculate the new end pressure of the cylinder, based on its current end pressure and the
|
||||
|
@ -234,7 +234,7 @@ static void update_cylinder_pressure(struct dive *d, int old_depth, int new_dept
|
|||
if (in_deco)
|
||||
cyl->deco_gas_used.mliter += gas_used.mliter;
|
||||
if (cyl->type.size.mliter) {
|
||||
delta_p.mbar = lrint(gas_used.mliter * 1000.0 / cyl->type.size.mliter * gas_compressibility_factor(&cyl->gasmix, cyl->end.mbar / 1000.0));
|
||||
delta_p.mbar = lrint(gas_used.mliter * 1000.0 / cyl->type.size.mliter * gas_compressibility_factor(cyl->gasmix, cyl->end.mbar / 1000.0));
|
||||
cyl->end.mbar -= delta_p.mbar;
|
||||
}
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ void track_ascent_gas(int depth, cylinder_t *cylinder, int avg_depth, int bottom
|
|||
}
|
||||
|
||||
// Determine whether ascending to the next stop will break the ceiling. Return true if the ascent is ok, false if it isn't.
|
||||
bool trial_ascent(struct deco_state *ds, int wait_time, int trial_depth, int stoplevel, int avg_depth, int bottom_time, struct gasmix *gasmix, int po2, double surface_pressure, struct dive *dive, enum divemode_t divemode)
|
||||
bool trial_ascent(struct deco_state *ds, int wait_time, int trial_depth, int stoplevel, int avg_depth, int bottom_time, struct gasmix gasmix, int po2, double surface_pressure, struct dive *dive, enum divemode_t divemode)
|
||||
{
|
||||
|
||||
bool clear_to_ascend = true;
|
||||
|
@ -615,7 +615,7 @@ bool enough_gas(int current_cylinder)
|
|||
* So we always test at the upper bundary, not in the middle!
|
||||
*/
|
||||
|
||||
int wait_until(struct deco_state *ds, struct dive *dive, int clock, int min, int leap, int stepsize, int depth, int target_depth, int avg_depth, int bottom_time, struct gasmix *gasmix, int po2, double surface_pressure, enum divemode_t divemode)
|
||||
int wait_until(struct deco_state *ds, struct dive *dive, int clock, int min, int leap, int stepsize, int depth, int target_depth, int avg_depth, int bottom_time, struct gasmix gasmix, int po2, double surface_pressure, enum divemode_t divemode)
|
||||
{
|
||||
// When a deco stop exceeds two days, there is something wrong...
|
||||
if (min >= 48 * 3600)
|
||||
|
@ -774,11 +774,11 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
// How long can we stay at the current depth and still directly ascent to the surface?
|
||||
do {
|
||||
add_segment(ds, depth_to_bar(depth, dive),
|
||||
&dive->cylinder[current_cylinder].gasmix,
|
||||
dive->cylinder[current_cylinder].gasmix,
|
||||
timestep, po2, divemode, prefs.bottomsac);
|
||||
update_cylinder_pressure(dive, depth, depth, timestep, prefs.bottomsac, &dive->cylinder[current_cylinder], false, divemode);
|
||||
clock += timestep;
|
||||
} while (trial_ascent(ds, 0, depth, 0, avg_depth, bottom_time, &dive->cylinder[current_cylinder].gasmix,
|
||||
} while (trial_ascent(ds, 0, depth, 0, avg_depth, bottom_time, dive->cylinder[current_cylinder].gasmix,
|
||||
po2, diveplan->surface_pressure / 1000.0, dive, divemode) &&
|
||||
enough_gas(current_cylinder) && clock < 6 * 3600);
|
||||
|
||||
|
@ -869,12 +869,12 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
last_ascend_rate = ascent_velocity(depth, avg_depth, bottom_time);
|
||||
/* Always prefer the best_first_ascend_cylinder if it has the right gasmix.
|
||||
* Otherwise take first cylinder from list with rightgasmix */
|
||||
if (same_gasmix(&gas, &dive->cylinder[best_first_ascend_cylinder].gasmix))
|
||||
if (same_gasmix(gas, dive->cylinder[best_first_ascend_cylinder].gasmix))
|
||||
current_cylinder = best_first_ascend_cylinder;
|
||||
else
|
||||
current_cylinder = get_gasidx(dive, &gas);
|
||||
current_cylinder = get_gasidx(dive, gas);
|
||||
if (current_cylinder == -1) {
|
||||
report_error(translate("gettextFromC", "Can't find gas %s"), gasname(&gas));
|
||||
report_error(translate("gettextFromC", "Can't find gas %s"), gasname(gas));
|
||||
current_cylinder = 0;
|
||||
}
|
||||
reset_regression();
|
||||
|
@ -894,7 +894,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
deltad = depth - stoplevels[stopidx];
|
||||
|
||||
add_segment(ds, depth_to_bar(depth, dive),
|
||||
&dive->cylinder[current_cylinder].gasmix,
|
||||
dive->cylinder[current_cylinder].gasmix,
|
||||
TIMESTEP, po2, divemode, prefs.decosac);
|
||||
last_segment_min_switch = false;
|
||||
clock += TIMESTEP;
|
||||
|
@ -923,7 +923,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
if (current_cylinder != gaschanges[gi].gasidx) {
|
||||
if (!prefs.switch_at_req_stop ||
|
||||
!trial_ascent(ds, 0, depth, stoplevels[stopidx - 1], avg_depth, bottom_time,
|
||||
&dive->cylinder[current_cylinder].gasmix, po2, diveplan->surface_pressure / 1000.0, dive, divemode) || get_o2(&dive->cylinder[current_cylinder].gasmix) < 160) {
|
||||
dive->cylinder[current_cylinder].gasmix, po2, diveplan->surface_pressure / 1000.0, dive, divemode) || get_o2(dive->cylinder[current_cylinder].gasmix) < 160) {
|
||||
current_cylinder = gaschanges[gi].gasidx;
|
||||
gas = dive->cylinder[current_cylinder].gasmix;
|
||||
#if DEBUG_PLAN & 16
|
||||
|
@ -931,9 +931,9 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
(get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[gi].depth / 1000.0);
|
||||
#endif
|
||||
/* Stop for the minimum duration to switch gas unless we switch to o2 */
|
||||
if (!last_segment_min_switch && get_o2(&dive->cylinder[current_cylinder].gasmix) != 1000) {
|
||||
if (!last_segment_min_switch && get_o2(dive->cylinder[current_cylinder].gasmix) != 1000) {
|
||||
add_segment(ds, depth_to_bar(depth, dive),
|
||||
&dive->cylinder[current_cylinder].gasmix,
|
||||
dive->cylinder[current_cylinder].gasmix,
|
||||
prefs.min_switch_duration, po2, divemode, prefs.decosac);
|
||||
clock += prefs.min_switch_duration;
|
||||
last_segment_min_switch = true;
|
||||
|
@ -953,7 +953,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
while (1) {
|
||||
/* Check if ascending to next stop is clear, go back and wait if we hit the ceiling on the way */
|
||||
if (trial_ascent(ds, 0, depth, stoplevels[stopidx], avg_depth, bottom_time,
|
||||
&dive->cylinder[current_cylinder].gasmix, po2, diveplan->surface_pressure / 1000.0, dive, divemode)) {
|
||||
dive->cylinder[current_cylinder].gasmix, po2, diveplan->surface_pressure / 1000.0, dive, divemode)) {
|
||||
decostoptable[decostopcounter].depth = depth;
|
||||
decostoptable[decostopcounter].time = 0;
|
||||
decostopcounter++;
|
||||
|
@ -985,9 +985,9 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
(get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[gi + 1].depth / 1000.0);
|
||||
#endif
|
||||
/* Stop for the minimum duration to switch gas unless we switch to o2 */
|
||||
if (!last_segment_min_switch && get_o2(&dive->cylinder[current_cylinder].gasmix) != 1000) {
|
||||
if (!last_segment_min_switch && get_o2(dive->cylinder[current_cylinder].gasmix) != 1000) {
|
||||
add_segment(ds, depth_to_bar(depth, dive),
|
||||
&dive->cylinder[current_cylinder].gasmix,
|
||||
dive->cylinder[current_cylinder].gasmix,
|
||||
prefs.min_switch_duration, po2, divemode, prefs.decosac);
|
||||
clock += prefs.min_switch_duration;
|
||||
last_segment_min_switch = true;
|
||||
|
@ -996,7 +996,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
}
|
||||
|
||||
int new_clock = wait_until(ds, dive, clock, clock, laststoptime * 2 + 1, timestep, depth, stoplevels[stopidx], avg_depth,
|
||||
bottom_time, &dive->cylinder[current_cylinder].gasmix, po2, diveplan->surface_pressure / 1000.0, divemode);
|
||||
bottom_time, dive->cylinder[current_cylinder].gasmix, po2, diveplan->surface_pressure / 1000.0, divemode);
|
||||
laststoptime = new_clock - clock;
|
||||
/* Finish infinite deco */
|
||||
if (laststoptime >= 48 * 3600 && depth >= 6000) {
|
||||
|
@ -1011,12 +1011,12 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
* backgas. This could be customized if there were demand.
|
||||
*/
|
||||
if (break_cylinder == -1) {
|
||||
if (get_o2(&dive->cylinder[best_first_ascend_cylinder].gasmix) <= 320)
|
||||
if (get_o2(dive->cylinder[best_first_ascend_cylinder].gasmix) <= 320)
|
||||
break_cylinder = best_first_ascend_cylinder;
|
||||
else
|
||||
break_cylinder = 0;
|
||||
}
|
||||
if (get_o2(&dive->cylinder[current_cylinder].gasmix) == 1000) {
|
||||
if (get_o2(dive->cylinder[current_cylinder].gasmix) == 1000) {
|
||||
if (laststoptime >= 12 * 60) {
|
||||
laststoptime = 12 * 60;
|
||||
new_clock = clock + laststoptime;
|
||||
|
@ -1043,7 +1043,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
}
|
||||
}
|
||||
}
|
||||
add_segment(ds, depth_to_bar(depth, dive), &dive->cylinder[stop_cylinder].gasmix,
|
||||
add_segment(ds, depth_to_bar(depth, dive), dive->cylinder[stop_cylinder].gasmix,
|
||||
laststoptime, po2, divemode, prefs.decosac);
|
||||
last_segment_min_switch = false;
|
||||
decostoptable[decostopcounter].depth = depth;
|
||||
|
|
|
@ -18,7 +18,7 @@ extern void set_display_runtime(bool display);
|
|||
extern void set_display_duration(bool display);
|
||||
extern void set_display_transitions(bool display);
|
||||
extern int get_cylinderid_at_time(struct dive *dive, struct divecomputer *dc, duration_t time);
|
||||
extern int get_gasidx(struct dive *dive, struct gasmix *mix);
|
||||
extern int get_gasidx(struct dive *dive, struct gasmix mix);
|
||||
extern bool diveplan_empty(struct diveplan *diveplan);
|
||||
extern void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_disclaimer, int error);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ static int diveplan_duration(struct diveplan *diveplan)
|
|||
* 5) Pointers to gas mixes in the gas change: gas-from and gas-to.
|
||||
* Returns: The size of the output buffer that has been used after the new results have been added.
|
||||
*/
|
||||
static void add_icd_entry(struct membuffer *b, struct icd_data *icdvalues, bool printheader, int time_seconds, int ambientpressure_mbar, struct gasmix *gas_from, struct gasmix *gas_to)
|
||||
static void add_icd_entry(struct membuffer *b, struct icd_data *icdvalues, bool printheader, int time_seconds, int ambientpressure_mbar, struct gasmix gas_from, struct gasmix gas_to)
|
||||
{
|
||||
if (printheader) { // Create a table description and a table header if no icd data have been written yet.
|
||||
put_format(b, "<div>%s:", translate("gettextFromC","Isobaric counterdiffusion information"));
|
||||
|
@ -179,8 +179,8 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
nextdp = nextdp->next;
|
||||
if (nextdp)
|
||||
newgasmix = dive->cylinder[nextdp->cylinderid].gasmix;
|
||||
gaschange_after = (nextdp && (gasmix_distance(&gasmix, &newgasmix)));
|
||||
gaschange_before = (gasmix_distance(&lastprintgasmix, &gasmix));
|
||||
gaschange_after = (nextdp && (gasmix_distance(gasmix, newgasmix)));
|
||||
gaschange_before = (gasmix_distance(lastprintgasmix, gasmix));
|
||||
rebreatherchange_after = (nextdp && (dp->setpoint != nextdp->setpoint || dp->divemode != nextdp->divemode));
|
||||
rebreatherchange_before = lastprintsetpoint != dp->setpoint || lastdivemode != dp->divemode;
|
||||
/* do we want to skip this leg as it is devoid of anything useful? */
|
||||
|
@ -215,7 +215,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
decimals, depthvalue, depth_unit,
|
||||
FRACTION(dp->time - lasttime, 60),
|
||||
FRACTION(dp->time, 60),
|
||||
gasname(&gasmix),
|
||||
gasname(gasmix),
|
||||
(double) dp->setpoint / 1000.0);
|
||||
} else {
|
||||
put_format_loc(&buf, translate("gettextFromC", "%s to %.*f %s in %d:%02d min - runtime %d:%02u on %s"),
|
||||
|
@ -223,7 +223,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
decimals, depthvalue, depth_unit,
|
||||
FRACTION(dp->time - lasttime, 60),
|
||||
FRACTION(dp->time, 60),
|
||||
gasname(&gasmix));
|
||||
gasname(gasmix));
|
||||
}
|
||||
|
||||
put_string(&buf, "<br>");
|
||||
|
@ -237,14 +237,14 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
decimals, depthvalue, depth_unit,
|
||||
FRACTION(dp->time - lasttime, 60),
|
||||
FRACTION(dp->time, 60),
|
||||
gasname(&gasmix),
|
||||
gasname(gasmix),
|
||||
(double) dp->setpoint / 1000.0);
|
||||
} else {
|
||||
put_format_loc(&buf, translate("gettextFromC", "Stay at %.*f %s for %d:%02d min - runtime %d:%02u on %s %s"),
|
||||
decimals, depthvalue, depth_unit,
|
||||
FRACTION(dp->time - lasttime, 60),
|
||||
FRACTION(dp->time, 60),
|
||||
gasname(&gasmix),
|
||||
gasname(gasmix),
|
||||
translate("gettextFromC", divemode_text_ui[dp->divemode]));
|
||||
}
|
||||
put_string(&buf, "<br>");
|
||||
|
@ -308,16 +308,16 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
if (dp->setpoint) {
|
||||
asprintf_loc(&temp, translate("gettextFromC", "(SP = %.1fbar CCR)"), dp->setpoint / 1000.0);
|
||||
put_format(&buf, "<td style='padding-left: 10px; color: red; float: left;'><b>%s %s</b></td>",
|
||||
gasname(&newgasmix), temp);
|
||||
gasname(newgasmix), temp);
|
||||
free(temp);
|
||||
} else {
|
||||
put_format(&buf, "<td style='padding-left: 10px; color: red; float: left;'><b>%s %s</b></td>",
|
||||
gasname(&newgasmix), lastdivemode == UNDEF_COMP_TYPE || lastdivemode == dp->divemode ? "" : translate("gettextFromC", divemode_text_ui[dp->divemode]));
|
||||
if (isascent && (get_he(&lastprintgasmix) > 0)) { // For a trimix gas change on ascent, save ICD info if previous cylinder had helium
|
||||
if (isobaric_counterdiffusion(&lastprintgasmix, &newgasmix, &icdvalues)) // Do icd calulations
|
||||
gasname(newgasmix), lastdivemode == UNDEF_COMP_TYPE || lastdivemode == dp->divemode ? "" : translate("gettextFromC", divemode_text_ui[dp->divemode]));
|
||||
if (isascent && (get_he(lastprintgasmix) > 0)) { // For a trimix gas change on ascent, save ICD info if previous cylinder had helium
|
||||
if (isobaric_counterdiffusion(lastprintgasmix, newgasmix, &icdvalues)) // Do icd calulations
|
||||
icdwarning = true;
|
||||
if (icdvalues.dN2 > 0) { // If the gas change involved helium as well as an increase in nitrogen..
|
||||
add_icd_entry(&icdbuf, &icdvalues, icdtableheader, dp->time, depth_to_mbar(dp->depth.mm, dive), &lastprintgasmix, &newgasmix); // .. then print calculations to buffer.
|
||||
add_icd_entry(&icdbuf, &icdvalues, icdtableheader, dp->time, depth_to_mbar(dp->depth.mm, dive), lastprintgasmix, newgasmix); // .. then print calculations to buffer.
|
||||
icdtableheader = false;
|
||||
}
|
||||
}
|
||||
|
@ -330,16 +330,16 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
// If a new gas has been used for this segment, now is the time to show it
|
||||
if (dp->setpoint) {
|
||||
asprintf_loc(&temp, translate("gettextFromC", "(SP = %.1fbar CCR)"), (double) dp->setpoint / 1000.0);
|
||||
put_format(&buf, "<td style='padding-left: 10px; color: red; float: left;'><b>%s %s</b></td>", gasname(&gasmix), temp);
|
||||
put_format(&buf, "<td style='padding-left: 10px; color: red; float: left;'><b>%s %s</b></td>", gasname(gasmix), temp);
|
||||
free(temp);
|
||||
} else {
|
||||
put_format(&buf, "<td style='padding-left: 10px; color: red; float: left;'><b>%s %s</b></td>", gasname(&gasmix),
|
||||
put_format(&buf, "<td style='padding-left: 10px; color: red; float: left;'><b>%s %s</b></td>", gasname(gasmix),
|
||||
lastdivemode == UNDEF_COMP_TYPE || lastdivemode == dp->divemode ? "" : translate("gettextFromC", divemode_text_ui[dp->divemode]));
|
||||
if (get_he(&lastprintgasmix) > 0) { // For a trimix gas change, save ICD info if previous cylinder had helium
|
||||
if (isobaric_counterdiffusion(&lastprintgasmix, &gasmix, &icdvalues)) // Do icd calculations
|
||||
if (get_he(lastprintgasmix) > 0) { // For a trimix gas change, save ICD info if previous cylinder had helium
|
||||
if (isobaric_counterdiffusion(lastprintgasmix, gasmix, &icdvalues)) // Do icd calculations
|
||||
icdwarning = true;
|
||||
if (icdvalues.dN2 > 0) { // If the gas change involved helium as well as an increase in nitrogen..
|
||||
add_icd_entry(&icdbuf, &icdvalues, icdtableheader, lasttime, depth_to_mbar(dp->depth.mm, dive), &lastprintgasmix, &gasmix); // .. then print data to buffer.
|
||||
add_icd_entry(&icdbuf, &icdvalues, icdtableheader, lasttime, depth_to_mbar(dp->depth.mm, dive), lastprintgasmix, gasmix); // .. then print data to buffer.
|
||||
icdtableheader = false;
|
||||
}
|
||||
}
|
||||
|
@ -362,14 +362,14 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
if (plan_verbatim) {
|
||||
if (lastsetpoint >= 0) {
|
||||
if (nextdp && nextdp->setpoint) {
|
||||
put_format_loc(&buf, translate("gettextFromC", "Switch gas to %s (SP = %.1fbar)"), gasname(&newgasmix), (double) nextdp->setpoint / 1000.0);
|
||||
put_format_loc(&buf, translate("gettextFromC", "Switch gas to %s (SP = %.1fbar)"), gasname(newgasmix), (double) nextdp->setpoint / 1000.0);
|
||||
} else {
|
||||
put_format(&buf, translate("gettextFromC", "Switch gas to %s"), gasname(&newgasmix));
|
||||
if ((isascent) && (get_he(&lastprintgasmix) > 0)) { // For a trimix gas change on ascent:
|
||||
if (isobaric_counterdiffusion(&lastprintgasmix, &newgasmix, &icdvalues)) // Do icd calculations
|
||||
put_format(&buf, translate("gettextFromC", "Switch gas to %s"), gasname(newgasmix));
|
||||
if ((isascent) && (get_he(lastprintgasmix) > 0)) { // For a trimix gas change on ascent:
|
||||
if (isobaric_counterdiffusion(lastprintgasmix, newgasmix, &icdvalues)) // Do icd calculations
|
||||
icdwarning = true;
|
||||
if (icdvalues.dN2 > 0) { // If the gas change involved helium as well as an increase in nitrogen..
|
||||
add_icd_entry(&icdbuf, &icdvalues, icdtableheader, dp->time, depth_to_mbar(dp->depth.mm, dive), &lastprintgasmix, &newgasmix); // ... then print data to buffer.
|
||||
add_icd_entry(&icdbuf, &icdvalues, icdtableheader, dp->time, depth_to_mbar(dp->depth.mm, dive), lastprintgasmix, newgasmix); // ... then print data to buffer.
|
||||
icdtableheader = false;
|
||||
}
|
||||
}
|
||||
|
@ -451,8 +451,8 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
volume = get_volume_units(cyl->gas_used.mliter, NULL, &unit);
|
||||
deco_volume = get_volume_units(cyl->deco_gas_used.mliter, NULL, &unit);
|
||||
if (cyl->type.size.mliter) {
|
||||
int remaining_gas = lrint((double)cyl->end.mbar * cyl->type.size.mliter / 1000.0 / gas_compressibility_factor(&cyl->gasmix, cyl->end.mbar / 1000.0));
|
||||
double deco_pressure_mbar = isothermal_pressure(&cyl->gasmix, 1.0, remaining_gas + cyl->deco_gas_used.mliter,
|
||||
int remaining_gas = lrint((double)cyl->end.mbar * cyl->type.size.mliter / 1000.0 / gas_compressibility_factor(cyl->gasmix, cyl->end.mbar / 1000.0));
|
||||
double deco_pressure_mbar = isothermal_pressure(cyl->gasmix, 1.0, remaining_gas + cyl->deco_gas_used.mliter,
|
||||
cyl->type.size.mliter) * 1000 - cyl->end.mbar;
|
||||
deco_pressure = get_pressure_units(lrint(deco_pressure_mbar), &pressure_unit);
|
||||
pressure = get_pressure_units(cyl->start.mbar - cyl->end.mbar, &pressure_unit);
|
||||
|
@ -464,7 +464,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
translate("gettextFromC", "Warning:"),
|
||||
translate("gettextFromC", "this is more gas than available in the specified cylinder!"));
|
||||
else
|
||||
if (cyl->end.mbar / 1000.0 * cyl->type.size.mliter / gas_compressibility_factor(&cyl->gasmix, cyl->end.mbar / 1000.0)
|
||||
if (cyl->end.mbar / 1000.0 * cyl->type.size.mliter / gas_compressibility_factor(cyl->gasmix, cyl->end.mbar / 1000.0)
|
||||
< cyl->deco_gas_used.mliter)
|
||||
snprintf(warning, sizeof(warning), "<br> — <span style='color: red;'>%s </span> %s",
|
||||
translate("gettextFromC", "Warning:"),
|
||||
|
@ -481,7 +481,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
* depth_to_bar(lastbottomdp->depth.mm, dive)
|
||||
+ prefs.sacfactor / 100.0 * cyl->deco_gas_used.mliter);
|
||||
/* Calculate minimum gas pressure for cyclinder. */
|
||||
lastbottomdp->minimum_gas.mbar = lrint(isothermal_pressure(&cyl->gasmix, 1.0,
|
||||
lastbottomdp->minimum_gas.mbar = lrint(isothermal_pressure(cyl->gasmix, 1.0,
|
||||
mingasv.mliter, cyl->type.size.mliter) * 1000);
|
||||
/* Translate all results into correct units */
|
||||
mingas_volume = get_volume_units(mingasv.mliter, NULL, &unit);
|
||||
|
@ -513,18 +513,18 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
/* Print the gas consumption for every cylinder here to temp buffer. */
|
||||
if (lrint(volume) > 0) {
|
||||
asprintf_loc(&temp, translate("gettextFromC", "%.0f%s/%.0f%s of <span style='color: red;'><b>%s</b></span> (%.0f%s/%.0f%s in planned ascent)"),
|
||||
volume, unit, pressure, pressure_unit, gasname(&cyl->gasmix), deco_volume, unit, deco_pressure, pressure_unit);
|
||||
volume, unit, pressure, pressure_unit, gasname(cyl->gasmix), deco_volume, unit, deco_pressure, pressure_unit);
|
||||
} else {
|
||||
asprintf_loc(&temp, translate("gettextFromC", "%.0f%s/%.0f%s of <span style='color: red;'><b>%s</b></span>"),
|
||||
volume, unit, pressure, pressure_unit, gasname(&cyl->gasmix));
|
||||
volume, unit, pressure, pressure_unit, gasname(cyl->gasmix));
|
||||
}
|
||||
} else {
|
||||
if (lrint(volume) > 0) {
|
||||
asprintf_loc(&temp, translate("gettextFromC", "%.0f%s of <span style='color: red;'><b>%s</b></span> (%.0f%s during planned ascent)"),
|
||||
volume, unit, gasname(&cyl->gasmix), deco_volume, unit);
|
||||
volume, unit, gasname(cyl->gasmix), deco_volume, unit);
|
||||
} else {
|
||||
asprintf_loc(&temp, translate("gettextFromC", "%.0f%s of <span style='color: red;'><b>%s</b></span>"),
|
||||
volume, unit, gasname(&cyl->gasmix));
|
||||
volume, unit, gasname(cyl->gasmix));
|
||||
}
|
||||
}
|
||||
/* Gas consumption: Now finally print all strings to output */
|
||||
|
@ -558,11 +558,11 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
while (dp) {
|
||||
if (dp->time != 0) {
|
||||
struct gas_pressures pressures;
|
||||
struct gasmix *gasmix = &dive->cylinder[dp->cylinderid].gasmix;
|
||||
struct gasmix gasmix = dive->cylinder[dp->cylinderid].gasmix;
|
||||
|
||||
current_divemode = get_current_divemode(&dive->dc, dp->time, &evd, ¤t_divemode);
|
||||
amb = depth_to_atm(dp->depth.mm, dive);
|
||||
fill_pressures(&pressures, amb, gasmix, (current_divemode == OC) ? 0.0 : amb * gasmix->o2.permille / 1000.0, current_divemode);
|
||||
fill_pressures(&pressures, amb, gasmix, (current_divemode == OC) ? 0.0 : amb * gasmix.o2.permille / 1000.0, current_divemode);
|
||||
|
||||
if (pressures.o2 > (dp->entered ? prefs.bottompo2 : prefs.decopo2) / 1000.0) {
|
||||
const char *depth_unit;
|
||||
|
|
|
@ -333,7 +333,7 @@ int get_cylinder_index(struct dive *dive, struct event *ev)
|
|||
fprintf(stderr, "Still looking up cylinder based on gas mix in get_cylinder_index()!\n");
|
||||
|
||||
mix = get_gasmix_from_event(dive, ev);
|
||||
best = find_best_gasmix_match(&mix, dive->cylinder, 0);
|
||||
best = find_best_gasmix_match(mix, dive->cylinder, 0);
|
||||
return best < 0 ? 0 : best;
|
||||
}
|
||||
|
||||
|
@ -760,14 +760,14 @@ static void fill_sac(struct dive *dive, struct plot_info *pi, int idx, unsigned
|
|||
/*
|
||||
* Create a bitmap of cylinders that match our current gasmix
|
||||
*/
|
||||
static unsigned int matching_gases(struct dive *dive, struct gasmix *gasmix)
|
||||
static unsigned int matching_gases(struct dive *dive, struct gasmix gasmix)
|
||||
{
|
||||
int i;
|
||||
unsigned int gases = 0;
|
||||
|
||||
for (i = 0; i < MAX_CYLINDERS; i++) {
|
||||
cylinder_t *cyl = dive->cylinder + i;
|
||||
if (same_gasmix(gasmix, &cyl->gasmix))
|
||||
if (same_gasmix(gasmix, cyl->gasmix))
|
||||
gases |= 1 << i;
|
||||
}
|
||||
return gases;
|
||||
|
@ -781,10 +781,10 @@ static void calculate_sac(struct dive *dive, struct divecomputer *dc, struct plo
|
|||
|
||||
for (int i = 0; i < pi->nr; i++) {
|
||||
struct plot_data *entry = pi->entry + i;
|
||||
struct gasmix newmix = get_gasmix(dive, dc, entry->sec, &ev, &gasmix);
|
||||
if (!same_gasmix(&newmix, &gasmix)) {
|
||||
struct gasmix newmix = get_gasmix(dive, dc, entry->sec, &ev, gasmix);
|
||||
if (!same_gasmix(newmix, gasmix)) {
|
||||
gasmix = newmix;
|
||||
gases = matching_gases(dive, &newmix);
|
||||
gases = matching_gases(dive, newmix);
|
||||
}
|
||||
|
||||
fill_sac(dive, pi, i, gases);
|
||||
|
@ -907,7 +907,7 @@ static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc
|
|||
|
||||
#ifndef SUBSURFACE_MOBILE
|
||||
/* calculate DECO STOP / TTS / NDL */
|
||||
static void calculate_ndl_tts(struct deco_state *ds, struct dive *dive, struct plot_data *entry, struct gasmix *gasmix, double surface_pressure,enum divemode_t divemode)
|
||||
static void calculate_ndl_tts(struct deco_state *ds, struct dive *dive, struct plot_data *entry, struct gasmix gasmix, double surface_pressure,enum divemode_t divemode)
|
||||
{
|
||||
/* FIXME: This should be configurable */
|
||||
/* ascent speed up to first deco stop */
|
||||
|
@ -1026,7 +1026,7 @@ void calculate_deco_information(struct deco_state *ds, struct deco_state *planne
|
|||
int time_stepsize = 20;
|
||||
|
||||
current_divemode = get_current_divemode(dc, entry->sec, &evd, ¤t_divemode);
|
||||
gasmix = get_gasmix(dive, dc, t1, &ev, &gasmix);
|
||||
gasmix = get_gasmix(dive, dc, t1, &ev, gasmix);
|
||||
entry->ambpressure = depth_to_bar(entry->depth, dive);
|
||||
entry->gfline = get_gf(ds, entry->ambpressure, dive) * (100.0 - AMB_PERCENTAGE) + AMB_PERCENTAGE;
|
||||
if (t0 > t1) {
|
||||
|
@ -1040,7 +1040,7 @@ void calculate_deco_information(struct deco_state *ds, struct deco_state *planne
|
|||
for (j = t0 + time_stepsize; j <= t1; j += time_stepsize) {
|
||||
int depth = interpolate(entry[-1].depth, entry[0].depth, j - t0, t1 - t0);
|
||||
add_segment(ds, depth_to_bar(depth, dive),
|
||||
&gasmix, time_stepsize, entry->o2pressure.mbar, current_divemode, entry->sac);
|
||||
gasmix, time_stepsize, entry->o2pressure.mbar, current_divemode, entry->sac);
|
||||
entry->icd_warning = ds->icd_warning;
|
||||
if ((t1 - j < time_stepsize) && (j < t1))
|
||||
time_stepsize = t1 - j;
|
||||
|
@ -1115,7 +1115,7 @@ void calculate_deco_information(struct deco_state *ds, struct deco_state *planne
|
|||
/* We are going to mess up deco state, so store it for later restore */
|
||||
struct deco_state *cache_data = NULL;
|
||||
cache_deco_state(ds, &cache_data);
|
||||
calculate_ndl_tts(ds, dive, entry, &gasmix, surface_pressure, current_divemode);
|
||||
calculate_ndl_tts(ds, dive, entry, gasmix, surface_pressure, current_divemode);
|
||||
if (decoMode() == VPMB && !in_planner() && i == pi->nr - 1)
|
||||
final_tts = entry->tts_calc;
|
||||
/* Restore "real" deco state for next real time step */
|
||||
|
@ -1213,15 +1213,15 @@ static void calculate_gas_information_new(struct dive *dive, struct divecomputer
|
|||
int fn2, fhe;
|
||||
struct plot_data *entry = pi->entry + i;
|
||||
|
||||
gasmix = get_gasmix(dive, dc, entry->sec, &evg, &gasmix);
|
||||
gasmix = get_gasmix(dive, dc, entry->sec, &evg, gasmix);
|
||||
amb_pressure = depth_to_bar(entry->depth, dive);
|
||||
current_divemode = get_current_divemode(dc, entry->sec, &evd, ¤t_divemode);
|
||||
fill_pressures(&entry->pressures, amb_pressure, &gasmix, (current_divemode == OC) ? 0.0 : entry->o2pressure.mbar / 1000.0, current_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.
|
||||
struct gasmix gasmix2 = get_gasmix(dive, dc, entry->sec, &evg, &gasmix);
|
||||
entry->scr_OC_pO2.mbar = (int) depth_to_mbar(entry->depth, dive) * get_o2(&gasmix2) / 1000;
|
||||
struct gasmix gasmix2 = get_gasmix(dive, dc, entry->sec, &evg, gasmix);
|
||||
entry->scr_OC_pO2.mbar = (int) depth_to_mbar(entry->depth, dive) * get_o2(gasmix2) / 1000;
|
||||
}
|
||||
|
||||
/* Calculate MOD, EAD, END and EADD based on partial pressures calculated before
|
||||
|
@ -1229,7 +1229,7 @@ static void calculate_gas_information_new(struct dive *dive, struct divecomputer
|
|||
* END takes O₂ + N₂ (air) into account ("Narcotic" for trimix dives)
|
||||
* EAD just uses N₂ ("Air" for nitrox dives) */
|
||||
pressure_t modpO2 = { .mbar = (int)(prefs.modpO2 * 1000) };
|
||||
entry->mod = (double)gas_mod(&gasmix, modpO2, dive, 1).mm;
|
||||
entry->mod = (double)gas_mod(gasmix, modpO2, dive, 1).mm;
|
||||
entry->end = (entry->depth + 10000) * (1000 - fhe) / 1000.0 - 10000;
|
||||
entry->ead = (entry->depth + 10000) * fn2 / (double)N2_IN_AIR - 10000;
|
||||
entry->eadd = (entry->depth + 10000) *
|
||||
|
@ -1237,7 +1237,7 @@ static void calculate_gas_information_new(struct dive *dive, struct divecomputer
|
|||
entry->pressures.n2 / amb_pressure * N2_DENSITY +
|
||||
entry->pressures.he / amb_pressure * HE_DENSITY) /
|
||||
(O2_IN_AIR * O2_DENSITY + N2_IN_AIR * N2_DENSITY) * 1000 - 10000;
|
||||
entry->density = gas_density(&gasmix, depth_to_mbar(entry->depth, dive));
|
||||
entry->density = gas_density(gasmix, depth_to_mbar(entry->depth, dive));
|
||||
if (entry->mod < 0)
|
||||
entry->mod = 0;
|
||||
if (entry->ead < 0)
|
||||
|
@ -1387,11 +1387,10 @@ static void plot_string(struct plot_info *pi, struct plot_data *entry, struct me
|
|||
depthvalue = get_depth_units(entry->depth, NULL, &depth_unit);
|
||||
put_format_loc(b, translate("gettextFromC", "@: %d:%02d\nD: %.1f%s\n"), FRACTION(entry->sec, 60), depthvalue, depth_unit);
|
||||
for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) {
|
||||
struct gasmix *mix;
|
||||
int mbar = GET_PRESSURE(entry, cyl);
|
||||
if (!mbar)
|
||||
continue;
|
||||
mix = &displayed_dive.cylinder[cyl].gasmix;
|
||||
struct gasmix mix = displayed_dive.cylinder[cyl].gasmix;
|
||||
pressurevalue = get_pressure_units(mbar, &pressure_unit);
|
||||
put_format_loc(b, translate("gettextFromC", "P: %d%s (%s)\n"), pressurevalue, pressure_unit, gasname(mix));
|
||||
}
|
||||
|
|
|
@ -400,7 +400,7 @@ void selectedDivesGasUsed(QVector<QPair<QString, int> > &gasUsedOrdered)
|
|||
get_gas_used(d, diveGases);
|
||||
for (j = 0; j < MAX_CYLINDERS; j++)
|
||||
if (diveGases[j].mliter) {
|
||||
QString gasName = gasname(&d->cylinder[j].gasmix);
|
||||
QString gasName = gasname(d->cylinder[j].gasmix);
|
||||
gasUsed[gasName] += diveGases[j].mliter;
|
||||
}
|
||||
}
|
||||
|
@ -1228,8 +1228,8 @@ extern "C" char *picturedir_string()
|
|||
|
||||
QString get_gas_string(struct gasmix gas)
|
||||
{
|
||||
uint o2 = (get_o2(&gas) + 5) / 10, he = (get_he(&gas) + 5) / 10;
|
||||
QString result = gasmix_is_air(&gas) ? gettextFromC::tr("AIR") : he == 0 ? (o2 == 100 ? gettextFromC::tr("OXYGEN") : QString("EAN%1").arg(o2, 2, 10, QChar('0'))) : QString("%1/%2").arg(o2).arg(he);
|
||||
uint o2 = (get_o2(gas) + 5) / 10, he = (get_he(gas) + 5) / 10;
|
||||
QString result = gasmix_is_air(gas) ? gettextFromC::tr("AIR") : he == 0 ? (o2 == 100 ? gettextFromC::tr("OXYGEN") : QString("EAN%1").arg(o2, 2, 10, QChar('0'))) : QString("%1/%2").arg(o2).arg(he);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -126,10 +126,10 @@ static void save_extra_data(struct membuffer *b, struct extra_data *ed)
|
|||
}
|
||||
}
|
||||
|
||||
static void put_gasmix(struct membuffer *b, struct gasmix *mix)
|
||||
static void put_gasmix(struct membuffer *b, struct gasmix mix)
|
||||
{
|
||||
int o2 = mix->o2.permille;
|
||||
int he = mix->he.permille;
|
||||
int o2 = mix.o2.permille;
|
||||
int he = mix.he.permille;
|
||||
|
||||
if (o2) {
|
||||
put_format(b, " o2=%u.%u%%", FRACTION(o2, 10));
|
||||
|
@ -154,7 +154,7 @@ static void save_cylinder_info(struct membuffer *b, struct dive *dive)
|
|||
put_pressure(b, cylinder->type.workingpressure, " workpressure=", "bar");
|
||||
show_utf8(b, " description=", description, "");
|
||||
strip_mb(b);
|
||||
put_gasmix(b, &cylinder->gasmix);
|
||||
put_gasmix(b, cylinder->gasmix);
|
||||
put_pressure(b, cylinder->start, " start=", "bar");
|
||||
put_pressure(b, cylinder->end, " end=", "bar");
|
||||
if (cylinder->cylinder_use != OC_GAS)
|
||||
|
@ -385,7 +385,7 @@ static void save_one_event(struct membuffer *b, struct dive *dive, struct event
|
|||
struct gasmix mix = get_gasmix_from_event(dive, ev);
|
||||
if (ev->gas.index >= 0)
|
||||
show_integer(b, ev->gas.index, "cylinder=", "");
|
||||
put_gasmix(b, &mix);
|
||||
put_gasmix(b, mix);
|
||||
}
|
||||
put_string(b, "\n");
|
||||
}
|
||||
|
|
|
@ -127,10 +127,10 @@ static void save_overview(struct membuffer *b, struct dive *dive)
|
|||
show_utf8(b, dive->suit, " <suit>", "</suit>\n", 0);
|
||||
}
|
||||
|
||||
static void put_gasmix(struct membuffer *b, struct gasmix *mix)
|
||||
static void put_gasmix(struct membuffer *b, struct gasmix mix)
|
||||
{
|
||||
int o2 = mix->o2.permille;
|
||||
int he = mix->he.permille;
|
||||
int o2 = mix.o2.permille;
|
||||
int he = mix.he.permille;
|
||||
|
||||
if (o2) {
|
||||
put_format(b, " o2='%u.%u%%'", FRACTION(o2, 10));
|
||||
|
@ -155,7 +155,7 @@ static void save_cylinder_info(struct membuffer *b, struct dive *dive)
|
|||
put_milli(b, " size='", volume, " l'");
|
||||
put_pressure(b, cylinder->type.workingpressure, " workpressure='", " bar'");
|
||||
show_utf8(b, description, " description='", "'", 1);
|
||||
put_gasmix(b, &cylinder->gasmix);
|
||||
put_gasmix(b, cylinder->gasmix);
|
||||
put_pressure(b, cylinder->start, " start='", " bar'");
|
||||
put_pressure(b, cylinder->end, " end='", " bar'");
|
||||
if (cylinder->cylinder_use != OC_GAS)
|
||||
|
@ -310,7 +310,7 @@ static void save_one_event(struct membuffer *b, struct dive *dive, struct event
|
|||
struct gasmix mix = get_gasmix_from_event(dive, ev);
|
||||
if (ev->gas.index >= 0)
|
||||
show_integer(b, ev->gas.index, "cylinder='", "'");
|
||||
put_gasmix(b, &mix);
|
||||
put_gasmix(b, mix);
|
||||
}
|
||||
put_format(b, " />\n");
|
||||
}
|
||||
|
|
|
@ -309,14 +309,14 @@ static void get_gas_parts(struct gasmix mix, volume_t vol, int o2_in_topup, volu
|
|||
{
|
||||
volume_t air = {};
|
||||
|
||||
if (gasmix_is_air(&mix)) {
|
||||
if (gasmix_is_air(mix)) {
|
||||
o2->mliter = 0;
|
||||
he->mliter = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
air.mliter = lrint(((double)vol.mliter * (1000 - get_he(&mix) - get_o2(&mix))) / (1000 - o2_in_topup));
|
||||
he->mliter = lrint(((double)vol.mliter * get_he(&mix)) / 1000.0);
|
||||
air.mliter = lrint(((double)vol.mliter * (1000 - get_he(mix) - get_o2(mix))) / (1000 - o2_in_topup));
|
||||
he->mliter = lrint(((double)vol.mliter * get_he(mix)) / 1000.0);
|
||||
o2->mliter += vol.mliter - he->mliter - air.mliter;
|
||||
}
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ QString DiveObjectHelper::gas() const
|
|||
gas = m_dive->cylinder[i].type.description;
|
||||
if (!gas.isEmpty())
|
||||
gas += QChar(' ');
|
||||
gas += gasname(&m_dive->cylinder[i].gasmix);
|
||||
gas += gasname(m_dive->cylinder[i].gasmix);
|
||||
// if has a description and if such gas is not already present
|
||||
if (!gas.isEmpty() && gases.indexOf(gas) == -1) {
|
||||
if (!gases.isEmpty())
|
||||
|
|
|
@ -351,10 +351,10 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o
|
|||
|
||||
if (is_cylinder_used(dive, i) || (prefs.display_unused_tanks && dive->cylinder[i].type.description)){
|
||||
put_format(&buf, "\\def\\cyl%cdescription{%s}\n", 'a' + i, dive->cylinder[i].type.description);
|
||||
put_format(&buf, "\\def\\cyl%cgasname{%s}\n", 'a' + i, gasname(&dive->cylinder[i].gasmix));
|
||||
put_format(&buf, "\\def\\cyl%cmixO2{%.1f\\%%}\n", 'a' + i, get_o2(&dive->cylinder[i].gasmix)/10.0);
|
||||
put_format(&buf, "\\def\\cyl%cmixHe{%.1f\\%%}\n", 'a' + i, get_he(&dive->cylinder[i].gasmix)/10.0);
|
||||
put_format(&buf, "\\def\\cyl%cmixN2{%.1f\\%%}\n", 'a' + i, (100.0 - (get_o2(&dive->cylinder[i].gasmix)/10.0) - (get_he(&dive->cylinder[i].gasmix)/10.0)));
|
||||
put_format(&buf, "\\def\\cyl%cgasname{%s}\n", 'a' + i, gasname(dive->cylinder[i].gasmix));
|
||||
put_format(&buf, "\\def\\cyl%cmixO2{%.1f\\%%}\n", 'a' + i, get_o2(dive->cylinder[i].gasmix)/10.0);
|
||||
put_format(&buf, "\\def\\cyl%cmixHe{%.1f\\%%}\n", 'a' + i, get_he(dive->cylinder[i].gasmix)/10.0);
|
||||
put_format(&buf, "\\def\\cyl%cmixN2{%.1f\\%%}\n", 'a' + i, (100.0 - (get_o2(dive->cylinder[i].gasmix)/10.0) - (get_he(dive->cylinder[i].gasmix)/10.0)));
|
||||
delta_p.mbar += dive->cylinder[i].start.mbar - dive->cylinder[i].end.mbar;
|
||||
put_format(&buf, "\\def\\cyl%cstartpress{%.1f\\pressureunit}\n", 'a' + i, get_pressure_units(dive->cylinder[i].start.mbar, &unit)/1.0);
|
||||
put_format(&buf, "\\def\\cyl%cendpress{%.1f\\pressureunit}\n", 'a' + i, get_pressure_units(dive->cylinder[i].end.mbar, &unit)/1.0);
|
||||
|
|
|
@ -62,7 +62,7 @@ void TabDiveInformation::updateData()
|
|||
gaslist.append(separator); volumes.append(separator); SACs.append(separator);
|
||||
separator = "\n";
|
||||
|
||||
gaslist.append(gasname(&displayed_dive.cylinder[i].gasmix));
|
||||
gaslist.append(gasname(displayed_dive.cylinder[i].gasmix));
|
||||
if (!gases[i].mliter)
|
||||
continue;
|
||||
volumes.append(get_volume_string(gases[i], true));
|
||||
|
|
|
@ -51,7 +51,7 @@ struct event *DiveEventItem::getEvent()
|
|||
return internalEvent;
|
||||
}
|
||||
|
||||
void DiveEventItem::setEvent(struct event *ev, struct gasmix *lastgasmix)
|
||||
void DiveEventItem::setEvent(struct event *ev, struct gasmix lastgasmix)
|
||||
{
|
||||
if (!ev)
|
||||
return;
|
||||
|
@ -63,7 +63,7 @@ void DiveEventItem::setEvent(struct event *ev, struct gasmix *lastgasmix)
|
|||
recalculatePos(true);
|
||||
}
|
||||
|
||||
void DiveEventItem::setupPixmap(struct gasmix *lastgasmix)
|
||||
void DiveEventItem::setupPixmap(struct gasmix lastgasmix)
|
||||
{
|
||||
const IconMetrics& metrics = defaultIconMetrics();
|
||||
#ifndef SUBSURFACE_MOBILE
|
||||
|
@ -94,13 +94,13 @@ void DiveEventItem::setupPixmap(struct gasmix *lastgasmix)
|
|||
} else if (event_is_gaschange(internalEvent)) {
|
||||
struct gasmix mix = get_gasmix_from_event(&displayed_dive, internalEvent);
|
||||
struct icd_data icd_data;
|
||||
bool icd = isobaric_counterdiffusion(lastgasmix, &mix, &icd_data);
|
||||
bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data);
|
||||
if (mix.he.permille) {
|
||||
if (icd)
|
||||
setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-trimix-ICD-icon"));
|
||||
else
|
||||
setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-trimix-icon"));
|
||||
} else if (gasmix_is_air(&mix)) {
|
||||
} else if (gasmix_is_air(mix)) {
|
||||
if (icd)
|
||||
setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-air-ICD-icon"));
|
||||
else
|
||||
|
@ -165,7 +165,7 @@ void DiveEventItem::setupPixmap(struct gasmix *lastgasmix)
|
|||
#undef EVENT_PIXMAP_BIGGER
|
||||
}
|
||||
|
||||
void DiveEventItem::setupToolTipString(struct gasmix *lastgasmix)
|
||||
void DiveEventItem::setupToolTipString(struct gasmix lastgasmix)
|
||||
{
|
||||
// we display the event on screen - so translate
|
||||
QString name = gettextFromC::tr(internalEvent->name);
|
||||
|
@ -177,12 +177,12 @@ void DiveEventItem::setupToolTipString(struct gasmix *lastgasmix)
|
|||
struct gasmix mix = get_gasmix_from_event(&displayed_dive, internalEvent);
|
||||
struct membuffer mb = {};
|
||||
name += ": ";
|
||||
name += gasname(&mix);
|
||||
name += gasname(mix);
|
||||
|
||||
/* Do we have an explicit cylinder index? Show it. */
|
||||
if (internalEvent->gas.index >= 0)
|
||||
name += tr(" (cyl. %1)").arg(internalEvent->gas.index + 1);
|
||||
bool icd = isobaric_counterdiffusion(lastgasmix, &mix, &icd_data);
|
||||
bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data);
|
||||
if (icd_data.dHe < 0) {
|
||||
put_format(&mb, "\n%s %s:%+.3g%% %s:%+.3g%%%s%+.3g%%",
|
||||
qPrintable(tr("ICD")),
|
||||
|
@ -192,7 +192,7 @@ void DiveEventItem::setupToolTipString(struct gasmix *lastgasmix)
|
|||
name += QString::fromUtf8(mb.buffer, mb.len);
|
||||
free_buffer(&mb);
|
||||
}
|
||||
*lastgasmix = mix;
|
||||
lastgasmix = mix;
|
||||
} else if (same_string(internalEvent->name, "modechange")) {
|
||||
name += QString(": %1").arg(gettextFromC::tr(divemode_text_ui[internalEvent->value]));
|
||||
} else if (value) {
|
||||
|
|
|
@ -13,7 +13,7 @@ class DiveEventItem : public DivePixmapItem {
|
|||
public:
|
||||
DiveEventItem(QGraphicsItem *parent = 0);
|
||||
~DiveEventItem();
|
||||
void setEvent(struct event *ev, struct gasmix *lastgasmix);
|
||||
void setEvent(struct event *ev, struct gasmix lastgasmix);
|
||||
struct event *getEvent();
|
||||
void eventVisibilityChanged(const QString &eventName, bool visible);
|
||||
void setVerticalAxis(DiveCartesianAxis *axis);
|
||||
|
@ -25,8 +25,8 @@ slots:
|
|||
void recalculatePos(bool instant = false);
|
||||
|
||||
private:
|
||||
void setupToolTipString(struct gasmix *lastgasmix);
|
||||
void setupPixmap(struct gasmix *lastgasmix);
|
||||
void setupToolTipString(struct gasmix lastgasmix);
|
||||
void setupPixmap(struct gasmix lastgasmix);
|
||||
DiveCartesianAxis *vAxis;
|
||||
DiveCartesianAxis *hAxis;
|
||||
DivePlotDataModel *dataModel;
|
||||
|
|
|
@ -413,8 +413,8 @@ void DivePercentageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
|||
struct gasmix gasmix = { 0 };
|
||||
struct event *ev = NULL;
|
||||
int sec = dataModel->index(i, DivePlotDataModel::TIME).data().toInt();
|
||||
gasmix = get_gasmix(&displayed_dive, displayed_dc, sec, &ev, &gasmix);
|
||||
int inert = 1000 - get_o2(&gasmix);
|
||||
gasmix = get_gasmix(&displayed_dive, displayed_dc, sec, &ev, gasmix);
|
||||
int inert = 1000 - get_o2(gasmix);
|
||||
mypen.setBrush(QBrush(ColorScale(value, inert)));
|
||||
painter->setPen(mypen);
|
||||
painter->drawLine(poly[i - 1], poly[i]);
|
||||
|
|
|
@ -781,7 +781,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force, bool doClearPictures)
|
|||
item->setHorizontalAxis(timeAxis);
|
||||
item->setVerticalAxis(profileYAxis);
|
||||
item->setModel(dataModel);
|
||||
item->setEvent(event, &lastgasmix);
|
||||
item->setEvent(event, lastgasmix);
|
||||
item->setZValue(2);
|
||||
scene()->addItem(item);
|
||||
eventItems.push_back(item);
|
||||
|
@ -1710,7 +1710,7 @@ void ProfileWidget2::changeGas()
|
|||
tank = rx.cap(1).toInt() - 1; // we display the tank 1 based
|
||||
} else {
|
||||
qDebug() << "failed to parse tank number";
|
||||
tank = get_gasidx(&displayed_dive, &gasmix);
|
||||
tank = get_gasidx(&displayed_dive, gasmix);
|
||||
}
|
||||
// add this both to the displayed dive and the current dive
|
||||
add_gas_switch_event(current_dive, current_dc, seconds, tank);
|
||||
|
|
|
@ -57,15 +57,15 @@ void TankItem::setData(DivePlotDataModel *model, struct plot_info *plotInfo, str
|
|||
modelDataChanged();
|
||||
}
|
||||
|
||||
void TankItem::createBar(qreal x, qreal w, struct gasmix *gas)
|
||||
void TankItem::createBar(qreal x, qreal w, struct gasmix gas)
|
||||
{
|
||||
// pick the right gradient, size, position and text
|
||||
QGraphicsRectItem *rect = new QGraphicsRectItem(x, 0, w, height, this);
|
||||
if (gasmix_is_air(gas))
|
||||
rect->setBrush(air);
|
||||
else if (gas->he.permille)
|
||||
else if (gas.he.permille)
|
||||
rect->setBrush(trimix);
|
||||
else if (gas->o2.permille == 1000)
|
||||
else if (gas.o2.permille == 1000)
|
||||
rect->setBrush(oxygen);
|
||||
else
|
||||
rect->setBrush(nitrox);
|
||||
|
@ -112,14 +112,14 @@ void TankItem::modelDataChanged(const QModelIndex&, const QModelIndex&)
|
|||
while (ev && (int)ev->time.seconds < last_entry->sec) {
|
||||
width = hAxis->posAtValue(ev->time.seconds) - hAxis->posAtValue(startTime);
|
||||
left = hAxis->posAtValue(startTime);
|
||||
createBar(left, width, &gasmix);
|
||||
createBar(left, width, gasmix);
|
||||
startTime = ev->time.seconds;
|
||||
gasmix = get_gasmix_from_event(&displayed_dive, ev);
|
||||
ev = get_next_event(ev->next, "gaschange");
|
||||
}
|
||||
width = hAxis->posAtValue(last_entry->sec) - hAxis->posAtValue(startTime);
|
||||
left = hAxis->posAtValue(startTime);
|
||||
createBar(left, width, &gasmix);
|
||||
createBar(left, width, gasmix);
|
||||
}
|
||||
|
||||
void TankItem::setHorizontalAxis(DiveCartesianAxis *horizontal)
|
||||
|
|
|
@ -25,7 +25,7 @@ public slots:
|
|||
void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
|
||||
|
||||
private:
|
||||
void createBar(qreal x, qreal w, struct gasmix *gas);
|
||||
void createBar(qreal x, qreal w, struct gasmix gas);
|
||||
DivePlotDataModel *dataModel;
|
||||
DiveCartesianAxis *hAxis;
|
||||
struct dive diveCylinderStore;
|
||||
|
|
|
@ -100,7 +100,7 @@ static QVariant gas_volume_tooltip(cylinder_t *cyl, pressure_t p)
|
|||
if (!vol)
|
||||
return QVariant();
|
||||
|
||||
Z = gas_compressibility_factor(&cyl->gasmix, p.mbar / 1000.0);
|
||||
Z = gas_compressibility_factor(cyl->gasmix, p.mbar / 1000.0);
|
||||
return gas_volume_string(vol, "(Z=") + QString("%1)").arg(Z, 0, 'f', 3);
|
||||
}
|
||||
|
||||
|
@ -212,14 +212,14 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
|
|||
} else {
|
||||
pressure_t modpO2;
|
||||
modpO2.mbar = prefs.bottompo2;
|
||||
ret = get_depth_string(gas_mod(&cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(1,1)), true);
|
||||
ret = get_depth_string(gas_mod(cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(1,1)), true);
|
||||
}
|
||||
break;
|
||||
case MND:
|
||||
if (cyl->bestmix_he)
|
||||
ret = QString("*");
|
||||
else
|
||||
ret = get_depth_string(gas_mnd(&cyl->gasmix, prefs.bestmixend, &displayed_dive, M_OR_FT(1,1)), true);
|
||||
ret = get_depth_string(gas_mnd(cyl->gasmix, prefs.bestmixend, &displayed_dive, M_OR_FT(1,1)), true);
|
||||
break;
|
||||
case USE:
|
||||
ret = gettextFromC::tr(cylinderuse_text[cyl->cylinder_use]);
|
||||
|
@ -353,15 +353,15 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||
if (CHANGED()) {
|
||||
cyl->gasmix.o2 = string_to_fraction(qPrintable(vString));
|
||||
// fO2 + fHe must not be greater than 1
|
||||
if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
|
||||
cyl->gasmix.he.permille = 1000 - get_o2(&cyl->gasmix);
|
||||
if (get_o2(cyl->gasmix) + get_he(cyl->gasmix) > 1000)
|
||||
cyl->gasmix.he.permille = 1000 - get_o2(cyl->gasmix);
|
||||
pressure_t modpO2;
|
||||
if (displayed_dive.dc.divemode == PSCR)
|
||||
modpO2.mbar = prefs.decopo2 + (1000 - get_o2(&cyl->gasmix)) * SURFACE_PRESSURE *
|
||||
modpO2.mbar = prefs.decopo2 + (1000 - get_o2(cyl->gasmix)) * SURFACE_PRESSURE *
|
||||
prefs.o2consumption / prefs.decosac / prefs.pscr_ratio;
|
||||
else
|
||||
modpO2.mbar = prefs.decopo2;
|
||||
cyl->depth = gas_mod(&cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
|
||||
cyl->depth = gas_mod(cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
|
||||
cyl->bestmix_o2 = false;
|
||||
changed = true;
|
||||
}
|
||||
|
@ -370,8 +370,8 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||
if (CHANGED()) {
|
||||
cyl->gasmix.he = string_to_fraction(qPrintable(vString));
|
||||
// fO2 + fHe must not be greater than 1
|
||||
if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
|
||||
cyl->gasmix.o2.permille = 1000 - get_he(&cyl->gasmix);
|
||||
if (get_o2(cyl->gasmix) + get_he(cyl->gasmix) > 1000)
|
||||
cyl->gasmix.o2.permille = 1000 - get_he(cyl->gasmix);
|
||||
cyl->bestmix_he = false;
|
||||
changed = true;
|
||||
}
|
||||
|
@ -395,7 +395,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||
}
|
||||
pressure_t modpO2;
|
||||
modpO2.mbar = prefs.decopo2;
|
||||
cyl->depth = gas_mod(&cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
|
||||
cyl->depth = gas_mod(cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
@ -588,8 +588,8 @@ void CylindersModel::updateDecoDepths(pressure_t olddecopo2)
|
|||
cylinder_t *cyl = &displayed_dive.cylinder[i];
|
||||
/* If the gas's deco MOD matches the old pO2, it will have been automatically calculated and should be updated.
|
||||
* If they don't match, we should leave the user entered depth as it is */
|
||||
if (cyl->depth.mm == gas_mod(&cyl->gasmix, olddecopo2, &displayed_dive, M_OR_FT(3, 10)).mm) {
|
||||
cyl->depth = gas_mod(&cyl->gasmix, decopo2, &displayed_dive, M_OR_FT(3, 10));
|
||||
if (cyl->depth.mm == gas_mod(cyl->gasmix, olddecopo2, &displayed_dive, M_OR_FT(3, 10)).mm) {
|
||||
cyl->depth = gas_mod(cyl->gasmix, decopo2, &displayed_dive, M_OR_FT(3, 10));
|
||||
}
|
||||
}
|
||||
emit dataChanged(createIndex(0, 0), createIndex(MAX_CYLINDERS - 1, COLUMNS - 1));
|
||||
|
@ -609,18 +609,18 @@ bool CylindersModel::updateBestMixes()
|
|||
if (cyl->bestmix_o2) {
|
||||
cyl->gasmix.o2 = best_o2(displayed_dive.maxdepth, &displayed_dive);
|
||||
// fO2 + fHe must not be greater than 1
|
||||
if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
|
||||
cyl->gasmix.he.permille = 1000 - get_o2(&cyl->gasmix);
|
||||
if (get_o2(cyl->gasmix) + get_he(cyl->gasmix) > 1000)
|
||||
cyl->gasmix.he.permille = 1000 - get_o2(cyl->gasmix);
|
||||
pressure_t modpO2;
|
||||
modpO2.mbar = prefs.decopo2;
|
||||
cyl->depth = gas_mod(&cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
|
||||
cyl->depth = gas_mod(cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
|
||||
gasUpdated = true;
|
||||
}
|
||||
if (cyl->bestmix_he) {
|
||||
cyl->gasmix.he = best_he(displayed_dive.maxdepth, &displayed_dive);
|
||||
// fO2 + fHe must not be greater than 1
|
||||
if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
|
||||
cyl->gasmix.o2.permille = 1000 - get_he(&cyl->gasmix);
|
||||
if (get_o2(cyl->gasmix) + get_he(cyl->gasmix) > 1000)
|
||||
cyl->gasmix.o2.permille = 1000 - get_he(cyl->gasmix);
|
||||
gasUpdated = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -506,16 +506,16 @@ static void merge_cylinder_type(cylinder_type_t *src, cylinder_type_t *dst)
|
|||
}
|
||||
}
|
||||
|
||||
static void merge_cylinder_mix(struct gasmix *src, struct gasmix *dst)
|
||||
static void merge_cylinder_mix(struct gasmix src, struct gasmix *dst)
|
||||
{
|
||||
if (!dst->o2.permille)
|
||||
*dst = *src;
|
||||
*dst = src;
|
||||
}
|
||||
|
||||
static void merge_cylinder_info(cylinder_t *src, cylinder_t *dst)
|
||||
{
|
||||
merge_cylinder_type(&src->type, &dst->type);
|
||||
merge_cylinder_mix(&src->gasmix, &dst->gasmix);
|
||||
merge_cylinder_mix(src->gasmix, &dst->gasmix);
|
||||
MERGE_MAX(dst, dst, src, start.mbar);
|
||||
MERGE_MIN(dst, dst, src, end.mbar);
|
||||
if (!dst->cylinder_use)
|
||||
|
|
|
@ -58,8 +58,8 @@ void setupPlan(struct diveplan *dp)
|
|||
free_dps(dp);
|
||||
|
||||
int droptime = M_OR_FT(79, 260) * 60 / M_OR_FT(23, 75);
|
||||
plan_add_segment(dp, 0, gas_mod(&ean36, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(ean36, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
||||
plan_add_segment(dp, droptime, M_OR_FT(79, 260), 0, 0, 1, OC);
|
||||
plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(79, 260), 0, 0, 1, OC);
|
||||
}
|
||||
|
@ -86,8 +86,8 @@ void setupPlanVpmb45m30mTx(struct diveplan *dp)
|
|||
free_dps(dp);
|
||||
|
||||
int droptime = M_OR_FT(45, 150) * 60 / M_OR_FT(23, 75);
|
||||
plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
||||
plan_add_segment(dp, droptime, M_OR_FT(45, 150), 0, 0, 1, OC);
|
||||
plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(45, 150), 0, 0, 1, OC);
|
||||
}
|
||||
|
@ -114,8 +114,8 @@ void setupPlanVpmb60m10mTx(struct diveplan *dp)
|
|||
free_dps(dp);
|
||||
|
||||
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(23, 75);
|
||||
plan_add_segment(dp, 0, gas_mod(&tx50_15, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(tx50_15, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
||||
plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
|
||||
plan_add_segment(dp, 10 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ void setupPlanVpmb60m30minEan50(struct diveplan *dp)
|
|||
free_dps(dp);
|
||||
|
||||
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
|
||||
plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
|
||||
plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ void setupPlanVpmb60m30minTx(struct diveplan *dp)
|
|||
free_dps(dp);
|
||||
|
||||
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
|
||||
plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
|
||||
plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
|
||||
}
|
||||
|
@ -231,8 +231,8 @@ void setupPlanVpmb100m60min(struct diveplan *dp)
|
|||
free_dps(dp);
|
||||
|
||||
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330);
|
||||
plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
||||
plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
|
||||
plan_add_segment(dp, 60 * 60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
|
||||
}
|
||||
|
@ -258,8 +258,8 @@ void setupPlanVpmb100m10min(struct diveplan *dp)
|
|||
free_dps(dp);
|
||||
|
||||
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330);
|
||||
plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
||||
plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
|
||||
plan_add_segment(dp, 10 * 60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
|
||||
}
|
||||
|
@ -307,9 +307,9 @@ void setupPlanVpmb100mTo70m30min(struct diveplan *dp)
|
|||
free_dps(dp);
|
||||
|
||||
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(18, 60);
|
||||
plan_add_segment(dp, 0, gas_mod(&tx21_35, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 3, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(tx21_35, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
||||
plan_add_segment(dp, 0, gas_mod(oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 3, 0, 1, OC);
|
||||
plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
|
||||
plan_add_segment(dp, 20 * 60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
|
||||
plan_add_segment(dp, 3 * 60, M_OR_FT(70, 230), 0, 0, 1, OC);
|
||||
|
|
Loading…
Reference in a new issue