2017-04-27 18:21:27 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-07-04 16:12:54 +00:00
|
|
|
#include "testplan.h"
|
2019-08-05 18:43:06 +00:00
|
|
|
#include "core/deco.h"
|
2018-07-25 19:39:04 +00:00
|
|
|
#include "core/dive.h"
|
2020-10-25 08:14:16 +00:00
|
|
|
#include "core/event.h"
|
2024-03-26 13:05:35 +00:00
|
|
|
#include "core/errorhelper.h"
|
2016-04-05 17:22:00 +00:00
|
|
|
#include "core/planner.h"
|
|
|
|
#include "core/qthelper.h"
|
2018-07-25 19:39:04 +00:00
|
|
|
#include "core/subsurfacestartup.h"
|
|
|
|
#include "core/units.h"
|
2015-07-04 16:12:54 +00:00
|
|
|
|
2018-07-25 19:39:04 +00:00
|
|
|
#define DEBUG 1
|
2015-07-06 13:44:05 +00:00
|
|
|
|
2015-07-04 16:12:54 +00:00
|
|
|
// testing the dive plan algorithm
|
2024-05-16 18:11:21 +00:00
|
|
|
static struct dive dive;
|
2022-11-05 19:27:49 +00:00
|
|
|
static struct deco_state test_deco_state;
|
2015-07-04 16:12:54 +00:00
|
|
|
void setupPrefs()
|
|
|
|
{
|
2024-06-13 20:59:32 +00:00
|
|
|
prefs = default_prefs;
|
2015-07-04 16:12:54 +00:00
|
|
|
prefs.ascrate50 = feet_to_mm(30) / 60;
|
|
|
|
prefs.ascrate75 = prefs.ascrate50;
|
|
|
|
prefs.ascratestops = prefs.ascrate50;
|
|
|
|
prefs.ascratelast6m = feet_to_mm(10) / 60;
|
|
|
|
prefs.last_stop = true;
|
|
|
|
}
|
|
|
|
|
2015-08-23 14:08:04 +00:00
|
|
|
void setupPrefsVpmb()
|
|
|
|
{
|
2024-06-13 20:59:32 +00:00
|
|
|
prefs = default_prefs;
|
2015-08-23 14:08:04 +00:00
|
|
|
prefs.ascrate50 = 10000 / 60;
|
|
|
|
prefs.ascrate75 = prefs.ascrate50;
|
|
|
|
prefs.ascratestops = prefs.ascrate50;
|
|
|
|
prefs.ascratelast6m = prefs.ascrate50;
|
|
|
|
prefs.descrate = 99000 / 60;
|
|
|
|
prefs.last_stop = false;
|
2017-01-07 02:11:19 +00:00
|
|
|
prefs.planner_deco_mode = VPMB;
|
2016-09-24 08:02:07 +00:00
|
|
|
prefs.vpmb_conservatism = 0;
|
2015-08-23 14:08:04 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan setupPlan()
|
2015-07-04 16:12:54 +00:00
|
|
|
{
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan dp;
|
|
|
|
dp.salinity = 10300;
|
2024-09-09 11:55:37 +00:00
|
|
|
dp.surface_pressure = 1_atm;
|
2024-09-04 05:36:05 +00:00
|
|
|
dp.gfhigh = 100;
|
|
|
|
dp.gflow = 100;
|
|
|
|
dp.bottomsac = prefs.bottomsac;
|
|
|
|
dp.decosac = prefs.decosac;
|
2015-07-04 16:12:54 +00:00
|
|
|
|
2024-09-03 15:04:48 +00:00
|
|
|
struct gasmix bottomgas = { 15_percent, 45_percent};
|
|
|
|
struct gasmix ean36 = { 36_percent, 0_percent};
|
|
|
|
struct gasmix oxygen = { 100_percent, 0_percent};
|
|
|
|
pressure_t po2 = 1600_mbar;;
|
test: fix subtle bug in testplan.cpp
testplan.cpp had a subtle bug since converting from a fixed-size
cylinder table to a dynamic cylinder table.
As noted in equipment.h, pointers to cylinders are *not* stable
when the cylinder table grows. Therefore, a construct such as
cylinder_t *cyl0 = get_or_create_cylinder(&dive, 0);
cylinder_t *cyl1 = get_or_create_cylinder(&dive, 1);
cylinder_t *cyl2 = get_or_create_cylinder(&dive, 2);
can give dangling cyl0 and cyl1 pointers. This was not an issue
with the old table code, since it had a rather liberal allocation
pattern. However, when switching to std::vector<>, the problem
becomes active.
To "fix" this, simply access the highest index first. Of course,
this should never be done in real code! Therefore, add a
comment at each instance.
Quickly checked all other get_or_create_cylinder() calls and
they seemed to be safe.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-05-31 16:51:03 +00:00
|
|
|
// Note: we add the highest-index cylinder first, because
|
|
|
|
// pointers to cylinders are not stable when reallocating.
|
|
|
|
// For testing OK - don't do this in actual code!
|
2024-06-30 20:39:52 +00:00
|
|
|
cylinder_t *cyl2 = dive.get_or_create_cylinder(2);
|
|
|
|
cylinder_t *cyl0 = dive.get_or_create_cylinder(0);
|
|
|
|
cylinder_t *cyl1 = dive.get_or_create_cylinder(1);
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl0->gasmix = bottomgas;
|
2024-09-03 15:04:48 +00:00
|
|
|
cyl0->type.size = 36_l;
|
|
|
|
cyl0->type.workingpressure = 232_bar;
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl1->gasmix = ean36;
|
|
|
|
cyl2->gasmix = oxygen;
|
2022-11-05 19:27:49 +00:00
|
|
|
reset_cylinders(&dive, true);
|
2015-07-04 16:12:54 +00:00
|
|
|
|
|
|
|
int droptime = M_OR_FT(79, 260) * 60 / M_OR_FT(23, 75);
|
2024-06-30 14:17:20 +00:00
|
|
|
plan_add_segment(dp, 0, dive.gas_mod(ean36, po2, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
|
|
|
plan_add_segment(dp, 0, dive.gas_mod(oxygen, po2, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
2018-03-28 20:50:28 +00:00
|
|
|
plan_add_segment(dp, droptime, M_OR_FT(79, 260), 0, 0, 1, OC);
|
2018-07-25 19:39:04 +00:00
|
|
|
plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(79, 260), 0, 0, 1, OC);
|
2024-09-04 05:36:05 +00:00
|
|
|
return dp;
|
2015-07-04 16:12:54 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan setupPlanVpmb45m30mTx()
|
2017-03-15 21:28:36 +00:00
|
|
|
{
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan dp;
|
|
|
|
dp.salinity = 10300;
|
2024-09-09 11:55:37 +00:00
|
|
|
dp.surface_pressure = 1_atm;
|
2024-09-04 05:36:05 +00:00
|
|
|
dp.gfhigh = 100;
|
|
|
|
dp.gflow = 100;
|
|
|
|
dp.bottomsac = prefs.bottomsac;
|
|
|
|
dp.decosac = prefs.decosac;
|
2017-03-15 21:28:36 +00:00
|
|
|
|
2024-09-03 15:04:48 +00:00
|
|
|
struct gasmix bottomgas = { 21_percent, 35_percent};
|
|
|
|
struct gasmix ean50 = { 50_percent, 0_percent};
|
|
|
|
struct gasmix oxygen = { 100_percent, 0_percent};
|
|
|
|
pressure_t po2 = 1600_mbar;
|
test: fix subtle bug in testplan.cpp
testplan.cpp had a subtle bug since converting from a fixed-size
cylinder table to a dynamic cylinder table.
As noted in equipment.h, pointers to cylinders are *not* stable
when the cylinder table grows. Therefore, a construct such as
cylinder_t *cyl0 = get_or_create_cylinder(&dive, 0);
cylinder_t *cyl1 = get_or_create_cylinder(&dive, 1);
cylinder_t *cyl2 = get_or_create_cylinder(&dive, 2);
can give dangling cyl0 and cyl1 pointers. This was not an issue
with the old table code, since it had a rather liberal allocation
pattern. However, when switching to std::vector<>, the problem
becomes active.
To "fix" this, simply access the highest index first. Of course,
this should never be done in real code! Therefore, add a
comment at each instance.
Quickly checked all other get_or_create_cylinder() calls and
they seemed to be safe.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-05-31 16:51:03 +00:00
|
|
|
// Note: we add the highest-index cylinder first, because
|
|
|
|
// pointers to cylinders are not stable when reallocating.
|
|
|
|
// For testing OK - don't do this in actual code!
|
2024-06-30 20:39:52 +00:00
|
|
|
cylinder_t *cyl2 = dive.get_or_create_cylinder(2);
|
|
|
|
cylinder_t *cyl0 = dive.get_or_create_cylinder(0);
|
|
|
|
cylinder_t *cyl1 = dive.get_or_create_cylinder(1);
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl0->gasmix = bottomgas;
|
2024-09-03 15:04:48 +00:00
|
|
|
cyl0->type.size = 24_l;
|
|
|
|
cyl0->type.workingpressure = 232_bar;
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl1->gasmix = ean50;
|
|
|
|
cyl2->gasmix = oxygen;
|
2022-11-05 19:27:49 +00:00
|
|
|
reset_cylinders(&dive, true);
|
2017-03-15 21:28:36 +00:00
|
|
|
|
|
|
|
int droptime = M_OR_FT(45, 150) * 60 / M_OR_FT(23, 75);
|
2024-06-30 14:17:20 +00:00
|
|
|
plan_add_segment(dp, 0, dive.gas_mod(ean50, po2, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
|
|
|
plan_add_segment(dp, 0, dive.gas_mod(oxygen, po2, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
2018-03-28 20:50:28 +00:00
|
|
|
plan_add_segment(dp, droptime, M_OR_FT(45, 150), 0, 0, 1, OC);
|
2018-07-25 19:39:04 +00:00
|
|
|
plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(45, 150), 0, 0, 1, OC);
|
2024-09-04 05:36:05 +00:00
|
|
|
return dp;
|
2017-03-15 21:28:36 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan setupPlanVpmb60m10mTx()
|
2017-03-15 21:28:36 +00:00
|
|
|
{
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan dp;
|
|
|
|
dp.salinity = 10300;
|
2024-09-09 11:55:37 +00:00
|
|
|
dp.surface_pressure = 1_atm;
|
2024-09-04 05:36:05 +00:00
|
|
|
dp.gfhigh = 100;
|
|
|
|
dp.gflow = 100;
|
|
|
|
dp.bottomsac = prefs.bottomsac;
|
|
|
|
dp.decosac = prefs.decosac;
|
2017-03-15 21:28:36 +00:00
|
|
|
|
2024-09-03 15:04:48 +00:00
|
|
|
struct gasmix bottomgas = { 18_percent, 45_percent };
|
|
|
|
struct gasmix tx50_15 = { 50_percent, 15_percent };
|
|
|
|
struct gasmix oxygen = { 100_percent, 0_percent };
|
|
|
|
pressure_t po2 = 1600_mbar;
|
test: fix subtle bug in testplan.cpp
testplan.cpp had a subtle bug since converting from a fixed-size
cylinder table to a dynamic cylinder table.
As noted in equipment.h, pointers to cylinders are *not* stable
when the cylinder table grows. Therefore, a construct such as
cylinder_t *cyl0 = get_or_create_cylinder(&dive, 0);
cylinder_t *cyl1 = get_or_create_cylinder(&dive, 1);
cylinder_t *cyl2 = get_or_create_cylinder(&dive, 2);
can give dangling cyl0 and cyl1 pointers. This was not an issue
with the old table code, since it had a rather liberal allocation
pattern. However, when switching to std::vector<>, the problem
becomes active.
To "fix" this, simply access the highest index first. Of course,
this should never be done in real code! Therefore, add a
comment at each instance.
Quickly checked all other get_or_create_cylinder() calls and
they seemed to be safe.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-05-31 16:51:03 +00:00
|
|
|
// Note: we add the highest-index cylinder first, because
|
|
|
|
// pointers to cylinders are not stable when reallocating.
|
|
|
|
// For testing OK - don't do this in actual code!
|
2024-06-30 20:39:52 +00:00
|
|
|
cylinder_t *cyl2 = dive.get_or_create_cylinder(2);
|
|
|
|
cylinder_t *cyl0 = dive.get_or_create_cylinder(0);
|
|
|
|
cylinder_t *cyl1 = dive.get_or_create_cylinder(1);
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl0->gasmix = bottomgas;
|
2024-09-03 15:04:48 +00:00
|
|
|
cyl0->type.size = 24_l;
|
|
|
|
cyl0->type.workingpressure = 232_bar;
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl1->gasmix = tx50_15;
|
|
|
|
cyl2->gasmix = oxygen;
|
2022-11-05 19:27:49 +00:00
|
|
|
reset_cylinders(&dive, true);
|
2017-03-15 21:28:36 +00:00
|
|
|
|
|
|
|
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(23, 75);
|
2024-06-30 14:17:20 +00:00
|
|
|
plan_add_segment(dp, 0, dive.gas_mod(tx50_15, po2, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
|
|
|
plan_add_segment(dp, 0, dive.gas_mod(oxygen, po2, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
2018-03-28 20:50:28 +00:00
|
|
|
plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
|
2018-07-25 19:39:04 +00:00
|
|
|
plan_add_segment(dp, 10 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
|
2024-09-04 05:36:05 +00:00
|
|
|
return dp;
|
2017-03-15 21:28:36 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan setupPlanVpmb60m30minAir()
|
2015-08-25 14:33:17 +00:00
|
|
|
{
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan dp;
|
|
|
|
dp.salinity = 10300;
|
2024-09-09 11:55:37 +00:00
|
|
|
dp.surface_pressure = 1_atm;
|
2024-09-04 05:36:05 +00:00
|
|
|
dp.bottomsac = prefs.bottomsac;
|
|
|
|
dp.decosac = prefs.decosac;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
2024-09-03 15:04:48 +00:00
|
|
|
struct gasmix bottomgas = { 21_percent, 0_percent};
|
2024-06-30 20:39:52 +00:00
|
|
|
cylinder_t *cyl0 = dive.get_or_create_cylinder(0);
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl0->gasmix = bottomgas;
|
2024-09-03 15:04:48 +00:00
|
|
|
cyl0->type.size = 100_l;
|
|
|
|
cyl0->type.workingpressure = 232_bar;
|
|
|
|
dive.surface_pressure = 1_atm;
|
2022-11-05 19:27:49 +00:00
|
|
|
reset_cylinders(&dive, true);
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
|
2018-03-28 20:50:28 +00:00
|
|
|
plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
|
2018-07-25 19:39:04 +00:00
|
|
|
plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
|
2024-09-04 05:36:05 +00:00
|
|
|
return dp;
|
2015-08-25 14:33:17 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan setupPlanVpmb60m30minEan50()
|
2015-08-25 14:33:17 +00:00
|
|
|
{
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan dp;
|
|
|
|
dp.salinity = 10300;
|
2024-09-09 11:55:37 +00:00
|
|
|
dp.surface_pressure = 1_atm;
|
2024-09-04 05:36:05 +00:00
|
|
|
dp.bottomsac = prefs.bottomsac;
|
|
|
|
dp.decosac = prefs.decosac;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
2024-09-03 15:04:48 +00:00
|
|
|
struct gasmix bottomgas = { 21_percent, 0_percent };
|
|
|
|
struct gasmix ean50 = { 50_percent, 0_percent };
|
|
|
|
pressure_t po2 = 1600_mbar;
|
test: fix subtle bug in testplan.cpp
testplan.cpp had a subtle bug since converting from a fixed-size
cylinder table to a dynamic cylinder table.
As noted in equipment.h, pointers to cylinders are *not* stable
when the cylinder table grows. Therefore, a construct such as
cylinder_t *cyl0 = get_or_create_cylinder(&dive, 0);
cylinder_t *cyl1 = get_or_create_cylinder(&dive, 1);
cylinder_t *cyl2 = get_or_create_cylinder(&dive, 2);
can give dangling cyl0 and cyl1 pointers. This was not an issue
with the old table code, since it had a rather liberal allocation
pattern. However, when switching to std::vector<>, the problem
becomes active.
To "fix" this, simply access the highest index first. Of course,
this should never be done in real code! Therefore, add a
comment at each instance.
Quickly checked all other get_or_create_cylinder() calls and
they seemed to be safe.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-05-31 16:51:03 +00:00
|
|
|
// Note: we add the highest-index cylinder first, because
|
|
|
|
// pointers to cylinders are not stable when reallocating.
|
|
|
|
// For testing OK - don't do this in actual code!
|
2024-06-30 20:39:52 +00:00
|
|
|
cylinder_t *cyl1 = dive.get_or_create_cylinder(1);
|
|
|
|
cylinder_t *cyl0 = dive.get_or_create_cylinder(0);
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl0->gasmix = bottomgas;
|
2024-09-03 15:04:48 +00:00
|
|
|
cyl0->type.size = 36_l;
|
|
|
|
cyl0->type.workingpressure = 232_bar;
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl1->gasmix = ean50;
|
2024-09-03 15:04:48 +00:00
|
|
|
dive.surface_pressure = 1_atm;
|
2022-11-05 19:27:49 +00:00
|
|
|
reset_cylinders(&dive, true);
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
|
2024-06-30 14:17:20 +00:00
|
|
|
plan_add_segment(dp, 0, dive.gas_mod(ean50, po2, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
2018-03-28 20:50:28 +00:00
|
|
|
plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
|
2018-07-25 19:39:04 +00:00
|
|
|
plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
|
2024-09-04 05:36:05 +00:00
|
|
|
return dp;
|
2015-08-25 14:33:17 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan setupPlanVpmb60m30minTx()
|
2015-08-25 14:33:17 +00:00
|
|
|
{
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan dp;
|
|
|
|
dp.salinity = 10300;
|
2024-09-09 11:55:37 +00:00
|
|
|
dp.surface_pressure = 1_atm;
|
2024-09-04 05:36:05 +00:00
|
|
|
dp.bottomsac = prefs.bottomsac;
|
|
|
|
dp.decosac = prefs.decosac;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
2024-09-03 15:04:48 +00:00
|
|
|
struct gasmix bottomgas = { 18_percent, 45_percent };
|
|
|
|
struct gasmix ean50 = { 50_percent, 0_percent };
|
|
|
|
pressure_t po2 = 1600_mbar;
|
test: fix subtle bug in testplan.cpp
testplan.cpp had a subtle bug since converting from a fixed-size
cylinder table to a dynamic cylinder table.
As noted in equipment.h, pointers to cylinders are *not* stable
when the cylinder table grows. Therefore, a construct such as
cylinder_t *cyl0 = get_or_create_cylinder(&dive, 0);
cylinder_t *cyl1 = get_or_create_cylinder(&dive, 1);
cylinder_t *cyl2 = get_or_create_cylinder(&dive, 2);
can give dangling cyl0 and cyl1 pointers. This was not an issue
with the old table code, since it had a rather liberal allocation
pattern. However, when switching to std::vector<>, the problem
becomes active.
To "fix" this, simply access the highest index first. Of course,
this should never be done in real code! Therefore, add a
comment at each instance.
Quickly checked all other get_or_create_cylinder() calls and
they seemed to be safe.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-05-31 16:51:03 +00:00
|
|
|
// Note: we add the highest-index cylinder first, because
|
|
|
|
// pointers to cylinders are not stable when reallocating.
|
|
|
|
// For testing OK - don't do this in actual code!
|
2024-06-30 20:39:52 +00:00
|
|
|
cylinder_t *cyl1 = dive.get_or_create_cylinder(1);
|
|
|
|
cylinder_t *cyl0 = dive.get_or_create_cylinder(0);
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl0->gasmix = bottomgas;
|
2024-09-03 15:04:48 +00:00
|
|
|
cyl0->type.size = 36_l;
|
|
|
|
cyl0->type.workingpressure = 232_bar;
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl1->gasmix = ean50;
|
2024-09-03 15:04:48 +00:00
|
|
|
dive.surface_pressure = 1_atm;
|
2022-11-05 19:27:49 +00:00
|
|
|
reset_cylinders(&dive, true);
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
|
2024-06-30 14:17:20 +00:00
|
|
|
plan_add_segment(dp, 0, dive.gas_mod(ean50, po2, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
2018-03-28 20:50:28 +00:00
|
|
|
plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
|
2018-07-25 19:39:04 +00:00
|
|
|
plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
|
2024-09-04 05:36:05 +00:00
|
|
|
return dp;
|
2015-08-25 14:33:17 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan setupPlanVpmbMultiLevelAir()
|
2015-08-25 14:33:17 +00:00
|
|
|
{
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan dp;
|
|
|
|
dp.salinity = 10300;
|
2024-09-09 11:55:37 +00:00
|
|
|
dp.surface_pressure = 1_atm;
|
2024-09-04 05:36:05 +00:00
|
|
|
dp.bottomsac = prefs.bottomsac;
|
|
|
|
dp.decosac = prefs.decosac;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
2024-09-03 15:04:48 +00:00
|
|
|
struct gasmix bottomgas = { 21_percent, 0_percent };
|
2024-06-30 20:39:52 +00:00
|
|
|
cylinder_t *cyl0 = dive.get_or_create_cylinder(0);
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl0->gasmix = bottomgas;
|
2024-09-03 15:04:48 +00:00
|
|
|
cyl0->type.size = 200_l;
|
|
|
|
cyl0->type.workingpressure = 232_bar;
|
|
|
|
dive.surface_pressure = 1_atm;
|
2022-11-05 19:27:49 +00:00
|
|
|
reset_cylinders(&dive, true);
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
int droptime = M_OR_FT(20, 66) * 60 / M_OR_FT(99, 330);
|
2018-03-28 20:50:28 +00:00
|
|
|
plan_add_segment(dp, droptime, M_OR_FT(20, 66), 0, 0, 1, OC);
|
2018-07-25 19:39:04 +00:00
|
|
|
plan_add_segment(dp, 10 * 60 - droptime, M_OR_FT(20, 66), 0, 0, 1, OC);
|
|
|
|
plan_add_segment(dp, 1 * 60, M_OR_FT(60, 200), 0, 0, 1, OC);
|
|
|
|
plan_add_segment(dp, 29 * 60, M_OR_FT(60, 200), 0, 0, 1, OC);
|
2024-09-04 05:36:05 +00:00
|
|
|
return dp;
|
2015-08-25 14:33:17 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan setupPlanVpmb100m60min()
|
2015-08-23 14:08:04 +00:00
|
|
|
{
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan dp;
|
|
|
|
dp.salinity = 10300;
|
2024-09-09 11:55:37 +00:00
|
|
|
dp.surface_pressure = 1_atm;
|
2024-09-04 05:36:05 +00:00
|
|
|
dp.bottomsac = prefs.bottomsac;
|
|
|
|
dp.decosac = prefs.decosac;
|
2015-08-23 14:08:04 +00:00
|
|
|
|
2024-09-03 15:04:48 +00:00
|
|
|
struct gasmix bottomgas = { 18_percent, 45_percent };
|
|
|
|
struct gasmix ean50 = { 50_percent, 0_percent };
|
|
|
|
struct gasmix oxygen = { 100_percent, 0_percent };
|
|
|
|
pressure_t po2 = 1600_mbar;
|
test: fix subtle bug in testplan.cpp
testplan.cpp had a subtle bug since converting from a fixed-size
cylinder table to a dynamic cylinder table.
As noted in equipment.h, pointers to cylinders are *not* stable
when the cylinder table grows. Therefore, a construct such as
cylinder_t *cyl0 = get_or_create_cylinder(&dive, 0);
cylinder_t *cyl1 = get_or_create_cylinder(&dive, 1);
cylinder_t *cyl2 = get_or_create_cylinder(&dive, 2);
can give dangling cyl0 and cyl1 pointers. This was not an issue
with the old table code, since it had a rather liberal allocation
pattern. However, when switching to std::vector<>, the problem
becomes active.
To "fix" this, simply access the highest index first. Of course,
this should never be done in real code! Therefore, add a
comment at each instance.
Quickly checked all other get_or_create_cylinder() calls and
they seemed to be safe.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-05-31 16:51:03 +00:00
|
|
|
// Note: we add the highest-index cylinder first, because
|
|
|
|
// pointers to cylinders are not stable when reallocating.
|
|
|
|
// For testing OK - don't do this in actual code!
|
2024-06-30 20:39:52 +00:00
|
|
|
cylinder_t *cyl2 = dive.get_or_create_cylinder(2);
|
|
|
|
cylinder_t *cyl0 = dive.get_or_create_cylinder(0);
|
|
|
|
cylinder_t *cyl1 = dive.get_or_create_cylinder(1);
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl0->gasmix = bottomgas;
|
2024-09-03 15:04:48 +00:00
|
|
|
cyl0->type.size = 200_l;
|
|
|
|
cyl0->type.workingpressure = 232_bar;
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl1->gasmix = ean50;
|
|
|
|
cyl2->gasmix = oxygen;
|
2024-09-03 15:04:48 +00:00
|
|
|
dive.surface_pressure = 1_atm;
|
2022-11-05 19:27:49 +00:00
|
|
|
reset_cylinders(&dive, true);
|
2015-08-23 14:08:04 +00:00
|
|
|
|
|
|
|
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330);
|
2024-06-30 14:17:20 +00:00
|
|
|
plan_add_segment(dp, 0, dive.gas_mod(ean50, po2, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
|
|
|
plan_add_segment(dp, 0, dive.gas_mod(oxygen, po2, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
2018-03-28 20:50:28 +00:00
|
|
|
plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
|
2018-07-25 19:39:04 +00:00
|
|
|
plan_add_segment(dp, 60 * 60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
|
2024-09-04 05:36:05 +00:00
|
|
|
return dp;
|
2015-08-23 14:08:04 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan setupPlanVpmb100m10min()
|
2015-08-24 21:37:20 +00:00
|
|
|
{
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan dp;
|
|
|
|
dp.salinity = 10300;
|
2024-09-09 11:55:37 +00:00
|
|
|
dp.surface_pressure = 1_atm;
|
2024-09-04 05:36:05 +00:00
|
|
|
dp.bottomsac = prefs.bottomsac;
|
|
|
|
dp.decosac = prefs.decosac;
|
2015-08-24 21:37:20 +00:00
|
|
|
|
2024-09-03 15:04:48 +00:00
|
|
|
struct gasmix bottomgas = { 18_percent, 45_percent };
|
|
|
|
struct gasmix ean50 = { 50_percent, 0_percent};
|
|
|
|
struct gasmix oxygen = { 100_percent, 0_percent};
|
|
|
|
pressure_t po2 = 1600_mbar;
|
test: fix subtle bug in testplan.cpp
testplan.cpp had a subtle bug since converting from a fixed-size
cylinder table to a dynamic cylinder table.
As noted in equipment.h, pointers to cylinders are *not* stable
when the cylinder table grows. Therefore, a construct such as
cylinder_t *cyl0 = get_or_create_cylinder(&dive, 0);
cylinder_t *cyl1 = get_or_create_cylinder(&dive, 1);
cylinder_t *cyl2 = get_or_create_cylinder(&dive, 2);
can give dangling cyl0 and cyl1 pointers. This was not an issue
with the old table code, since it had a rather liberal allocation
pattern. However, when switching to std::vector<>, the problem
becomes active.
To "fix" this, simply access the highest index first. Of course,
this should never be done in real code! Therefore, add a
comment at each instance.
Quickly checked all other get_or_create_cylinder() calls and
they seemed to be safe.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-05-31 16:51:03 +00:00
|
|
|
// Note: we add the highest-index cylinder first, because
|
|
|
|
// pointers to cylinders are not stable when reallocating.
|
|
|
|
// For testing OK - don't do this in actual code!
|
2024-06-30 20:39:52 +00:00
|
|
|
cylinder_t *cyl2 = dive.get_or_create_cylinder(2);
|
|
|
|
cylinder_t *cyl0 = dive.get_or_create_cylinder(0);
|
|
|
|
cylinder_t *cyl1 = dive.get_or_create_cylinder(1);
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl0->gasmix = bottomgas;
|
2024-09-03 15:04:48 +00:00
|
|
|
cyl0->type.size = 60_l;
|
|
|
|
cyl0->type.workingpressure = 232_bar;
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl1->gasmix = ean50;
|
|
|
|
cyl2->gasmix = oxygen;
|
2024-09-03 15:04:48 +00:00
|
|
|
dive.surface_pressure = 1_atm;
|
2022-11-05 19:27:49 +00:00
|
|
|
reset_cylinders(&dive, true);
|
2015-08-24 21:37:20 +00:00
|
|
|
|
|
|
|
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330);
|
2024-06-30 14:17:20 +00:00
|
|
|
plan_add_segment(dp, 0, dive.gas_mod(ean50, po2, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
|
|
|
plan_add_segment(dp, 0, dive.gas_mod(oxygen, po2, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
2018-03-28 20:50:28 +00:00
|
|
|
plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
|
2018-07-25 19:39:04 +00:00
|
|
|
plan_add_segment(dp, 10 * 60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
|
2024-09-04 05:36:05 +00:00
|
|
|
return dp;
|
2015-08-24 21:37:20 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan setupPlanVpmb30m20min()
|
2015-09-22 14:32:26 +00:00
|
|
|
{
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan dp;
|
|
|
|
dp.salinity = 10300;
|
2024-09-09 11:55:37 +00:00
|
|
|
dp.surface_pressure = 1_atm;
|
2024-09-04 05:36:05 +00:00
|
|
|
dp.bottomsac = prefs.bottomsac;
|
|
|
|
dp.decosac = prefs.decosac;
|
2015-09-22 14:32:26 +00:00
|
|
|
|
2024-09-03 15:04:48 +00:00
|
|
|
struct gasmix bottomgas = { 21_percent, 0_percent };
|
2024-06-30 20:39:52 +00:00
|
|
|
cylinder_t *cyl0 = dive.get_or_create_cylinder(0);
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl0->gasmix = bottomgas;
|
2024-09-03 15:04:48 +00:00
|
|
|
cyl0->type.size = 36_l;
|
|
|
|
cyl0->type.workingpressure = 232_bar;
|
|
|
|
dive.surface_pressure = 1_atm;
|
2022-11-05 19:27:49 +00:00
|
|
|
reset_cylinders(&dive, true);
|
2015-09-22 14:32:26 +00:00
|
|
|
|
|
|
|
int droptime = M_OR_FT(30, 100) * 60 / M_OR_FT(18, 60);
|
2018-03-28 20:50:28 +00:00
|
|
|
plan_add_segment(dp, droptime, M_OR_FT(30, 100), 0, 0, 1, OC);
|
2018-07-25 19:39:04 +00:00
|
|
|
plan_add_segment(dp, 20 * 60 - droptime, M_OR_FT(30, 100), 0, 0, 1, OC);
|
2024-09-04 05:36:05 +00:00
|
|
|
return dp;
|
2015-09-22 14:32:26 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan setupPlanVpmb100mTo70m30min()
|
2015-09-22 14:32:26 +00:00
|
|
|
{
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan dp;
|
|
|
|
dp.salinity = 10300;
|
2024-09-09 11:55:37 +00:00
|
|
|
dp.surface_pressure = 1_atm;
|
2024-09-04 05:36:05 +00:00
|
|
|
dp.bottomsac = prefs.bottomsac;
|
|
|
|
dp.decosac = prefs.decosac;
|
2015-09-22 14:32:26 +00:00
|
|
|
|
2024-09-03 15:04:48 +00:00
|
|
|
struct gasmix bottomgas = { 12_percent, 65_percent };
|
|
|
|
struct gasmix tx21_35 = { 21_percent, 35_percent };
|
|
|
|
struct gasmix ean50 = { 50_percent, 0_percent };
|
|
|
|
struct gasmix oxygen = { 100_percent, 0_percent };
|
|
|
|
pressure_t po2 = 1600_mbar;
|
test: fix subtle bug in testplan.cpp
testplan.cpp had a subtle bug since converting from a fixed-size
cylinder table to a dynamic cylinder table.
As noted in equipment.h, pointers to cylinders are *not* stable
when the cylinder table grows. Therefore, a construct such as
cylinder_t *cyl0 = get_or_create_cylinder(&dive, 0);
cylinder_t *cyl1 = get_or_create_cylinder(&dive, 1);
cylinder_t *cyl2 = get_or_create_cylinder(&dive, 2);
can give dangling cyl0 and cyl1 pointers. This was not an issue
with the old table code, since it had a rather liberal allocation
pattern. However, when switching to std::vector<>, the problem
becomes active.
To "fix" this, simply access the highest index first. Of course,
this should never be done in real code! Therefore, add a
comment at each instance.
Quickly checked all other get_or_create_cylinder() calls and
they seemed to be safe.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-05-31 16:51:03 +00:00
|
|
|
// Note: we add the highest-index cylinder first, because
|
|
|
|
// pointers to cylinders are not stable when reallocating.
|
|
|
|
// For testing OK - don't do this in actual code!
|
2024-06-30 20:39:52 +00:00
|
|
|
cylinder_t *cyl3 = dive.get_or_create_cylinder(3);
|
|
|
|
cylinder_t *cyl0 = dive.get_or_create_cylinder(0);
|
|
|
|
cylinder_t *cyl1 = dive.get_or_create_cylinder(1);
|
|
|
|
cylinder_t *cyl2 = dive.get_or_create_cylinder(2);
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl0->gasmix = bottomgas;
|
2024-09-03 15:04:48 +00:00
|
|
|
cyl0->type.size = 36_l;
|
|
|
|
cyl0->type.workingpressure = 232_bar;
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl1->gasmix = tx21_35;
|
|
|
|
cyl2->gasmix = ean50;
|
|
|
|
cyl3->gasmix = oxygen;
|
2024-09-03 15:04:48 +00:00
|
|
|
dive.surface_pressure = 1_atm;
|
2022-11-05 19:27:49 +00:00
|
|
|
reset_cylinders(&dive, true);
|
2015-09-22 14:32:26 +00:00
|
|
|
|
|
|
|
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(18, 60);
|
2024-06-30 14:17:20 +00:00
|
|
|
plan_add_segment(dp, 0, dive.gas_mod(tx21_35, po2, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
|
|
|
|
plan_add_segment(dp, 0, dive.gas_mod(ean50, po2, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
|
|
|
|
plan_add_segment(dp, 0, dive.gas_mod(oxygen, po2, M_OR_FT(3, 10)).mm, 3, 0, 1, OC);
|
2018-03-28 20:50:28 +00:00
|
|
|
plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
|
2018-07-25 19:39:04 +00:00
|
|
|
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);
|
2018-03-28 20:50:28 +00:00
|
|
|
plan_add_segment(dp, (30 - 20 - 3) * 60, M_OR_FT(70, 230), 0, 0, 1, OC);
|
2024-09-04 05:36:05 +00:00
|
|
|
return dp;
|
2015-09-22 14:32:26 +00:00
|
|
|
}
|
|
|
|
|
2018-10-30 10:55:11 +00:00
|
|
|
/* This tests handling different gases in the manually entered part of the dive */
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan setupPlanSeveralGases()
|
2018-10-30 10:55:11 +00:00
|
|
|
{
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan dp;
|
|
|
|
dp.salinity = 10300;
|
2024-09-09 11:55:37 +00:00
|
|
|
dp.surface_pressure = 1_atm;
|
2024-09-04 05:36:05 +00:00
|
|
|
dp.bottomsac = prefs.bottomsac;
|
|
|
|
dp.decosac = prefs.decosac;
|
2018-10-30 10:55:11 +00:00
|
|
|
|
2024-09-03 15:04:48 +00:00
|
|
|
struct gasmix ean36 = { 36_percent, 0_percent };
|
|
|
|
struct gasmix tx11_50 = { 11_percent, 50_percent };
|
2018-10-30 10:55:11 +00:00
|
|
|
|
test: fix subtle bug in testplan.cpp
testplan.cpp had a subtle bug since converting from a fixed-size
cylinder table to a dynamic cylinder table.
As noted in equipment.h, pointers to cylinders are *not* stable
when the cylinder table grows. Therefore, a construct such as
cylinder_t *cyl0 = get_or_create_cylinder(&dive, 0);
cylinder_t *cyl1 = get_or_create_cylinder(&dive, 1);
cylinder_t *cyl2 = get_or_create_cylinder(&dive, 2);
can give dangling cyl0 and cyl1 pointers. This was not an issue
with the old table code, since it had a rather liberal allocation
pattern. However, when switching to std::vector<>, the problem
becomes active.
To "fix" this, simply access the highest index first. Of course,
this should never be done in real code! Therefore, add a
comment at each instance.
Quickly checked all other get_or_create_cylinder() calls and
they seemed to be safe.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-05-31 16:51:03 +00:00
|
|
|
// Note: we add the highest-index cylinder first, because
|
|
|
|
// pointers to cylinders are not stable when reallocating.
|
|
|
|
// For testing OK - don't do this in actual code!
|
2024-06-30 20:39:52 +00:00
|
|
|
cylinder_t *cyl1 = dive.get_or_create_cylinder(1);
|
|
|
|
cylinder_t *cyl0 = dive.get_or_create_cylinder(0);
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl0->gasmix = ean36;
|
2024-09-03 15:04:48 +00:00
|
|
|
cyl0->type.size = 36_l;
|
|
|
|
cyl0->type.workingpressure = 232_bar;
|
2019-08-04 16:44:57 +00:00
|
|
|
cyl1->gasmix = tx11_50;
|
2024-09-03 15:04:48 +00:00
|
|
|
dive.surface_pressure = 1_atm;
|
2022-11-05 19:27:49 +00:00
|
|
|
reset_cylinders(&dive, true);
|
2018-10-30 10:55:11 +00:00
|
|
|
|
|
|
|
plan_add_segment(dp, 120, 40000, 0, 0, true, OC);
|
|
|
|
plan_add_segment(dp, 18 * 60, 40000, 0, 0, true, OC);
|
|
|
|
plan_add_segment(dp, 10 * 60, 10000, 1, 0, true, OC);
|
|
|
|
plan_add_segment(dp, 5 * 60, 10000, 0, 0, true, OC);
|
2024-09-04 05:36:05 +00:00
|
|
|
return dp;
|
2018-10-30 10:55:11 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan setupPlanCcr()
|
2023-02-16 02:53:17 +00:00
|
|
|
{
|
2024-09-04 05:36:05 +00:00
|
|
|
diveplan dp;
|
|
|
|
dp.salinity = 10300;
|
2024-09-09 11:55:37 +00:00
|
|
|
dp.surface_pressure = 1_atm;
|
2024-09-04 05:36:05 +00:00
|
|
|
dp.gflow = 50;
|
|
|
|
dp.gfhigh = 70;
|
|
|
|
dp.bottomsac = prefs.bottomsac;
|
|
|
|
dp.decosac = prefs.decosac;
|
2023-02-16 02:53:17 +00:00
|
|
|
|
2024-09-03 15:04:48 +00:00
|
|
|
pressure_t po2 = 1600_mbar;
|
|
|
|
struct gasmix diluent = { 20_percent, 21_percent};
|
|
|
|
struct gasmix ean53 = { 53_percent, 0_percent};
|
|
|
|
struct gasmix tx19_33 = { 19_percent, 33_percent};
|
test: fix subtle bug in testplan.cpp
testplan.cpp had a subtle bug since converting from a fixed-size
cylinder table to a dynamic cylinder table.
As noted in equipment.h, pointers to cylinders are *not* stable
when the cylinder table grows. Therefore, a construct such as
cylinder_t *cyl0 = get_or_create_cylinder(&dive, 0);
cylinder_t *cyl1 = get_or_create_cylinder(&dive, 1);
cylinder_t *cyl2 = get_or_create_cylinder(&dive, 2);
can give dangling cyl0 and cyl1 pointers. This was not an issue
with the old table code, since it had a rather liberal allocation
pattern. However, when switching to std::vector<>, the problem
becomes active.
To "fix" this, simply access the highest index first. Of course,
this should never be done in real code! Therefore, add a
comment at each instance.
Quickly checked all other get_or_create_cylinder() calls and
they seemed to be safe.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-05-31 16:51:03 +00:00
|
|
|
// Note: we add the highest-index cylinder first, because
|
|
|
|
// pointers to cylinders are not stable when reallocating.
|
|
|
|
// For testing OK - don't do this in actual code!
|
2024-06-30 20:39:52 +00:00
|
|
|
cylinder_t *cyl2 = dive.get_or_create_cylinder(2);
|
|
|
|
cylinder_t *cyl0 = dive.get_or_create_cylinder(0);
|
|
|
|
cylinder_t *cyl1 = dive.get_or_create_cylinder(1);
|
2023-02-16 02:53:17 +00:00
|
|
|
cyl0->gasmix = diluent;
|
2024-06-30 14:17:20 +00:00
|
|
|
cyl0->depth = dive.gas_mod(diluent, po2, M_OR_FT(3, 10));
|
2024-09-03 15:04:48 +00:00
|
|
|
cyl0->type.size = 3_l;
|
|
|
|
cyl0->type.workingpressure = 200_bar;
|
2023-02-16 02:53:17 +00:00
|
|
|
cyl0->cylinder_use = DILUENT;
|
|
|
|
cyl1->gasmix = ean53;
|
2024-06-30 14:17:20 +00:00
|
|
|
cyl1->depth = dive.gas_mod(ean53, po2, M_OR_FT(3, 10));
|
2023-02-16 02:53:17 +00:00
|
|
|
cyl2->gasmix = tx19_33;
|
2024-06-30 14:17:20 +00:00
|
|
|
cyl2->depth = dive.gas_mod(tx19_33, po2, M_OR_FT(3, 10));
|
2022-11-05 19:27:49 +00:00
|
|
|
reset_cylinders(&dive, true);
|
2023-02-16 02:53:17 +00:00
|
|
|
|
|
|
|
plan_add_segment(dp, 0, cyl1->depth.mm, 1, 0, false, OC);
|
|
|
|
plan_add_segment(dp, 0, cyl2->depth.mm, 2, 0, false, OC);
|
|
|
|
plan_add_segment(dp, 20 * 60, M_OR_FT(60, 197), 0, 1300, true, CCR);
|
2024-09-04 05:36:05 +00:00
|
|
|
|
|
|
|
return dp;
|
2023-02-16 02:53:17 +00:00
|
|
|
}
|
|
|
|
|
2015-08-29 12:30:48 +00:00
|
|
|
/* We compare the calculated runtimes against two values:
|
|
|
|
* - Known runtime calculated by Subsurface previously (to detect if anything has changed)
|
|
|
|
* - Benchmark runtime (we should be close, but not always exactly the same)
|
|
|
|
*/
|
|
|
|
bool compareDecoTime(int actualRunTimeSeconds, int benchmarkRunTimeSeconds, int knownSsrfRunTimeSeconds)
|
2015-08-25 21:51:57 +00:00
|
|
|
{
|
2015-08-29 12:30:48 +00:00
|
|
|
bool result;
|
|
|
|
|
2015-08-25 21:51:57 +00:00
|
|
|
// If the calculated run time equals the expected run time, do a simple comparison
|
2015-08-29 12:30:48 +00:00
|
|
|
if (actualRunTimeSeconds == benchmarkRunTimeSeconds) {
|
2015-08-30 05:40:34 +00:00
|
|
|
result = true;
|
2015-08-25 21:51:57 +00:00
|
|
|
} else {
|
|
|
|
/* We want the difference between the expected and calculated total run time to be not more than
|
|
|
|
* 1% of total run time + 1 minute */
|
|
|
|
int permilDifferenceAllowed = 1 * 10;
|
|
|
|
int absoluteDifferenceAllowedSeconds = 60;
|
2017-03-23 01:13:49 +00:00
|
|
|
int totalDifferenceAllowed = lrint(0.001 * permilDifferenceAllowed * benchmarkRunTimeSeconds + absoluteDifferenceAllowedSeconds);
|
2015-08-29 12:30:48 +00:00
|
|
|
int totalDifference = abs(actualRunTimeSeconds - benchmarkRunTimeSeconds);
|
2015-08-25 21:51:57 +00:00
|
|
|
|
2024-03-26 13:05:35 +00:00
|
|
|
report_info("Calculated run time = %d seconds", actualRunTimeSeconds);
|
|
|
|
report_info("Expected run time = %d seconds", benchmarkRunTimeSeconds);
|
|
|
|
report_info("Allowed time difference is %g percent plus %d seconds = %d seconds",
|
2015-08-25 21:51:57 +00:00
|
|
|
permilDifferenceAllowed * 0.1, absoluteDifferenceAllowedSeconds, totalDifferenceAllowed);
|
2024-03-26 13:05:35 +00:00
|
|
|
report_info("total difference = %d seconds", totalDifference);
|
2015-08-25 21:51:57 +00:00
|
|
|
|
2015-08-30 05:40:34 +00:00
|
|
|
result = (totalDifference <= totalDifferenceAllowed);
|
2015-08-29 12:30:48 +00:00
|
|
|
}
|
|
|
|
if ((knownSsrfRunTimeSeconds > 0) && (actualRunTimeSeconds != knownSsrfRunTimeSeconds)) {
|
2024-03-26 13:05:35 +00:00
|
|
|
report_error("Calculated run time does not match known Subsurface runtime");
|
|
|
|
report_error("Calculated runtime: %d", actualRunTimeSeconds);
|
|
|
|
report_error("Known Subsurface runtime: %d", knownSsrfRunTimeSeconds);
|
2015-08-25 21:51:57 +00:00
|
|
|
}
|
2015-08-29 12:30:48 +00:00
|
|
|
return result;
|
2015-08-25 21:51:57 +00:00
|
|
|
}
|
|
|
|
|
2015-07-04 16:12:54 +00:00
|
|
|
void TestPlan::testMetric()
|
|
|
|
{
|
2024-03-07 18:08:22 +00:00
|
|
|
deco_state_cache cache;
|
2015-07-04 16:12:54 +00:00
|
|
|
|
|
|
|
setupPrefs();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
2017-01-07 02:11:19 +00:00
|
|
|
prefs.planner_deco_mode = BUEHLMANN;
|
2015-07-04 16:12:54 +00:00
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
auto testPlan = setupPlan();
|
2015-07-04 16:12:54 +00:00
|
|
|
|
2024-09-07 13:32:06 +00:00
|
|
|
plan(&test_deco_state, testPlan, &dive, 0, 60, cache, 1, 0);
|
2015-07-04 16:12:54 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2024-05-29 18:40:18 +00:00
|
|
|
dive.notes.clear();
|
2024-06-07 08:25:09 +00:00
|
|
|
save_dive(stdout, dive, false);
|
2015-07-04 16:12:54 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
2024-09-04 05:36:05 +00:00
|
|
|
auto dp = std::find_if(testPlan.dp.begin(), testPlan.dp.end(), [](auto &dp) { return dp.minimum_gas.mbar != 0; });
|
2024-09-10 19:32:09 +00:00
|
|
|
QCOMPARE(lrint(dp == testPlan.dp.end() ? 0.0 : dp->minimum_gas.mbar / 1000.0), 148l);
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(dive.dcs[0].events.size() >= 2);
|
2015-07-04 16:12:54 +00:00
|
|
|
// check first gas change to EAN36 at 33m
|
2024-05-27 15:09:48 +00:00
|
|
|
struct event *ev = &dive.dcs[0].events[0];
|
2015-07-04 16:12:54 +00:00
|
|
|
QCOMPARE(ev->gas.index, 1);
|
|
|
|
QCOMPARE(ev->value, 36);
|
2024-05-27 15:09:48 +00:00
|
|
|
QCOMPARE(get_depth_at_time(&dive.dcs[0], ev->time.seconds), 33000);
|
2015-07-04 16:12:54 +00:00
|
|
|
// check second gas change to Oxygen at 6m
|
2024-05-27 15:09:48 +00:00
|
|
|
ev = &dive.dcs[0].events[1];
|
2015-07-04 16:12:54 +00:00
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 2);
|
|
|
|
QCOMPARE(ev->value, 100);
|
2024-05-27 15:09:48 +00:00
|
|
|
QCOMPARE(get_depth_at_time(&dive.dcs[0], ev->time.seconds), 6000);
|
2017-02-19 09:28:55 +00:00
|
|
|
// check expected run time of 109 minutes
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(compareDecoTime(dive.dcs[0].duration.seconds, 109u * 60u, 109u * 60u));
|
2015-07-04 16:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlan::testImperial()
|
|
|
|
{
|
2024-03-07 18:08:22 +00:00
|
|
|
deco_state_cache cache;
|
2015-07-04 16:12:54 +00:00
|
|
|
|
|
|
|
setupPrefs();
|
|
|
|
prefs.unit_system = IMPERIAL;
|
|
|
|
prefs.units.length = units::FEET;
|
2017-01-07 02:11:19 +00:00
|
|
|
prefs.planner_deco_mode = BUEHLMANN;
|
2015-07-04 16:12:54 +00:00
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
auto testPlan = setupPlan();
|
2015-07-04 16:12:54 +00:00
|
|
|
|
2024-09-07 13:32:06 +00:00
|
|
|
plan(&test_deco_state, testPlan, &dive, 0, 60, cache, 1, 0);
|
2015-07-04 16:12:54 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2024-05-29 18:40:18 +00:00
|
|
|
dive.notes.clear();
|
2024-06-07 08:25:09 +00:00
|
|
|
save_dive(stdout, dive, false);
|
2015-07-04 16:12:54 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
2024-09-04 05:36:05 +00:00
|
|
|
auto dp = std::find_if(testPlan.dp.begin(), testPlan.dp.end(), [](auto &dp) { return dp.minimum_gas.mbar != 0; });
|
2024-09-10 19:32:09 +00:00
|
|
|
QCOMPARE(lrint(dp == testPlan.dp.end() ? 0.0 : dp->minimum_gas.mbar / 1000.0), 155l);
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(dive.dcs[0].events.size() >= 2);
|
2015-07-04 16:12:54 +00:00
|
|
|
// check first gas change to EAN36 at 33m
|
2024-05-27 15:09:48 +00:00
|
|
|
struct event *ev = &dive.dcs[0].events[0];
|
2015-07-04 16:12:54 +00:00
|
|
|
QCOMPARE(ev->gas.index, 1);
|
|
|
|
QCOMPARE(ev->value, 36);
|
2024-05-27 15:09:48 +00:00
|
|
|
QCOMPARE(get_depth_at_time(&dive.dcs[0], ev->time.seconds), 33528);
|
2015-07-04 16:12:54 +00:00
|
|
|
// check second gas change to Oxygen at 6m
|
2024-05-27 15:09:48 +00:00
|
|
|
ev = &dive.dcs[0].events[1];
|
2015-07-04 16:12:54 +00:00
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 2);
|
|
|
|
QCOMPARE(ev->value, 100);
|
2024-05-27 15:09:48 +00:00
|
|
|
QCOMPARE(get_depth_at_time(&dive.dcs[0], ev->time.seconds), 6096);
|
2017-02-19 09:28:55 +00:00
|
|
|
// check expected run time of 111 minutes
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(compareDecoTime(dive.dcs[0].duration.seconds, 111u * 60u - 2u, 111u * 60u - 2u));
|
2015-07-04 16:12:54 +00:00
|
|
|
}
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
void TestPlan::testVpmbMetric45m30minTx()
|
|
|
|
{
|
2024-03-07 18:08:22 +00:00
|
|
|
deco_state_cache cache;
|
2017-03-15 21:28:36 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
auto testPlan = setupPlanVpmb45m30mTx();
|
2017-03-15 21:28:36 +00:00
|
|
|
|
2024-09-07 13:32:06 +00:00
|
|
|
plan(&test_deco_state, testPlan, &dive, 0, 60, cache, 1, 0);
|
2017-03-15 21:28:36 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2024-05-29 18:40:18 +00:00
|
|
|
dive.notes.clear();
|
2024-06-07 08:25:09 +00:00
|
|
|
save_dive(stdout, dive, false);
|
2017-03-15 21:28:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// check minimum gas result
|
2024-09-04 05:36:05 +00:00
|
|
|
auto dp = std::find_if(testPlan.dp.begin(), testPlan.dp.end(), [](auto &dp) { return dp.minimum_gas.mbar != 0; });
|
2024-09-10 19:32:09 +00:00
|
|
|
QCOMPARE(lrint(dp == testPlan.dp.end() ? 0.0 : dp->minimum_gas.mbar / 1000.0), 108l);
|
2017-03-15 21:28:36 +00:00
|
|
|
// print first ceiling
|
2024-06-20 20:47:16 +00:00
|
|
|
printf("First ceiling %.1f m\n", dive.mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar) * 0.001);
|
2017-03-15 21:28:36 +00:00
|
|
|
// check benchmark run time of 141 minutes, and known Subsurface runtime of 139 minutes
|
2024-05-27 15:09:48 +00:00
|
|
|
//QVERIFY(compareDecoTime(dive.dcs[0].duration.seconds, 141u * 60u + 20u, 139u * 60u + 20u));
|
2017-03-15 21:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlan::testVpmbMetric60m10minTx()
|
|
|
|
{
|
2024-03-07 18:08:22 +00:00
|
|
|
deco_state_cache cache;
|
2017-03-15 21:28:36 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
auto testPlan = setupPlanVpmb60m10mTx();
|
2017-03-15 21:28:36 +00:00
|
|
|
|
2024-09-07 13:32:06 +00:00
|
|
|
plan(&test_deco_state, testPlan, &dive, 0, 60, cache, 1, 0);
|
2017-03-15 21:28:36 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2024-05-29 18:40:18 +00:00
|
|
|
dive.notes.clear();
|
2024-06-07 08:25:09 +00:00
|
|
|
save_dive(stdout, dive, false);
|
2017-03-15 21:28:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// check minimum gas result
|
2024-09-04 05:36:05 +00:00
|
|
|
auto dp = std::find_if(testPlan.dp.begin(), testPlan.dp.end(), [](auto &dp) { return dp.minimum_gas.mbar != 0; });
|
2024-09-10 19:32:09 +00:00
|
|
|
QCOMPARE(lrint(dp == testPlan.dp.end() ? 0.0 : dp->minimum_gas.mbar / 1000.0), 162l);
|
2017-03-15 21:28:36 +00:00
|
|
|
// print first ceiling
|
2024-06-20 20:47:16 +00:00
|
|
|
printf("First ceiling %.1f m\n", dive.mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar) * 0.001);
|
2017-03-15 21:28:36 +00:00
|
|
|
// check benchmark run time of 141 minutes, and known Subsurface runtime of 139 minutes
|
2024-05-27 15:09:48 +00:00
|
|
|
//QVERIFY(compareDecoTime(dive.dcs[0].duration.seconds, 141u * 60u + 20u, 139u * 60u + 20u));
|
2017-03-15 21:28:36 +00:00
|
|
|
}
|
|
|
|
|
2015-08-25 14:33:17 +00:00
|
|
|
void TestPlan::testVpmbMetric60m30minAir()
|
|
|
|
{
|
2024-03-07 18:08:22 +00:00
|
|
|
deco_state_cache cache;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
auto testPlan = setupPlanVpmb60m30minAir();
|
2015-08-25 14:33:17 +00:00
|
|
|
|
2024-09-07 13:32:06 +00:00
|
|
|
plan(&test_deco_state, testPlan, &dive, 0, 60, cache, 1, 0);
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2024-05-29 18:40:18 +00:00
|
|
|
dive.notes.clear();
|
2024-06-07 08:25:09 +00:00
|
|
|
save_dive(stdout, dive, false);
|
2015-08-25 14:33:17 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
2024-09-04 05:36:05 +00:00
|
|
|
auto dp = std::find_if(testPlan.dp.begin(), testPlan.dp.end(), [](auto &dp) { return dp.minimum_gas.mbar != 0; });
|
2024-09-10 19:32:09 +00:00
|
|
|
QCOMPARE(lrint(dp == testPlan.dp.end() ? 0.0 : dp->minimum_gas.mbar / 1000.0), 180l);
|
2015-08-29 02:05:39 +00:00
|
|
|
// print first ceiling
|
2024-06-20 20:47:16 +00:00
|
|
|
printf("First ceiling %.1f m\n", dive.mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar) * 0.001);
|
2015-10-06 11:41:40 +00:00
|
|
|
// check benchmark run time of 141 minutes, and known Subsurface runtime of 139 minutes
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(compareDecoTime(dive.dcs[0].duration.seconds, 141u * 60u + 20u, 139u * 60u + 20u));
|
2015-08-25 14:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlan::testVpmbMetric60m30minEan50()
|
|
|
|
{
|
2024-03-07 18:08:22 +00:00
|
|
|
deco_state_cache cache;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
auto testPlan = setupPlanVpmb60m30minEan50();
|
2015-08-25 14:33:17 +00:00
|
|
|
|
2024-09-07 13:32:06 +00:00
|
|
|
plan(&test_deco_state, testPlan, &dive, 0, 60, cache, 1, 0);
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2024-05-29 18:40:18 +00:00
|
|
|
dive.notes.clear();
|
2024-06-07 08:25:09 +00:00
|
|
|
save_dive(stdout, dive, false);
|
2015-08-25 14:33:17 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
2024-09-04 05:36:05 +00:00
|
|
|
auto dp = std::find_if(testPlan.dp.begin(), testPlan.dp.end(), [](auto &dp) { return dp.minimum_gas.mbar != 0; });
|
2024-09-10 19:32:09 +00:00
|
|
|
QCOMPARE(lrint(dp == testPlan.dp.end() ? 0.0 : dp->minimum_gas.mbar / 1000.0), 155l);
|
2015-08-29 02:05:39 +00:00
|
|
|
// print first ceiling
|
2024-06-20 20:47:16 +00:00
|
|
|
printf("First ceiling %.1f m\n", dive.mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar) * 0.001);
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(dive.dcs[0].events.size() >= 1);
|
2015-08-25 14:33:17 +00:00
|
|
|
// check first gas change to EAN50 at 21m
|
2024-05-27 15:09:48 +00:00
|
|
|
struct event *ev = &dive.dcs[0].events[0];
|
2015-08-25 14:33:17 +00:00
|
|
|
QCOMPARE(ev->gas.index, 1);
|
|
|
|
QCOMPARE(ev->value, 50);
|
2024-05-27 15:09:48 +00:00
|
|
|
QCOMPARE(get_depth_at_time(&dive.dcs[0], ev->time.seconds), 21000);
|
2015-08-29 12:30:48 +00:00
|
|
|
// check benchmark run time of 95 minutes, and known Subsurface runtime of 96 minutes
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(compareDecoTime(dive.dcs[0].duration.seconds, 95u * 60u + 20u, 96u * 60u + 20u));
|
2015-08-25 14:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlan::testVpmbMetric60m30minTx()
|
|
|
|
{
|
2024-03-07 18:08:22 +00:00
|
|
|
deco_state_cache cache;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
auto testPlan = setupPlanVpmb60m30minTx();
|
2015-08-25 14:33:17 +00:00
|
|
|
|
2024-09-07 13:32:06 +00:00
|
|
|
plan(&test_deco_state, testPlan, &dive, 0, 60, cache, 1, 0);
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2024-05-29 18:40:18 +00:00
|
|
|
dive.notes.clear();
|
2024-06-07 08:25:09 +00:00
|
|
|
save_dive(stdout, dive, false);
|
2015-08-25 14:33:17 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
2024-09-04 05:36:05 +00:00
|
|
|
auto dp = std::find_if(testPlan.dp.begin(), testPlan.dp.end(), [](auto &dp) { return dp.minimum_gas.mbar != 0; });
|
2024-09-10 19:32:09 +00:00
|
|
|
QCOMPARE(lrint(dp == testPlan.dp.end() ? 0.0 : dp->minimum_gas.mbar / 1000.0), 159l);
|
2015-08-29 02:05:39 +00:00
|
|
|
// print first ceiling
|
2024-06-20 20:47:16 +00:00
|
|
|
printf("First ceiling %.1f m\n", dive.mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar) * 0.001);
|
2015-08-25 14:33:17 +00:00
|
|
|
// check first gas change to EAN50 at 21m
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(dive.dcs[0].events.size() >= 1);
|
|
|
|
struct event *ev = &dive.dcs[0].events[0];
|
2015-08-25 14:33:17 +00:00
|
|
|
QCOMPARE(ev->gas.index, 1);
|
|
|
|
QCOMPARE(ev->value, 50);
|
2024-05-27 15:09:48 +00:00
|
|
|
QCOMPARE(get_depth_at_time(&dive.dcs[0], ev->time.seconds), 21000);
|
2015-10-06 11:41:40 +00:00
|
|
|
// check benchmark run time of 89 minutes, and known Subsurface runtime of 89 minutes
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(compareDecoTime(dive.dcs[0].duration.seconds, 89u * 60u + 20u, 89u * 60u + 20u));
|
2015-08-25 14:33:17 +00:00
|
|
|
}
|
|
|
|
|
2015-08-24 21:37:20 +00:00
|
|
|
void TestPlan::testVpmbMetric100m60min()
|
2015-08-23 14:08:04 +00:00
|
|
|
{
|
2024-03-07 18:08:22 +00:00
|
|
|
deco_state_cache cache;
|
2015-08-23 14:08:04 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
auto testPlan = setupPlanVpmb100m60min();
|
2015-08-23 14:08:04 +00:00
|
|
|
|
2024-09-07 13:32:06 +00:00
|
|
|
plan(&test_deco_state, testPlan, &dive, 0, 60, cache, 1, 0);
|
2015-08-23 14:08:04 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2024-05-29 18:40:18 +00:00
|
|
|
dive.notes.clear();
|
2024-06-07 08:25:09 +00:00
|
|
|
save_dive(stdout, dive, false);
|
2015-08-23 14:08:04 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
2024-09-04 05:36:05 +00:00
|
|
|
auto dp = std::find_if(testPlan.dp.begin(), testPlan.dp.end(), [](auto &dp) { return dp.minimum_gas.mbar != 0; });
|
2024-09-10 19:32:09 +00:00
|
|
|
QCOMPARE(lrint(dp == testPlan.dp.end() ? 0.0 : dp->minimum_gas.mbar / 1000.0), 157l);
|
2015-08-29 02:05:39 +00:00
|
|
|
// print first ceiling
|
2024-06-20 20:47:16 +00:00
|
|
|
printf("First ceiling %.1f m\n", dive.mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar) * 0.001);
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(dive.dcs[0].events.size() >= 2);
|
2015-08-23 14:08:04 +00:00
|
|
|
// check first gas change to EAN50 at 21m
|
2024-05-27 15:09:48 +00:00
|
|
|
struct event *ev = &dive.dcs[0].events[0];
|
2015-08-23 14:08:04 +00:00
|
|
|
QCOMPARE(ev->gas.index, 1);
|
|
|
|
QCOMPARE(ev->value, 50);
|
2024-05-27 15:09:48 +00:00
|
|
|
QCOMPARE(get_depth_at_time(&dive.dcs[0], ev->time.seconds), 21000);
|
2015-08-23 14:08:04 +00:00
|
|
|
// check second gas change to Oxygen at 6m
|
2024-05-27 15:09:48 +00:00
|
|
|
ev = &dive.dcs[0].events[1];
|
2015-08-23 14:08:04 +00:00
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 2);
|
|
|
|
QCOMPARE(ev->value, 100);
|
2024-05-27 15:09:48 +00:00
|
|
|
QCOMPARE(get_depth_at_time(&dive.dcs[0], ev->time.seconds), 6000);
|
2015-10-06 11:41:40 +00:00
|
|
|
// check benchmark run time of 311 minutes, and known Subsurface runtime of 314 minutes
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(compareDecoTime(dive.dcs[0].duration.seconds, 311u * 60u + 20u, 315u * 60u + 20u));
|
2015-08-23 14:08:04 +00:00
|
|
|
}
|
|
|
|
|
2018-10-30 10:55:11 +00:00
|
|
|
void TestPlan::testMultipleGases()
|
|
|
|
{
|
2024-03-07 18:08:22 +00:00
|
|
|
deco_state_cache cache;
|
2018-10-30 10:55:11 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
auto testPlan = setupPlanSeveralGases();
|
2018-10-30 10:55:11 +00:00
|
|
|
|
2024-09-07 13:32:06 +00:00
|
|
|
plan(&test_deco_state, testPlan, &dive, 0, 60, cache, 1, 0);
|
2018-10-30 10:55:11 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2024-05-29 18:40:18 +00:00
|
|
|
dive.notes.clear();
|
2024-06-07 08:25:09 +00:00
|
|
|
save_dive(stdout, dive, false);
|
2018-10-30 10:55:11 +00:00
|
|
|
#endif
|
|
|
|
|
2024-09-03 15:04:48 +00:00
|
|
|
gasmix gas = dive.get_gasmix_at_time(dive.dcs[0], 20_min + 1_sec);
|
2018-10-30 10:55:11 +00:00
|
|
|
QCOMPARE(get_o2(gas), 110);
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(compareDecoTime(dive.dcs[0].duration.seconds, 2480u, 2480u));
|
2018-10-30 10:55:11 +00:00
|
|
|
}
|
|
|
|
|
2015-08-25 14:33:17 +00:00
|
|
|
void TestPlan::testVpmbMetricMultiLevelAir()
|
|
|
|
{
|
2024-03-07 18:08:22 +00:00
|
|
|
deco_state_cache cache;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
auto testPlan = setupPlanVpmbMultiLevelAir();
|
2015-08-25 14:33:17 +00:00
|
|
|
|
2024-09-07 13:32:06 +00:00
|
|
|
plan(&test_deco_state, testPlan, &dive, 0, 60, cache, 1, 0);
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2024-05-29 18:40:18 +00:00
|
|
|
dive.notes.clear();
|
2024-06-07 08:25:09 +00:00
|
|
|
save_dive(stdout, dive, false);
|
2015-08-25 14:33:17 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
2024-09-04 05:36:05 +00:00
|
|
|
auto dp = std::find_if(testPlan.dp.begin(), testPlan.dp.end(), [](auto &dp) { return dp.minimum_gas.mbar != 0; });
|
2024-09-10 19:32:09 +00:00
|
|
|
QCOMPARE(lrint(dp == testPlan.dp.end() ? 0.0 : dp->minimum_gas.mbar / 1000.0), 101l);
|
2015-08-29 02:05:39 +00:00
|
|
|
// print first ceiling
|
2024-06-20 20:47:16 +00:00
|
|
|
printf("First ceiling %.1f m\n", dive.mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar) * 0.001);
|
2015-10-06 11:41:40 +00:00
|
|
|
// check benchmark run time of 167 minutes, and known Subsurface runtime of 169 minutes
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(compareDecoTime(dive.dcs[0].duration.seconds, 167u * 60u + 20u, 169u * 60u + 20u));
|
2015-08-25 14:33:17 +00:00
|
|
|
}
|
|
|
|
|
2015-08-24 21:37:20 +00:00
|
|
|
void TestPlan::testVpmbMetric100m10min()
|
|
|
|
{
|
2024-03-07 18:08:22 +00:00
|
|
|
deco_state_cache cache;
|
2015-08-24 21:37:20 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
auto testPlan = setupPlanVpmb100m10min();
|
2015-08-24 21:37:20 +00:00
|
|
|
|
2024-09-07 13:32:06 +00:00
|
|
|
plan(&test_deco_state, testPlan, &dive, 0, 60, cache, 1, 0);
|
2015-08-24 21:37:20 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2024-05-29 18:40:18 +00:00
|
|
|
dive.notes.clear();
|
2024-06-07 08:25:09 +00:00
|
|
|
save_dive(stdout, dive, false);
|
2015-08-24 21:37:20 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
2024-09-04 05:36:05 +00:00
|
|
|
auto dp = std::find_if(testPlan.dp.begin(), testPlan.dp.end(), [](auto &dp) { return dp.minimum_gas.mbar != 0; });
|
2024-09-10 19:32:09 +00:00
|
|
|
QCOMPARE(lrint(dp == testPlan.dp.end() ? 0.0 : dp->minimum_gas.mbar / 1000.0), 175l);
|
2015-08-29 02:05:39 +00:00
|
|
|
// print first ceiling
|
2024-06-20 20:47:16 +00:00
|
|
|
printf("First ceiling %.1f m\n", dive.mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar) * 0.001);
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(dive.dcs[0].events.size() >= 2);
|
2015-08-24 21:37:20 +00:00
|
|
|
// check first gas change to EAN50 at 21m
|
2024-05-27 15:09:48 +00:00
|
|
|
struct event *ev = &dive.dcs[0].events[0];
|
2015-08-24 21:37:20 +00:00
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 1);
|
|
|
|
QCOMPARE(ev->value, 50);
|
2024-05-27 15:09:48 +00:00
|
|
|
QCOMPARE(get_depth_at_time(&dive.dcs[0], ev->time.seconds), 21000);
|
2015-08-24 21:37:20 +00:00
|
|
|
// check second gas change to Oxygen at 6m
|
2024-05-27 15:09:48 +00:00
|
|
|
ev = &dive.dcs[0].events[1];
|
2015-08-24 21:37:20 +00:00
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 2);
|
|
|
|
QCOMPARE(ev->value, 100);
|
2024-05-27 15:09:48 +00:00
|
|
|
QCOMPARE(get_depth_at_time(&dive.dcs[0], ev->time.seconds), 6000);
|
2015-10-06 11:41:40 +00:00
|
|
|
// check benchmark run time of 58 minutes, and known Subsurface runtime of 57 minutes
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(compareDecoTime(dive.dcs[0].duration.seconds, 58u * 60u + 20u, 57u * 60u + 20u));
|
2015-08-24 21:37:20 +00:00
|
|
|
}
|
2015-08-23 14:08:04 +00:00
|
|
|
|
2015-09-22 14:32:26 +00:00
|
|
|
/* This tests that a previously calculated plan isn't affecting the calculations of the next plan.
|
|
|
|
* It is NOT a 'repetitive dive' test (i.e. with a surface interval and considering tissue
|
|
|
|
* saturation from the previous dive).
|
|
|
|
*/
|
|
|
|
void TestPlan::testVpmbMetricRepeat()
|
|
|
|
{
|
2024-03-07 18:08:22 +00:00
|
|
|
deco_state_cache cache;
|
2015-09-22 14:32:26 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
auto testPlan = setupPlanVpmb30m20min();
|
2015-09-22 14:32:26 +00:00
|
|
|
|
2024-09-07 13:32:06 +00:00
|
|
|
plan(&test_deco_state, testPlan, &dive, 0, 60, cache, 1, 0);
|
2015-09-22 14:32:26 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2024-05-29 18:40:18 +00:00
|
|
|
dive.notes.clear();
|
2024-06-07 08:25:09 +00:00
|
|
|
save_dive(stdout, dive, false);
|
2015-09-22 14:32:26 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
2024-09-04 05:36:05 +00:00
|
|
|
auto dp = std::find_if(testPlan.dp.begin(), testPlan.dp.end(), [](auto &dp) { return dp.minimum_gas.mbar != 0; });
|
2024-09-10 19:32:09 +00:00
|
|
|
QCOMPARE(lrint(dp == testPlan.dp.end() ? 0.0 : dp->minimum_gas.mbar / 1000.0), 61l);
|
2015-09-22 14:32:26 +00:00
|
|
|
// print first ceiling
|
2024-06-20 20:47:16 +00:00
|
|
|
printf("First ceiling %.1f m\n", dive.mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar) * 0.001);
|
2017-02-19 09:28:55 +00:00
|
|
|
// check benchmark run time of 27 minutes, and known Subsurface runtime of 28 minutes
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(compareDecoTime(dive.dcs[0].duration.seconds, 27u * 60u + 20u, 27u * 60u + 20u));
|
2015-09-22 14:32:26 +00:00
|
|
|
|
2024-05-27 15:09:48 +00:00
|
|
|
int firstDiveRunTimeSeconds = dive.dcs[0].duration.seconds;
|
2015-09-22 14:32:26 +00:00
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
testPlan = setupPlanVpmb100mTo70m30min();
|
2024-09-07 13:32:06 +00:00
|
|
|
plan(&test_deco_state, testPlan, &dive, 0, 60, cache, 1, 0);
|
2015-09-22 14:32:26 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2024-05-29 18:40:18 +00:00
|
|
|
dive.notes.clear();
|
2024-06-07 08:25:09 +00:00
|
|
|
save_dive(stdout, dive, false);
|
2015-09-22 14:32:26 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
2024-09-04 05:36:05 +00:00
|
|
|
dp = std::find_if(testPlan.dp.begin(), testPlan.dp.end(), [](auto &dp) { return dp.minimum_gas.mbar != 0; });
|
2024-09-10 19:32:09 +00:00
|
|
|
QCOMPARE(lrint(dp == testPlan.dp.end() ? 0.0 : dp->minimum_gas.mbar / 1000.0), 80l);
|
2015-09-22 14:32:26 +00:00
|
|
|
// print first ceiling
|
2024-06-20 20:47:16 +00:00
|
|
|
printf("First ceiling %.1f m\n", dive.mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar) * 0.001);
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(dive.dcs[0].events.size() >= 3);
|
2015-09-22 14:32:26 +00:00
|
|
|
// check first gas change to 21/35 at 66m
|
2024-05-27 15:09:48 +00:00
|
|
|
struct event *ev = &dive.dcs[0].events[0];
|
2015-09-22 14:32:26 +00:00
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 1);
|
|
|
|
QCOMPARE(ev->gas.mix.o2.permille, 210);
|
|
|
|
QCOMPARE(ev->gas.mix.he.permille, 350);
|
2024-05-27 15:09:48 +00:00
|
|
|
QCOMPARE(get_depth_at_time(&dive.dcs[0], ev->time.seconds), 66000);
|
2015-09-22 14:32:26 +00:00
|
|
|
// check second gas change to EAN50 at 21m
|
2024-05-27 15:09:48 +00:00
|
|
|
ev = &dive.dcs[0].events[1];
|
2015-09-22 14:32:26 +00:00
|
|
|
QCOMPARE(ev->gas.index, 2);
|
|
|
|
QCOMPARE(ev->value, 50);
|
2024-05-27 15:09:48 +00:00
|
|
|
QCOMPARE(get_depth_at_time(&dive.dcs[0], ev->time.seconds), 21000);
|
2015-09-22 14:32:26 +00:00
|
|
|
// check third gas change to Oxygen at 6m
|
2024-05-27 15:09:48 +00:00
|
|
|
ev = &dive.dcs[0].events[2];
|
2015-09-22 14:32:26 +00:00
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 3);
|
|
|
|
QCOMPARE(ev->value, 100);
|
2024-05-27 15:09:48 +00:00
|
|
|
QCOMPARE(get_depth_at_time(&dive.dcs[0], ev->time.seconds), 6000);
|
2015-09-22 14:32:26 +00:00
|
|
|
// we don't have a benchmark, known Subsurface runtime is 126 minutes
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(compareDecoTime(dive.dcs[0].duration.seconds, 127u * 60u + 20u, 127u * 60u + 20u));
|
2015-09-22 14:32:26 +00:00
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
testPlan = setupPlanVpmb30m20min();
|
2024-09-07 13:32:06 +00:00
|
|
|
plan(&test_deco_state, testPlan, &dive, 0, 60, cache, 1, 0);
|
2015-09-22 14:32:26 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2024-05-29 18:40:18 +00:00
|
|
|
dive.notes.clear();
|
2024-06-07 08:25:09 +00:00
|
|
|
save_dive(stdout, dive, false);
|
2015-09-22 14:32:26 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
2024-09-04 05:36:05 +00:00
|
|
|
dp = std::find_if(testPlan.dp.begin(), testPlan.dp.end(), [](auto &dp) { return dp.minimum_gas.mbar != 0; });
|
2024-09-10 19:32:09 +00:00
|
|
|
QCOMPARE(lrint(dp == testPlan.dp.end() ? 0.0 : dp->minimum_gas.mbar / 1000.0), 61l);
|
2015-09-22 14:32:26 +00:00
|
|
|
// print first ceiling
|
2024-06-20 20:47:16 +00:00
|
|
|
printf("First ceiling %.1f m\n", dive.mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar) * 0.001);
|
2015-09-22 14:32:26 +00:00
|
|
|
|
|
|
|
// check runtime is exactly the same as the first time
|
2024-05-27 15:09:48 +00:00
|
|
|
int finalDiveRunTimeSeconds = dive.dcs[0].duration.seconds;
|
2015-09-22 14:32:26 +00:00
|
|
|
QCOMPARE(finalDiveRunTimeSeconds, firstDiveRunTimeSeconds);
|
|
|
|
}
|
|
|
|
|
2023-02-16 02:53:17 +00:00
|
|
|
|
|
|
|
// Test that the correct gases are selected during a CCR dive with bailout ascent
|
|
|
|
// Includes a regression test for https://groups.google.com/g/subsurface-divelog/c/8N3cTz2Zv5E
|
|
|
|
|
|
|
|
void TestPlan::testCcrBailoutGasSelection()
|
|
|
|
{
|
2024-03-07 18:08:22 +00:00
|
|
|
deco_state_cache cache;
|
2023-02-16 02:53:17 +00:00
|
|
|
|
|
|
|
setupPrefs();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
prefs.planner_deco_mode = BUEHLMANN;
|
2024-05-27 15:09:48 +00:00
|
|
|
dive.dcs[0].divemode = CCR;
|
2023-02-16 02:53:17 +00:00
|
|
|
prefs.dobailout = true;
|
|
|
|
|
2024-09-04 05:36:05 +00:00
|
|
|
auto testPlan = setupPlanCcr();
|
2023-02-16 02:53:17 +00:00
|
|
|
|
2024-09-07 13:32:06 +00:00
|
|
|
plan(&test_deco_state, testPlan, &dive, 0, 60, cache, true, false);
|
2023-02-16 02:53:17 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2024-05-29 18:40:18 +00:00
|
|
|
dive.notes.clear();
|
2024-06-07 08:25:09 +00:00
|
|
|
save_dive(stdout, dive, false);
|
2023-02-16 02:53:17 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// check diluent used
|
2024-09-03 15:04:48 +00:00
|
|
|
cylinder_t *cylinder = dive.get_cylinder(get_cylinderid_at_time(&dive, &dive.dcs[0], 20_min - 1_sec));
|
2023-02-16 02:53:17 +00:00
|
|
|
QCOMPARE(cylinder->cylinder_use, DILUENT);
|
|
|
|
QCOMPARE(get_o2(cylinder->gasmix), 200);
|
|
|
|
|
|
|
|
// check deep bailout used
|
2024-09-03 15:04:48 +00:00
|
|
|
cylinder = dive.get_cylinder(get_cylinderid_at_time(&dive, &dive.dcs[0], 20_min + 1_sec));
|
2023-02-16 02:53:17 +00:00
|
|
|
QCOMPARE(cylinder->cylinder_use, OC_GAS);
|
|
|
|
QCOMPARE(get_o2(cylinder->gasmix), 190);
|
|
|
|
|
|
|
|
// check shallow bailout used
|
2024-09-03 15:04:48 +00:00
|
|
|
cylinder = dive.get_cylinder(get_cylinderid_at_time(&dive, &dive.dcs[0], 30_min));
|
2023-02-16 02:53:17 +00:00
|
|
|
QCOMPARE(cylinder->cylinder_use, OC_GAS);
|
|
|
|
QCOMPARE(get_o2(cylinder->gasmix), 530);
|
|
|
|
|
|
|
|
// check expected run time of 51 minutes
|
2024-05-27 15:09:48 +00:00
|
|
|
QVERIFY(compareDecoTime(dive.dcs[0].duration.seconds, 51 * 60, 51 * 60));
|
2023-02-16 02:53:17 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-02-05 22:26:51 +00:00
|
|
|
QTEST_GUILESS_MAIN(TestPlan)
|