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"
|
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
|
|
|
#include <QDebug>
|
|
|
|
|
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
|
2017-08-27 20:49:41 +00:00
|
|
|
struct decostop stoptable[60];
|
2017-11-22 19:42:33 +00:00
|
|
|
struct deco_state test_deco_state;
|
|
|
|
extern bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, int timestep, struct decostop *decostoptable, struct deco_state **cached_datap, bool is_planner, bool show_disclaimer);
|
2015-07-04 16:12:54 +00:00
|
|
|
void setupPrefs()
|
|
|
|
{
|
2015-10-06 09:15:38 +00:00
|
|
|
copy_prefs(&default_prefs, &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()
|
|
|
|
{
|
2015-10-06 09:15:38 +00:00
|
|
|
copy_prefs(&default_prefs, &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
|
|
|
}
|
|
|
|
|
2015-07-04 16:12:54 +00:00
|
|
|
void setupPlan(struct diveplan *dp)
|
|
|
|
{
|
2015-07-06 13:44:05 +00:00
|
|
|
dp->salinity = 10300;
|
2015-07-04 16:12:54 +00:00
|
|
|
dp->surface_pressure = 1013;
|
|
|
|
dp->gfhigh = 100;
|
|
|
|
dp->gflow = 100;
|
2017-03-15 21:28:36 +00:00
|
|
|
dp->bottomsac = prefs.bottomsac;
|
|
|
|
dp->decosac = prefs.decosac;
|
2015-07-04 16:12:54 +00:00
|
|
|
|
2018-07-25 19:39:04 +00:00
|
|
|
struct gasmix bottomgas = {{150}, {450}};
|
|
|
|
struct gasmix ean36 = {{360}, {0}};
|
|
|
|
struct gasmix oxygen = {{1000}, {0}};
|
|
|
|
pressure_t po2 = {1600};
|
2019-08-04 16:44:57 +00:00
|
|
|
cylinder_t *cyl0 = get_or_create_cylinder(&displayed_dive, 0);
|
|
|
|
cylinder_t *cyl1 = get_or_create_cylinder(&displayed_dive, 1);
|
|
|
|
cylinder_t *cyl2 = get_or_create_cylinder(&displayed_dive, 2);
|
|
|
|
cyl0->gasmix = bottomgas;
|
|
|
|
cyl0->type.size.mliter = 36000;
|
|
|
|
cyl0->type.workingpressure.mbar = 232000;
|
|
|
|
cyl1->gasmix = ean36;
|
|
|
|
cyl2->gasmix = oxygen;
|
2015-07-04 16:12:54 +00:00
|
|
|
reset_cylinders(&displayed_dive, true);
|
|
|
|
free_dps(dp);
|
|
|
|
|
|
|
|
int droptime = M_OR_FT(79, 260) * 60 / M_OR_FT(23, 75);
|
2018-08-16 17:10:10 +00:00
|
|
|
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);
|
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);
|
2015-07-04 16:12:54 +00:00
|
|
|
}
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
void setupPlanVpmb45m30mTx(struct diveplan *dp)
|
|
|
|
{
|
|
|
|
dp->salinity = 10300;
|
|
|
|
dp->surface_pressure = 1013;
|
|
|
|
dp->gfhigh = 100;
|
|
|
|
dp->gflow = 100;
|
|
|
|
dp->bottomsac = prefs.bottomsac;
|
|
|
|
dp->decosac = prefs.decosac;
|
|
|
|
|
2018-07-25 19:39:04 +00:00
|
|
|
struct gasmix bottomgas = {{210}, {350}};
|
|
|
|
struct gasmix ean50 = {{500}, {0}};
|
|
|
|
struct gasmix oxygen = {{1000}, {0}};
|
|
|
|
pressure_t po2 = {1600};
|
2019-08-04 16:44:57 +00:00
|
|
|
cylinder_t *cyl0 = get_or_create_cylinder(&displayed_dive, 0);
|
|
|
|
cylinder_t *cyl1 = get_or_create_cylinder(&displayed_dive, 1);
|
|
|
|
cylinder_t *cyl2 = get_or_create_cylinder(&displayed_dive, 2);
|
|
|
|
cyl0->gasmix = bottomgas;
|
|
|
|
cyl0->type.size.mliter = 24000;
|
|
|
|
cyl0->type.workingpressure.mbar = 232000;
|
|
|
|
cyl1->gasmix = ean50;
|
|
|
|
cyl2->gasmix = oxygen;
|
2017-03-15 21:28:36 +00:00
|
|
|
reset_cylinders(&displayed_dive, true);
|
|
|
|
free_dps(dp);
|
|
|
|
|
|
|
|
int droptime = M_OR_FT(45, 150) * 60 / M_OR_FT(23, 75);
|
2018-08-16 17:10:10 +00:00
|
|
|
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);
|
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);
|
2017-03-15 21:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setupPlanVpmb60m10mTx(struct diveplan *dp)
|
|
|
|
{
|
|
|
|
dp->salinity = 10300;
|
|
|
|
dp->surface_pressure = 1013;
|
|
|
|
dp->gfhigh = 100;
|
|
|
|
dp->gflow = 100;
|
|
|
|
dp->bottomsac = prefs.bottomsac;
|
|
|
|
dp->decosac = prefs.decosac;
|
|
|
|
|
2018-07-25 19:39:04 +00:00
|
|
|
struct gasmix bottomgas = {{180}, {450}};
|
|
|
|
struct gasmix tx50_15 = {{500}, {150}};
|
|
|
|
struct gasmix oxygen = {{1000}, {0}};
|
|
|
|
pressure_t po2 = {1600};
|
2019-08-04 16:44:57 +00:00
|
|
|
cylinder_t *cyl0 = get_or_create_cylinder(&displayed_dive, 0);
|
|
|
|
cylinder_t *cyl1 = get_or_create_cylinder(&displayed_dive, 1);
|
|
|
|
cylinder_t *cyl2 = get_or_create_cylinder(&displayed_dive, 2);
|
|
|
|
cyl0->gasmix = bottomgas;
|
|
|
|
cyl0->type.size.mliter = 24000;
|
|
|
|
cyl0->type.workingpressure.mbar = 232000;
|
|
|
|
cyl1->gasmix = tx50_15;
|
|
|
|
cyl2->gasmix = oxygen;
|
2017-03-15 21:28:36 +00:00
|
|
|
reset_cylinders(&displayed_dive, true);
|
|
|
|
free_dps(dp);
|
|
|
|
|
|
|
|
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(23, 75);
|
2018-08-16 17:10:10 +00:00
|
|
|
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);
|
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);
|
2017-03-15 21:28:36 +00:00
|
|
|
}
|
|
|
|
|
2015-08-25 14:33:17 +00:00
|
|
|
void setupPlanVpmb60m30minAir(struct diveplan *dp)
|
|
|
|
{
|
|
|
|
dp->salinity = 10300;
|
|
|
|
dp->surface_pressure = 1013;
|
2017-03-15 21:28:36 +00:00
|
|
|
dp->bottomsac = prefs.bottomsac;
|
|
|
|
dp->decosac = prefs.decosac;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
2018-07-25 19:39:04 +00:00
|
|
|
struct gasmix bottomgas = {{210}, {0}};
|
2019-08-04 16:44:57 +00:00
|
|
|
cylinder_t *cyl0 = get_or_create_cylinder(&displayed_dive, 0);
|
|
|
|
cyl0->gasmix = bottomgas;
|
|
|
|
cyl0->type.size.mliter = 100000;
|
|
|
|
cyl0->type.workingpressure.mbar = 232000;
|
2015-08-25 14:33:17 +00:00
|
|
|
displayed_dive.surface_pressure.mbar = 1013;
|
|
|
|
reset_cylinders(&displayed_dive, true);
|
|
|
|
free_dps(dp);
|
|
|
|
|
|
|
|
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);
|
2015-08-25 14:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setupPlanVpmb60m30minEan50(struct diveplan *dp)
|
|
|
|
{
|
|
|
|
dp->salinity = 10300;
|
|
|
|
dp->surface_pressure = 1013;
|
2017-03-15 21:28:36 +00:00
|
|
|
dp->bottomsac = prefs.bottomsac;
|
|
|
|
dp->decosac = prefs.decosac;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
2018-07-25 19:39:04 +00:00
|
|
|
struct gasmix bottomgas = {{210}, {0}};
|
|
|
|
struct gasmix ean50 = {{500}, {0}};
|
|
|
|
pressure_t po2 = {1600};
|
2019-08-04 16:44:57 +00:00
|
|
|
cylinder_t *cyl0 = get_or_create_cylinder(&displayed_dive, 0);
|
|
|
|
cylinder_t *cyl1 = get_or_create_cylinder(&displayed_dive, 1);
|
|
|
|
cyl0->gasmix = bottomgas;
|
|
|
|
cyl0->type.size.mliter = 36000;
|
|
|
|
cyl0->type.workingpressure.mbar = 232000;
|
|
|
|
cyl1->gasmix = ean50;
|
2015-08-25 14:33:17 +00:00
|
|
|
displayed_dive.surface_pressure.mbar = 1013;
|
|
|
|
reset_cylinders(&displayed_dive, true);
|
|
|
|
free_dps(dp);
|
|
|
|
|
|
|
|
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
|
2018-08-16 17:10:10 +00:00
|
|
|
plan_add_segment(dp, 0, gas_mod(ean50, po2, &displayed_dive, 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);
|
2015-08-25 14:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setupPlanVpmb60m30minTx(struct diveplan *dp)
|
|
|
|
{
|
|
|
|
dp->salinity = 10300;
|
|
|
|
dp->surface_pressure = 1013;
|
2017-03-15 21:28:36 +00:00
|
|
|
dp->bottomsac = prefs.bottomsac;
|
|
|
|
dp->decosac = prefs.decosac;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
2018-07-25 19:39:04 +00:00
|
|
|
struct gasmix bottomgas = {{180}, {450}};
|
|
|
|
struct gasmix ean50 = {{500}, {0}};
|
|
|
|
pressure_t po2 = {1600};
|
2019-08-04 16:44:57 +00:00
|
|
|
cylinder_t *cyl0 = get_or_create_cylinder(&displayed_dive, 0);
|
|
|
|
cylinder_t *cyl1 = get_or_create_cylinder(&displayed_dive, 1);
|
|
|
|
cyl0->gasmix = bottomgas;
|
|
|
|
cyl0->type.size.mliter = 36000;
|
|
|
|
cyl0->type.workingpressure.mbar = 232000;
|
|
|
|
cyl1->gasmix = ean50;
|
2015-08-25 14:33:17 +00:00
|
|
|
displayed_dive.surface_pressure.mbar = 1013;
|
|
|
|
reset_cylinders(&displayed_dive, true);
|
|
|
|
free_dps(dp);
|
|
|
|
|
|
|
|
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
|
2018-08-16 17:10:10 +00:00
|
|
|
plan_add_segment(dp, 0, gas_mod(ean50, po2, &displayed_dive, 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);
|
2015-08-25 14:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setupPlanVpmbMultiLevelAir(struct diveplan *dp)
|
|
|
|
{
|
|
|
|
dp->salinity = 10300;
|
|
|
|
dp->surface_pressure = 1013;
|
2017-03-15 21:28:36 +00:00
|
|
|
dp->bottomsac = prefs.bottomsac;
|
|
|
|
dp->decosac = prefs.decosac;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
2018-07-25 19:39:04 +00:00
|
|
|
struct gasmix bottomgas = {{210}, {0}};
|
2019-08-04 16:44:57 +00:00
|
|
|
cylinder_t *cyl0 = get_or_create_cylinder(&displayed_dive, 0);
|
|
|
|
cyl0->gasmix = bottomgas;
|
|
|
|
cyl0->type.size.mliter = 200000;
|
|
|
|
cyl0->type.workingpressure.mbar = 232000;
|
2015-08-25 14:33:17 +00:00
|
|
|
displayed_dive.surface_pressure.mbar = 1013;
|
|
|
|
reset_cylinders(&displayed_dive, true);
|
|
|
|
free_dps(dp);
|
|
|
|
|
|
|
|
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);
|
2015-08-25 14:33:17 +00:00
|
|
|
}
|
|
|
|
|
2015-08-24 21:37:20 +00:00
|
|
|
void setupPlanVpmb100m60min(struct diveplan *dp)
|
2015-08-23 14:08:04 +00:00
|
|
|
{
|
|
|
|
dp->salinity = 10300;
|
|
|
|
dp->surface_pressure = 1013;
|
2017-03-15 21:28:36 +00:00
|
|
|
dp->bottomsac = prefs.bottomsac;
|
|
|
|
dp->decosac = prefs.decosac;
|
2015-08-23 14:08:04 +00:00
|
|
|
|
2018-07-25 19:39:04 +00:00
|
|
|
struct gasmix bottomgas = {{180}, {450}};
|
|
|
|
struct gasmix ean50 = {{500}, {0}};
|
|
|
|
struct gasmix oxygen = {{1000}, {0}};
|
|
|
|
pressure_t po2 = {1600};
|
2019-08-04 16:44:57 +00:00
|
|
|
cylinder_t *cyl0 = get_or_create_cylinder(&displayed_dive, 0);
|
|
|
|
cylinder_t *cyl1 = get_or_create_cylinder(&displayed_dive, 1);
|
|
|
|
cylinder_t *cyl2 = get_or_create_cylinder(&displayed_dive, 2);
|
|
|
|
cyl0->gasmix = bottomgas;
|
|
|
|
cyl0->type.size.mliter = 200000;
|
|
|
|
cyl0->type.workingpressure.mbar = 232000;
|
|
|
|
cyl1->gasmix = ean50;
|
|
|
|
cyl2->gasmix = oxygen;
|
2015-08-23 14:08:04 +00:00
|
|
|
displayed_dive.surface_pressure.mbar = 1013;
|
|
|
|
reset_cylinders(&displayed_dive, true);
|
|
|
|
free_dps(dp);
|
|
|
|
|
|
|
|
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330);
|
2018-08-16 17:10:10 +00:00
|
|
|
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);
|
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);
|
2015-08-23 14:08:04 +00:00
|
|
|
}
|
|
|
|
|
2015-08-24 21:37:20 +00:00
|
|
|
void setupPlanVpmb100m10min(struct diveplan *dp)
|
|
|
|
{
|
|
|
|
dp->salinity = 10300;
|
|
|
|
dp->surface_pressure = 1013;
|
2017-03-15 21:28:36 +00:00
|
|
|
dp->bottomsac = prefs.bottomsac;
|
|
|
|
dp->decosac = prefs.decosac;
|
2015-08-24 21:37:20 +00:00
|
|
|
|
2018-07-25 19:39:04 +00:00
|
|
|
struct gasmix bottomgas = {{180}, {450}};
|
|
|
|
struct gasmix ean50 = {{500}, {0}};
|
|
|
|
struct gasmix oxygen = {{1000}, {0}};
|
|
|
|
pressure_t po2 = {1600};
|
2019-08-04 16:44:57 +00:00
|
|
|
cylinder_t *cyl0 = get_or_create_cylinder(&displayed_dive, 0);
|
|
|
|
cylinder_t *cyl1 = get_or_create_cylinder(&displayed_dive, 1);
|
|
|
|
cylinder_t *cyl2 = get_or_create_cylinder(&displayed_dive, 2);
|
|
|
|
cyl0->gasmix = bottomgas;
|
|
|
|
cyl0->type.size.mliter = 60000;
|
|
|
|
cyl0->type.workingpressure.mbar = 232000;
|
|
|
|
cyl1->gasmix = ean50;
|
|
|
|
cyl2->gasmix = oxygen;
|
2015-08-24 21:37:20 +00:00
|
|
|
displayed_dive.surface_pressure.mbar = 1013;
|
|
|
|
reset_cylinders(&displayed_dive, true);
|
|
|
|
free_dps(dp);
|
|
|
|
|
|
|
|
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330);
|
2018-08-16 17:10:10 +00:00
|
|
|
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);
|
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);
|
2015-08-24 21:37:20 +00:00
|
|
|
}
|
|
|
|
|
2015-09-22 14:32:26 +00:00
|
|
|
void setupPlanVpmb30m20min(struct diveplan *dp)
|
|
|
|
{
|
|
|
|
dp->salinity = 10300;
|
|
|
|
dp->surface_pressure = 1013;
|
2017-03-15 21:28:36 +00:00
|
|
|
dp->bottomsac = prefs.bottomsac;
|
|
|
|
dp->decosac = prefs.decosac;
|
2015-09-22 14:32:26 +00:00
|
|
|
|
2018-07-25 19:39:04 +00:00
|
|
|
struct gasmix bottomgas = {{210}, {0}};
|
2019-08-04 16:44:57 +00:00
|
|
|
cylinder_t *cyl0 = get_or_create_cylinder(&displayed_dive, 0);
|
|
|
|
cyl0->gasmix = bottomgas;
|
|
|
|
cyl0->type.size.mliter = 36000;
|
|
|
|
cyl0->type.workingpressure.mbar = 232000;
|
2015-09-22 14:32:26 +00:00
|
|
|
displayed_dive.surface_pressure.mbar = 1013;
|
|
|
|
reset_cylinders(&displayed_dive, true);
|
|
|
|
free_dps(dp);
|
|
|
|
|
|
|
|
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);
|
2015-09-22 14:32:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setupPlanVpmb100mTo70m30min(struct diveplan *dp)
|
|
|
|
{
|
|
|
|
dp->salinity = 10300;
|
|
|
|
dp->surface_pressure = 1013;
|
2017-03-15 21:28:36 +00:00
|
|
|
dp->bottomsac = prefs.bottomsac;
|
|
|
|
dp->decosac = prefs.decosac;
|
2015-09-22 14:32:26 +00:00
|
|
|
|
2018-07-25 19:39:04 +00:00
|
|
|
struct gasmix bottomgas = {{120}, {650}};
|
|
|
|
struct gasmix tx21_35 = {{210}, {350}};
|
|
|
|
struct gasmix ean50 = {{500}, {0}};
|
|
|
|
struct gasmix oxygen = {{1000}, {0}};
|
|
|
|
pressure_t po2 = {1600};
|
2019-08-04 16:44:57 +00:00
|
|
|
cylinder_t *cyl0 = get_or_create_cylinder(&displayed_dive, 0);
|
|
|
|
cylinder_t *cyl1 = get_or_create_cylinder(&displayed_dive, 1);
|
|
|
|
cylinder_t *cyl2 = get_or_create_cylinder(&displayed_dive, 2);
|
|
|
|
cylinder_t *cyl3 = get_or_create_cylinder(&displayed_dive, 3);
|
|
|
|
cyl0->gasmix = bottomgas;
|
|
|
|
cyl0->type.size.mliter = 36000;
|
|
|
|
cyl0->type.workingpressure.mbar = 232000;
|
|
|
|
cyl1->gasmix = tx21_35;
|
|
|
|
cyl2->gasmix = ean50;
|
|
|
|
cyl3->gasmix = oxygen;
|
2015-09-22 14:32:26 +00:00
|
|
|
displayed_dive.surface_pressure.mbar = 1013;
|
|
|
|
reset_cylinders(&displayed_dive, true);
|
|
|
|
free_dps(dp);
|
|
|
|
|
|
|
|
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(18, 60);
|
2018-08-16 17:10:10 +00:00
|
|
|
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);
|
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);
|
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 */
|
|
|
|
|
|
|
|
void setupPlanSeveralGases(struct diveplan *dp)
|
|
|
|
{
|
|
|
|
dp->salinity = 10300;
|
|
|
|
dp->surface_pressure = 1013;
|
|
|
|
dp->bottomsac = prefs.bottomsac;
|
|
|
|
dp->decosac = prefs.decosac;
|
|
|
|
|
|
|
|
struct gasmix ean36 = {{360}, {0}};
|
|
|
|
struct gasmix tx11_50 = {{110}, {500}};
|
|
|
|
|
2019-08-04 16:44:57 +00:00
|
|
|
cylinder_t *cyl0 = get_or_create_cylinder(&displayed_dive, 0);
|
|
|
|
cylinder_t *cyl1 = get_or_create_cylinder(&displayed_dive, 1);
|
|
|
|
cyl0->gasmix = ean36;
|
|
|
|
cyl0->type.size.mliter = 36000;
|
|
|
|
cyl0->type.workingpressure.mbar = 232000;
|
|
|
|
cyl1->gasmix = tx11_50;
|
2018-10-30 10:55:11 +00:00
|
|
|
displayed_dive.surface_pressure.mbar = 1013;
|
|
|
|
reset_cylinders(&displayed_dive, true);
|
|
|
|
free_dps(dp);
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2015-08-31 20:12:36 +00:00
|
|
|
qDebug("Calculated run time = %d seconds", actualRunTimeSeconds);
|
|
|
|
qDebug("Expected run time = %d seconds", benchmarkRunTimeSeconds);
|
|
|
|
qDebug("Allowed time difference is %g percent plus %d seconds = %d seconds",
|
2015-08-25 21:51:57 +00:00
|
|
|
permilDifferenceAllowed * 0.1, absoluteDifferenceAllowedSeconds, totalDifferenceAllowed);
|
2015-08-31 20:12:36 +00:00
|
|
|
qDebug("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)) {
|
|
|
|
QWARN("Calculated run time does not match known Subsurface runtime");
|
|
|
|
qWarning("Calculated runtime: %d", actualRunTimeSeconds);
|
|
|
|
qWarning("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()
|
|
|
|
{
|
2017-05-25 22:45:53 +00:00
|
|
|
struct deco_state *cache = NULL;
|
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
|
|
|
|
2016-03-10 04:44:26 +00:00
|
|
|
struct diveplan testPlan = {};
|
2015-07-04 16:12:54 +00:00
|
|
|
setupPlan(&testPlan);
|
|
|
|
|
2017-11-22 19:42:33 +00:00
|
|
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
2015-07-04 16:12:54 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
free(displayed_dive.notes);
|
|
|
|
displayed_dive.notes = NULL;
|
2018-09-10 12:47:56 +00:00
|
|
|
save_dive(stdout, &displayed_dive, false);
|
2015-07-04 16:12:54 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
|
|
|
struct divedatapoint *dp = testPlan.dp;
|
2018-07-25 19:39:04 +00:00
|
|
|
while (!dp->minimum_gas.mbar && dp->next)
|
|
|
|
dp = dp->next;
|
2017-03-15 21:28:36 +00:00
|
|
|
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 148l);
|
2015-07-04 16:12:54 +00:00
|
|
|
// check first gas change to EAN36 at 33m
|
|
|
|
struct event *ev = displayed_dive.dc.events;
|
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 1);
|
|
|
|
QCOMPARE(ev->value, 36);
|
|
|
|
QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 33000);
|
|
|
|
// check second gas change to Oxygen at 6m
|
|
|
|
ev = ev->next;
|
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 2);
|
|
|
|
QCOMPARE(ev->value, 100);
|
|
|
|
QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 6000);
|
2017-02-19 09:28:55 +00:00
|
|
|
// check expected run time of 109 minutes
|
|
|
|
QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 109u * 60u, 109u * 60u));
|
2015-07-04 16:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlan::testImperial()
|
|
|
|
{
|
2017-05-25 22:45:53 +00:00
|
|
|
struct deco_state *cache = NULL;
|
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
|
|
|
|
2016-03-10 04:44:26 +00:00
|
|
|
struct diveplan testPlan = {};
|
2015-07-04 16:12:54 +00:00
|
|
|
setupPlan(&testPlan);
|
|
|
|
|
2017-11-22 19:42:33 +00:00
|
|
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
2015-07-04 16:12:54 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
free(displayed_dive.notes);
|
|
|
|
displayed_dive.notes = NULL;
|
2018-09-10 12:47:56 +00:00
|
|
|
save_dive(stdout, &displayed_dive, false);
|
2015-07-04 16:12:54 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
|
|
|
struct divedatapoint *dp = testPlan.dp;
|
2018-07-25 19:39:04 +00:00
|
|
|
while (!dp->minimum_gas.mbar && dp->next)
|
|
|
|
dp = dp->next;
|
2021-05-07 08:05:43 +00:00
|
|
|
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 155l);
|
2015-07-04 16:12:54 +00:00
|
|
|
// check first gas change to EAN36 at 33m
|
|
|
|
struct event *ev = displayed_dive.dc.events;
|
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 1);
|
|
|
|
QCOMPARE(ev->value, 36);
|
|
|
|
QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 33528);
|
|
|
|
// check second gas change to Oxygen at 6m
|
|
|
|
ev = ev->next;
|
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 2);
|
|
|
|
QCOMPARE(ev->value, 100);
|
|
|
|
QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 6096);
|
2017-02-19 09:28:55 +00:00
|
|
|
// check expected run time of 111 minutes
|
|
|
|
QVERIFY(compareDecoTime(displayed_dive.dc.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()
|
|
|
|
{
|
2017-05-25 22:45:53 +00:00
|
|
|
struct deco_state *cache = NULL;
|
2017-03-15 21:28:36 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
|
|
|
struct diveplan testPlan = {};
|
|
|
|
setupPlanVpmb45m30mTx(&testPlan);
|
|
|
|
|
2017-11-22 19:42:33 +00:00
|
|
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
2017-03-15 21:28:36 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
free(displayed_dive.notes);
|
|
|
|
displayed_dive.notes = NULL;
|
2018-09-10 12:47:56 +00:00
|
|
|
save_dive(stdout, &displayed_dive, false);
|
2017-03-15 21:28:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// check minimum gas result
|
|
|
|
struct divedatapoint *dp = testPlan.dp;
|
2018-07-25 19:39:04 +00:00
|
|
|
while (!dp->minimum_gas.mbar && dp->next)
|
|
|
|
dp = dp->next;
|
2017-03-15 21:28:36 +00:00
|
|
|
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 108l);
|
|
|
|
// print first ceiling
|
2017-11-22 19:42:33 +00:00
|
|
|
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
|
2017-03-15 21:28:36 +00:00
|
|
|
// check benchmark run time of 141 minutes, and known Subsurface runtime of 139 minutes
|
|
|
|
//QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 141u * 60u + 20u, 139u * 60u + 20u));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlan::testVpmbMetric60m10minTx()
|
|
|
|
{
|
2017-05-25 22:45:53 +00:00
|
|
|
struct deco_state *cache = NULL;
|
2017-03-15 21:28:36 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
|
|
|
struct diveplan testPlan = {};
|
|
|
|
setupPlanVpmb60m10mTx(&testPlan);
|
|
|
|
|
2017-11-22 19:42:33 +00:00
|
|
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
2017-03-15 21:28:36 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
free(displayed_dive.notes);
|
|
|
|
displayed_dive.notes = NULL;
|
2018-09-10 12:47:56 +00:00
|
|
|
save_dive(stdout, &displayed_dive, false);
|
2017-03-15 21:28:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// check minimum gas result
|
|
|
|
struct divedatapoint *dp = testPlan.dp;
|
2018-07-25 19:39:04 +00:00
|
|
|
while (!dp->minimum_gas.mbar && dp->next)
|
|
|
|
dp = dp->next;
|
2017-03-15 21:28:36 +00:00
|
|
|
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 162l);
|
|
|
|
// print first ceiling
|
2017-11-22 19:42:33 +00:00
|
|
|
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
|
2017-03-15 21:28:36 +00:00
|
|
|
// check benchmark run time of 141 minutes, and known Subsurface runtime of 139 minutes
|
|
|
|
//QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 141u * 60u + 20u, 139u * 60u + 20u));
|
|
|
|
}
|
|
|
|
|
2015-08-25 14:33:17 +00:00
|
|
|
void TestPlan::testVpmbMetric60m30minAir()
|
|
|
|
{
|
2017-05-25 22:45:53 +00:00
|
|
|
struct deco_state *cache = NULL;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2016-03-10 04:44:26 +00:00
|
|
|
struct diveplan testPlan = {};
|
2015-08-25 14:33:17 +00:00
|
|
|
setupPlanVpmb60m30minAir(&testPlan);
|
|
|
|
|
2017-11-22 19:42:33 +00:00
|
|
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
free(displayed_dive.notes);
|
|
|
|
displayed_dive.notes = NULL;
|
2018-09-10 12:47:56 +00:00
|
|
|
save_dive(stdout, &displayed_dive, false);
|
2015-08-25 14:33:17 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
|
|
|
struct divedatapoint *dp = testPlan.dp;
|
2018-07-25 19:39:04 +00:00
|
|
|
while (!dp->minimum_gas.mbar && dp->next)
|
|
|
|
dp = dp->next;
|
2017-03-15 21:28:36 +00:00
|
|
|
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 180l);
|
2015-08-29 02:05:39 +00:00
|
|
|
// print first ceiling
|
2017-11-22 19:42:33 +00:00
|
|
|
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
|
2015-10-06 11:41:40 +00:00
|
|
|
// check benchmark run time of 141 minutes, and known Subsurface runtime of 139 minutes
|
|
|
|
QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 141u * 60u + 20u, 139u * 60u + 20u));
|
2015-08-25 14:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlan::testVpmbMetric60m30minEan50()
|
|
|
|
{
|
2017-05-25 22:45:53 +00:00
|
|
|
struct deco_state *cache = NULL;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2016-03-10 04:44:26 +00:00
|
|
|
struct diveplan testPlan = {};
|
2015-08-25 14:33:17 +00:00
|
|
|
setupPlanVpmb60m30minEan50(&testPlan);
|
|
|
|
|
2017-11-22 19:42:33 +00:00
|
|
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
free(displayed_dive.notes);
|
|
|
|
displayed_dive.notes = NULL;
|
2018-09-10 12:47:56 +00:00
|
|
|
save_dive(stdout, &displayed_dive, false);
|
2015-08-25 14:33:17 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
|
|
|
struct divedatapoint *dp = testPlan.dp;
|
2018-07-25 19:39:04 +00:00
|
|
|
while (!dp->minimum_gas.mbar && dp->next)
|
|
|
|
dp = dp->next;
|
2017-03-15 21:28:36 +00:00
|
|
|
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 155l);
|
2015-08-29 02:05:39 +00:00
|
|
|
// print first ceiling
|
2017-11-22 19:42:33 +00:00
|
|
|
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
|
2015-08-25 14:33:17 +00:00
|
|
|
// check first gas change to EAN50 at 21m
|
|
|
|
struct event *ev = displayed_dive.dc.events;
|
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 1);
|
|
|
|
QCOMPARE(ev->value, 50);
|
|
|
|
QCOMPARE(get_depth_at_time(&displayed_dive.dc, 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
|
|
|
|
QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 95u * 60u + 20u, 96u * 60u + 20u));
|
2015-08-25 14:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlan::testVpmbMetric60m30minTx()
|
|
|
|
{
|
2017-05-25 22:45:53 +00:00
|
|
|
struct deco_state *cache = NULL;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2016-03-10 04:44:26 +00:00
|
|
|
struct diveplan testPlan = {};
|
2015-08-25 14:33:17 +00:00
|
|
|
setupPlanVpmb60m30minTx(&testPlan);
|
|
|
|
|
2017-11-22 19:42:33 +00:00
|
|
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
free(displayed_dive.notes);
|
|
|
|
displayed_dive.notes = NULL;
|
2018-09-10 12:47:56 +00:00
|
|
|
save_dive(stdout, &displayed_dive, false);
|
2015-08-25 14:33:17 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
|
|
|
struct divedatapoint *dp = testPlan.dp;
|
2018-07-25 19:39:04 +00:00
|
|
|
while (!dp->minimum_gas.mbar && dp->next)
|
|
|
|
dp = dp->next;
|
2017-03-15 21:28:36 +00:00
|
|
|
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 159l);
|
2015-08-29 02:05:39 +00:00
|
|
|
// print first ceiling
|
2017-11-22 19:42:33 +00:00
|
|
|
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
|
2015-08-25 14:33:17 +00:00
|
|
|
// check first gas change to EAN50 at 21m
|
|
|
|
struct event *ev = displayed_dive.dc.events;
|
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 1);
|
|
|
|
QCOMPARE(ev->value, 50);
|
|
|
|
QCOMPARE(get_depth_at_time(&displayed_dive.dc, 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
|
|
|
|
QVERIFY(compareDecoTime(displayed_dive.dc.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
|
|
|
{
|
2017-05-25 22:45:53 +00:00
|
|
|
struct deco_state *cache = NULL;
|
2015-08-23 14:08:04 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2016-03-10 04:44:26 +00:00
|
|
|
struct diveplan testPlan = {};
|
2015-08-24 21:37:20 +00:00
|
|
|
setupPlanVpmb100m60min(&testPlan);
|
2015-08-23 14:08:04 +00:00
|
|
|
|
2017-11-22 19:42:33 +00:00
|
|
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
2015-08-23 14:08:04 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
free(displayed_dive.notes);
|
|
|
|
displayed_dive.notes = NULL;
|
2018-09-10 12:47:56 +00:00
|
|
|
save_dive(stdout, &displayed_dive, false);
|
2015-08-23 14:08:04 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
|
|
|
struct divedatapoint *dp = testPlan.dp;
|
2018-07-25 19:39:04 +00:00
|
|
|
while (!dp->minimum_gas.mbar && dp->next)
|
|
|
|
dp = dp->next;
|
2017-03-15 21:28:36 +00:00
|
|
|
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 157l);
|
2015-08-29 02:05:39 +00:00
|
|
|
// print first ceiling
|
2017-11-22 19:42:33 +00:00
|
|
|
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
|
2015-08-23 14:08:04 +00:00
|
|
|
// check first gas change to EAN50 at 21m
|
|
|
|
struct event *ev = displayed_dive.dc.events;
|
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 1);
|
|
|
|
QCOMPARE(ev->value, 50);
|
|
|
|
QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 21000);
|
|
|
|
// check second gas change to Oxygen at 6m
|
|
|
|
ev = ev->next;
|
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 2);
|
|
|
|
QCOMPARE(ev->value, 100);
|
|
|
|
QCOMPARE(get_depth_at_time(&displayed_dive.dc, 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
|
2017-02-19 09:28:55 +00:00
|
|
|
QVERIFY(compareDecoTime(displayed_dive.dc.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()
|
|
|
|
{
|
|
|
|
struct deco_state *cache = NULL;
|
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
|
|
|
struct diveplan testPlan = {};
|
|
|
|
|
|
|
|
setupPlanSeveralGases(&testPlan);
|
|
|
|
|
|
|
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
free(displayed_dive.notes);
|
|
|
|
displayed_dive.notes = NULL;
|
|
|
|
save_dive(stdout, &displayed_dive, false);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
gasmix gas;
|
|
|
|
gas = get_gasmix_at_time(&displayed_dive, &displayed_dive.dc, {20 * 60 + 1});
|
|
|
|
QCOMPARE(get_o2(gas), 110);
|
|
|
|
QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 2480u, 2480u));
|
|
|
|
}
|
|
|
|
|
2015-08-25 14:33:17 +00:00
|
|
|
void TestPlan::testVpmbMetricMultiLevelAir()
|
|
|
|
{
|
2017-05-25 22:45:53 +00:00
|
|
|
struct deco_state *cache = NULL;
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2016-03-10 04:44:26 +00:00
|
|
|
struct diveplan testPlan = {};
|
2015-08-25 14:33:17 +00:00
|
|
|
setupPlanVpmbMultiLevelAir(&testPlan);
|
|
|
|
|
2017-11-22 19:42:33 +00:00
|
|
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
2015-08-25 14:33:17 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
free(displayed_dive.notes);
|
|
|
|
displayed_dive.notes = NULL;
|
2018-09-10 12:47:56 +00:00
|
|
|
save_dive(stdout, &displayed_dive, false);
|
2015-08-25 14:33:17 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
|
|
|
struct divedatapoint *dp = testPlan.dp;
|
2018-07-25 19:39:04 +00:00
|
|
|
while (!dp->minimum_gas.mbar && dp->next)
|
|
|
|
dp = dp->next;
|
2017-03-15 21:28:36 +00:00
|
|
|
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 101l);
|
2015-08-29 02:05:39 +00:00
|
|
|
// print first ceiling
|
2017-11-22 19:42:33 +00:00
|
|
|
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
|
2015-10-06 11:41:40 +00:00
|
|
|
// check benchmark run time of 167 minutes, and known Subsurface runtime of 169 minutes
|
|
|
|
QVERIFY(compareDecoTime(displayed_dive.dc.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()
|
|
|
|
{
|
2017-05-25 22:45:53 +00:00
|
|
|
struct deco_state *cache = NULL;
|
2015-08-24 21:37:20 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2016-03-10 04:44:26 +00:00
|
|
|
struct diveplan testPlan = {};
|
2015-08-24 21:37:20 +00:00
|
|
|
setupPlanVpmb100m10min(&testPlan);
|
|
|
|
|
2017-11-22 19:42:33 +00:00
|
|
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
2015-08-24 21:37:20 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
free(displayed_dive.notes);
|
|
|
|
displayed_dive.notes = NULL;
|
2018-09-10 12:47:56 +00:00
|
|
|
save_dive(stdout, &displayed_dive, false);
|
2015-08-24 21:37:20 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
|
|
|
struct divedatapoint *dp = testPlan.dp;
|
2018-07-25 19:39:04 +00:00
|
|
|
while (!dp->minimum_gas.mbar && dp->next)
|
|
|
|
dp = dp->next;
|
2017-03-15 21:28:36 +00:00
|
|
|
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 175l);
|
2015-08-29 02:05:39 +00:00
|
|
|
// print first ceiling
|
2017-11-22 19:42:33 +00:00
|
|
|
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
|
2015-08-24 21:37:20 +00:00
|
|
|
// check first gas change to EAN50 at 21m
|
|
|
|
struct event *ev = displayed_dive.dc.events;
|
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 1);
|
|
|
|
QCOMPARE(ev->value, 50);
|
|
|
|
QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 21000);
|
|
|
|
// check second gas change to Oxygen at 6m
|
|
|
|
ev = ev->next;
|
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 2);
|
|
|
|
QCOMPARE(ev->value, 100);
|
|
|
|
QCOMPARE(get_depth_at_time(&displayed_dive.dc, 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
|
|
|
|
QVERIFY(compareDecoTime(displayed_dive.dc.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()
|
|
|
|
{
|
2017-05-25 22:45:53 +00:00
|
|
|
struct deco_state *cache = NULL;
|
2015-09-22 14:32:26 +00:00
|
|
|
|
|
|
|
setupPrefsVpmb();
|
|
|
|
prefs.unit_system = METRIC;
|
|
|
|
prefs.units.length = units::METERS;
|
|
|
|
|
2016-03-10 04:44:26 +00:00
|
|
|
struct diveplan testPlan = {};
|
2015-09-22 14:32:26 +00:00
|
|
|
setupPlanVpmb30m20min(&testPlan);
|
|
|
|
|
2017-11-22 19:42:33 +00:00
|
|
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
2015-09-22 14:32:26 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
free(displayed_dive.notes);
|
|
|
|
displayed_dive.notes = NULL;
|
2018-09-10 12:47:56 +00:00
|
|
|
save_dive(stdout, &displayed_dive, false);
|
2015-09-22 14:32:26 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
|
|
|
struct divedatapoint *dp = testPlan.dp;
|
2018-07-25 19:39:04 +00:00
|
|
|
while (!dp->minimum_gas.mbar && dp->next)
|
|
|
|
dp = dp->next;
|
2017-03-15 21:28:36 +00:00
|
|
|
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 61l);
|
2015-09-22 14:32:26 +00:00
|
|
|
// print first ceiling
|
2017-11-22 19:42:33 +00:00
|
|
|
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
|
2017-02-19 09:28:55 +00:00
|
|
|
// check benchmark run time of 27 minutes, and known Subsurface runtime of 28 minutes
|
2015-09-22 14:32:26 +00:00
|
|
|
QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 27u * 60u + 20u, 27u * 60u + 20u));
|
|
|
|
|
|
|
|
int firstDiveRunTimeSeconds = displayed_dive.dc.duration.seconds;
|
|
|
|
|
|
|
|
setupPlanVpmb100mTo70m30min(&testPlan);
|
2017-11-22 19:42:33 +00:00
|
|
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
2015-09-22 14:32:26 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
free(displayed_dive.notes);
|
|
|
|
displayed_dive.notes = NULL;
|
2018-09-10 12:47:56 +00:00
|
|
|
save_dive(stdout, &displayed_dive, false);
|
2015-09-22 14:32:26 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
|
|
|
dp = testPlan.dp;
|
2018-07-25 19:39:04 +00:00
|
|
|
while (!dp->minimum_gas.mbar && dp->next)
|
|
|
|
dp = dp->next;
|
2017-03-15 21:28:36 +00:00
|
|
|
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 80l);
|
2015-09-22 14:32:26 +00:00
|
|
|
// print first ceiling
|
2017-11-22 19:42:33 +00:00
|
|
|
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
|
2015-09-22 14:32:26 +00:00
|
|
|
// check first gas change to 21/35 at 66m
|
|
|
|
struct event *ev = displayed_dive.dc.events;
|
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 1);
|
|
|
|
QCOMPARE(ev->gas.mix.o2.permille, 210);
|
|
|
|
QCOMPARE(ev->gas.mix.he.permille, 350);
|
|
|
|
QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 66000);
|
|
|
|
// check second gas change to EAN50 at 21m
|
|
|
|
ev = ev->next;
|
|
|
|
QCOMPARE(ev->gas.index, 2);
|
|
|
|
QCOMPARE(ev->value, 50);
|
|
|
|
QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 21000);
|
|
|
|
// check third gas change to Oxygen at 6m
|
|
|
|
ev = ev->next;
|
|
|
|
QVERIFY(ev != NULL);
|
|
|
|
QCOMPARE(ev->gas.index, 3);
|
|
|
|
QCOMPARE(ev->value, 100);
|
|
|
|
QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 6000);
|
|
|
|
// we don't have a benchmark, known Subsurface runtime is 126 minutes
|
2017-02-19 09:28:55 +00:00
|
|
|
QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 127u * 60u + 20u, 127u * 60u + 20u));
|
2015-09-22 14:32:26 +00:00
|
|
|
|
|
|
|
setupPlanVpmb30m20min(&testPlan);
|
2017-11-22 19:42:33 +00:00
|
|
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
2015-09-22 14:32:26 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
free(displayed_dive.notes);
|
|
|
|
displayed_dive.notes = NULL;
|
2018-09-10 12:47:56 +00:00
|
|
|
save_dive(stdout, &displayed_dive, false);
|
2015-09-22 14:32:26 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-15 21:28:36 +00:00
|
|
|
// check minimum gas result
|
|
|
|
dp = testPlan.dp;
|
2018-07-25 19:39:04 +00:00
|
|
|
while (!dp->minimum_gas.mbar && dp->next)
|
|
|
|
dp = dp->next;
|
2017-03-15 21:28:36 +00:00
|
|
|
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 61l);
|
2015-09-22 14:32:26 +00:00
|
|
|
// print first ceiling
|
2017-11-22 19:42:33 +00:00
|
|
|
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
|
2015-09-22 14:32:26 +00:00
|
|
|
|
|
|
|
// check runtime is exactly the same as the first time
|
|
|
|
int finalDiveRunTimeSeconds = displayed_dive.dc.duration.seconds;
|
|
|
|
QCOMPARE(finalDiveRunTimeSeconds, firstDiveRunTimeSeconds);
|
|
|
|
}
|
|
|
|
|
2017-02-05 22:26:51 +00:00
|
|
|
QTEST_GUILESS_MAIN(TestPlan)
|