core: turn M_OR_FT macro into a function

No point in this being a macro. Make it return a depth_t - it
was unclear that this returns a depth in mm.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-12-14 10:10:19 +01:00 committed by Michael Keller
parent 0e77dd9a68
commit bd2f7e72f1
11 changed files with 105 additions and 97 deletions

View file

@ -96,8 +96,8 @@ std::unique_ptr<dive> dive_table::default_dive()
auto d = std::make_unique<dive>();
d->when = time(nullptr) + gettimezoneoffset() + 3600;
d->dcs[0].duration = 40_min;
d->dcs[0].maxdepth.mm = M_OR_FT(15, 45);
d->dcs[0].meandepth.mm = M_OR_FT(13, 39); // this creates a resonable looking safety stop
d->dcs[0].maxdepth = m_or_ft(15, 45);
d->dcs[0].meandepth = m_or_ft(13, 39); // this creates a resonable looking safety stop
make_manually_added_dive_dc(&d->dcs[0]);
fake_dc(&d->dcs[0]);
add_default_cylinder(d.get());

View file

@ -314,7 +314,7 @@ void reset_cylinders(struct dive *dive, bool track_gas)
for (cylinder_t &cyl: dive->cylinders) {
if (cyl.depth.mm == 0) /* if the gas doesn't give a mod, calculate based on prefs */
cyl.depth = dive->gas_mod(cyl.gasmix, decopo2, M_OR_FT(3,10));
cyl.depth = dive->gas_mod(cyl.gasmix, decopo2, m_or_ft(3, 10).mm);
if (track_gas)
cyl.start.mbar = cyl.end.mbar = cyl.type.workingpressure.mbar;
cyl.gas_used = 0_l;

View file

@ -660,9 +660,9 @@ std::vector<decostop> plan(struct deco_state *ds, struct diveplan &diveplan, str
* Remark: not reentrant, but the user probably won't change preferences while this is running.
*/
if (prefs.last_stop)
decostoplevels[1].mm = 0;
decostoplevels[1] = 0_m;
else
decostoplevels[1].mm = M_OR_FT(3,10);
decostoplevels[1] = m_or_ft(3, 10);
/* Let's start at the last 'sample', i.e. the last manually entered waypoint. */
const struct sample &sample = dc->samples.back();
@ -1027,7 +1027,7 @@ std::vector<decostop> plan(struct deco_state *ds, struct diveplan &diveplan, str
* otherwise odd things can happen, such as CVA causing the final ascent to start *later*
* if the ascent rate is slower, which is completely nonsensical.
* Assume final ascent takes 20s, which is the time taken to ascend at 9m/min from 3m */
ds->deco_time = clock - bottom_time - (M_OR_FT(3,10) * ( prefs.last_stop ? 2 : 1)) / last_ascend_rate + 20;
ds->deco_time = clock - bottom_time - (m_or_ft(3, 10).mm * ( prefs.last_stop ? 2 : 1)) / last_ascend_rate + 20;
} while (!is_final_plan && error == PLAN_OK);
plan_add_segment(diveplan, clock - previous_point_time, 0, current_cylinder, po2, false, divemode);

View file

@ -764,12 +764,12 @@ static void calculate_ndl_tts(struct deco_state *ds, const struct dive *dive, st
const int ascent_s_per_deco_step = 1;
/* how long time steps in deco calculations? */
const int time_stepsize = 60;
const int deco_stepsize = M_OR_FT(3, 10);
const depth_t deco_stepsize = m_or_ft(3, 10);
/* at what depth is the current deco-step? */
depth_t ascent_depth { .mm = entry.depth };
int next_stop = round_up(deco_allowed_depth(
tissue_tolerance_calc(ds, dive, dive->depth_to_bar(ascent_depth), in_planner),
surface_pressure, dive, 1).mm, deco_stepsize);
surface_pressure, dive, 1).mm, deco_stepsize.mm);
/* at what time should we give up and say that we got enuff NDL? */
/* If iterating through a dive, entry.tts_calc needs to be reset */
entry.tts_calc = 0;
@ -802,14 +802,14 @@ static void calculate_ndl_tts(struct deco_state *ds, const struct dive *dive, st
add_segment(ds, dive->depth_to_bar(ascent_depth),
gasmix, ascent_s_per_step, entry.o2pressure.mbar, divemode, prefs.decosac, in_planner);
next_stop = round_up(deco_allowed_depth(tissue_tolerance_calc(ds, dive, dive->depth_to_bar(ascent_depth), in_planner),
surface_pressure, dive, 1).mm, deco_stepsize);
surface_pressure, dive, 1).mm, deco_stepsize.mm);
}
ascent_depth.mm = next_stop;
/* And how long is the current deco-step? */
entry.stoptime_calc = 0;
entry.stopdepth_calc = next_stop;
next_stop -= deco_stepsize;
next_stop -= deco_stepsize.mm;
/* And how long is the total TTS */
while (next_stop >= 0) {
@ -829,7 +829,7 @@ static void calculate_ndl_tts(struct deco_state *ds, const struct dive *dive, st
add_segment(ds, dive->depth_to_bar(ascent_depth),
gasmix, ascent_s_per_deco_step, entry.o2pressure.mbar, divemode, prefs.decosac, in_planner);
ascent_depth.mm = next_stop;
next_stop -= deco_stepsize;
next_stop -= deco_stepsize.mm;
}
}
}

View file

@ -199,3 +199,8 @@ unsigned int get_distance(location_t loc1, location_t loc2)
return lrint(6371000 * c);
}
depth_t m_or_ft(int m, int ft)
{
int mm = prefs.units.length == units::METERS ? m * 1000 : feet_to_mm(ft);
return depth_t::from_base(mm);
}

View file

@ -19,8 +19,6 @@
#define HE_DENSITY 166
#define ZERO_C_IN_MKELVIN 273150 // mKelvin
#define M_OR_FT(_m, _f) ((prefs.units.length == units::METERS) ? ((_m) * 1000) : (feet_to_mm(_f)))
/* Salinity is expressed in weight in grams per 10l */
#define SEAWATER_SALINITY 10300
#define EN13319_SALINITY 10200
@ -193,6 +191,10 @@ static inline depth_t operator""_ft(unsigned long long ft)
return depth_t { .mm = static_cast<int32_t>(round(ft * 304.8)) };
}
// Return either the first argument in meters or the second argument in
// feet, depending on use settings.
depth_t m_or_ft(int m, int ft);
struct pressure_t : public unit_base<pressure_t>
{
int32_t mbar = 0; // pressure up to 2000 bar

View file

@ -347,8 +347,8 @@ void ProfileWidget2::mouseDoubleClickEvent(QMouseEvent *event)
return;
int minutes = lrint(profileScene->timeAxis->valueAt(mappedPos) / 60);
int milimeters = lrint(profileScene->profileYAxis->valueAt(mappedPos) / M_OR_FT(1, 1)) * M_OR_FT(1, 1);
plannerModel->addStop(milimeters, minutes * 60);
depth_t depth { .mm = int_cast<int>(profileScene->profileYAxis->valueAt(mappedPos) / m_or_ft(1, 1).mm) * m_or_ft(1, 1).mm };
plannerModel->addStop(depth, minutes * 60);
if (currentState == EDIT)
emit stopAdded();
}
@ -938,7 +938,7 @@ void ProfileWidget2::divePlannerHandlerMoved()
profileScene->timeAxis->setBounds(0.0, profileScene->timeAxis->maximum() * 1.02);
divedatapoint data = plannerModel->at(index);
data.depth.mm = lrint(profileScene->profileYAxis->valueAt(activeHandler->pos()) / M_OR_FT(1, 1)) * M_OR_FT(1, 1);
data.depth.mm = lrint(profileScene->profileYAxis->valueAt(activeHandler->pos()) / m_or_ft(1, 1).mm) * m_or_ft(1, 1).mm;
data.time = lrint(profileScene->timeAxis->valueAt(activeHandler->pos()));
plannerModel->editStop(index, data);
@ -964,7 +964,7 @@ void ProfileWidget2::keyDownAction()
for (int row: handleIndices) {
divedatapoint dp = plannerModel->at(row);
dp.depth.mm += M_OR_FT(1, 5);
dp.depth += m_or_ft(1, 5);
plannerModel->editStop(row, dp);
}
if (currentState == EDIT && !handleIndices.empty())
@ -983,7 +983,7 @@ void ProfileWidget2::keyUpAction()
if (dp.depth.mm <= 0)
continue;
dp.depth.mm -= M_OR_FT(1, 5);
dp.depth -= m_or_ft(1, 5);
plannerModel->editStop(row, dp);
}
if (currentState == EDIT && !handleIndices.empty())

View file

@ -237,13 +237,13 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
} else {
pressure_t modpO2;
modpO2.mbar = inPlanner ? prefs.bottompo2 : (int)(prefs.modpO2 * 1000.0);
return get_depth_string(d->gas_mod(cyl->gasmix, modpO2, M_OR_FT(1,1)), true);
return get_depth_string(d->gas_mod(cyl->gasmix, modpO2, m_or_ft(1, 1).mm), true);
}
case MND:
if (cyl->bestmix_he)
return QStringLiteral("*");
else
return get_depth_string(d->gas_mnd(cyl->gasmix, prefs.bestmixend, M_OR_FT(1,1)), true);
return get_depth_string(d->gas_mnd(cyl->gasmix, prefs.bestmixend, m_or_ft(1, 1).mm), true);
break;
case USE:
return gettextFromC::tr(cylinderuse_text[cyl->cylinder_use]);
@ -414,7 +414,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
prefs.o2consumption / prefs.decosac / prefs.pscr_ratio;
else
modpO2.mbar = prefs.decopo2;
cyl.depth = d->gas_mod(cyl.gasmix, modpO2, M_OR_FT(3, 10));
cyl.depth = d->gas_mod(cyl.gasmix, modpO2, m_or_ft(3, 10).mm);
cyl.bestmix_o2 = false;
}
type = Command::EditCylinderType::GASMIX;
@ -443,7 +443,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
}
pressure_t modpO2;
modpO2.mbar = prefs.decopo2;
cyl.depth = d->gas_mod(cyl.gasmix, modpO2, M_OR_FT(3, 10));
cyl.depth = d->gas_mod(cyl.gasmix, modpO2, m_or_ft(3, 10).mm);
}
type = Command::EditCylinderType::GASMIX;
break;
@ -649,8 +649,8 @@ void CylindersModel::updateDecoDepths(pressure_t olddecopo2)
for (auto &cyl: d->cylinders) {
/* If the gas's deco MOD matches the old pO2, it will have been automatically calculated and should be updated.
* If they don't match, we should leave the user entered depth as it is */
if (cyl.depth.mm == d->gas_mod(cyl.gasmix, olddecopo2, M_OR_FT(3, 10)).mm) {
cyl.depth = d->gas_mod(cyl.gasmix, decopo2, M_OR_FT(3, 10));
if (cyl.depth.mm == d->gas_mod(cyl.gasmix, olddecopo2, m_or_ft(3, 10).mm).mm) {
cyl.depth = d->gas_mod(cyl.gasmix, decopo2, m_or_ft(3, 10).mm);
}
}
emit dataChanged(createIndex(0, 0), createIndex(numRows - 1, COLUMNS - 1));
@ -680,7 +680,7 @@ bool CylindersModel::updateBestMixes()
cyl.gasmix.he.permille = 1000 - get_o2(cyl.gasmix);
pressure_t modpO2;
modpO2.mbar = prefs.decopo2;
cyl.depth = d->gas_mod(cyl.gasmix, modpO2, M_OR_FT(3, 10));
cyl.depth = d->gas_mod(cyl.gasmix, modpO2, m_or_ft(3, 10).mm);
gasUpdated = true;
}
if (cyl.bestmix_he) {

View file

@ -90,12 +90,12 @@ void DivePlannerPointsModel::createSimpleDive(struct dive *dIn)
// If we're in drop_stone_mode, don't add a first point.
// It will be added implicitly.
if (!prefs.drop_stone_mode)
addStop(M_OR_FT(15, 45), 1 * 60, cylinderid, prefs.defaultsetpoint, true, UNDEF_COMP_TYPE);
addStop(m_or_ft(15, 45), 1 * 60, cylinderid, prefs.defaultsetpoint, true, UNDEF_COMP_TYPE);
addStop(M_OR_FT(15, 45), 20 * 60, 0, prefs.defaultsetpoint, true, UNDEF_COMP_TYPE);
addStop(m_or_ft(15, 45), 20 * 60, 0, prefs.defaultsetpoint, true, UNDEF_COMP_TYPE);
if (!isPlanner()) {
addStop(M_OR_FT(5, 15), 42 * 60, cylinderid, prefs.defaultsetpoint, true, UNDEF_COMP_TYPE);
addStop(M_OR_FT(5, 15), 45 * 60, cylinderid, prefs.defaultsetpoint, true, UNDEF_COMP_TYPE);
addStop(m_or_ft(5, 15), 42 * 60, cylinderid, prefs.defaultsetpoint, true, UNDEF_COMP_TYPE);
addStop(m_or_ft(5, 15), 45 * 60, cylinderid, prefs.defaultsetpoint, true, UNDEF_COMP_TYPE);
}
updateDiveProfile();
}
@ -173,7 +173,8 @@ void DivePlannerPointsModel::loadFromDive(dive *dIn, int dcNrIn)
if (newtime.seconds == lastrecordedtime.seconds)
newtime.seconds += 10;
divemode_t current_divemode = loop.at(newtime.seconds - 1);
addStop(depthsum / samplecount, newtime.seconds, cylinderid, last_sp.mbar, true, current_divemode);
depth_t depth { .mm = depthsum / samplecount };
addStop(depth, newtime.seconds, cylinderid, last_sp.mbar, true, current_divemode);
lastrecordedtime = newtime;
}
lasttime = newtime;
@ -184,7 +185,7 @@ void DivePlannerPointsModel::loadFromDive(dive *dIn, int dcNrIn)
// make sure we get the last point right so the duration is correct
divemode_t current_divemode = loop.at(dc->duration.seconds);
if (!hasMarkedSamples && !dc->last_manual_time.seconds)
addStop(0, dc->duration.seconds,cylinderid, last_sp.mbar, true, current_divemode);
addStop(0_m, dc->duration.seconds,cylinderid, last_sp.mbar, true, current_divemode);
preserved_until = d->duration;
updateDiveProfile();
@ -808,19 +809,19 @@ int DivePlannerPointsModel::lastEnteredPoint() const
void DivePlannerPointsModel::addDefaultStop()
{
removeDeco();
addStop(0, 0, -1, prefs.defaultsetpoint, true, UNDEF_COMP_TYPE);
addStop(0_m, 0, -1, prefs.defaultsetpoint, true, UNDEF_COMP_TYPE);
}
void DivePlannerPointsModel::addStop(int milimeters, int seconds)
void DivePlannerPointsModel::addStop(depth_t depth, int seconds)
{
removeDeco();
addStop(milimeters, seconds, -1, prefs.defaultsetpoint, true, UNDEF_COMP_TYPE);
addStop(depth, seconds, -1, prefs.defaultsetpoint, true, UNDEF_COMP_TYPE);
updateDiveProfile();
}
// cylinderid_in == -1 means same gas as before.
// divemode == UNDEF_COMP_TYPE means determine from previous point.
int DivePlannerPointsModel::addStop(int milimeters, int seconds, int cylinderid_in, int ccpoint, bool entered, enum divemode_t divemode)
int DivePlannerPointsModel::addStop(depth_t depth, int seconds, int cylinderid_in, int ccpoint, bool entered, enum divemode_t divemode)
{
int cylinderid = 0;
bool usePrevious = false;
@ -830,16 +831,16 @@ int DivePlannerPointsModel::addStop(int milimeters, int seconds, int cylinderid_
usePrevious = true;
int row = divepoints.count();
if (seconds == 0 && milimeters == 0) {
if (seconds == 0 && depth.mm == 0) {
if (row == 0) {
milimeters = M_OR_FT(5, 15); // 5m / 15ft
depth = m_or_ft(5, 15); // 5m / 15ft
seconds = 600; // 10 min
// Default to the first cylinder
cylinderid = 0;
} else {
/* this is only possible if the user clicked on the 'plus' sign on the DivePoints Table */
const divedatapoint t = divepoints.at(lastEnteredPoint());
milimeters = t.depth.mm;
depth = t.depth;
seconds = t.time + 600; // 10 minutes.
cylinderid = t.cylinderid;
ccpoint = t.setpoint;
@ -881,7 +882,7 @@ int DivePlannerPointsModel::addStop(int milimeters, int seconds, int cylinderid_
// add the new stop
beginInsertRows(QModelIndex(), row, row);
divedatapoint point(seconds, milimeters, cylinderid, ccpoint, entered);
divedatapoint point(seconds, depth.mm, cylinderid, ccpoint, entered);
point.divemode = divemode;
divepoints.insert(divepoints.begin() + row, point);
endInsertRows();

View file

@ -65,7 +65,7 @@ public:
struct deco_state final_deco_state;
void loadFromDive(dive *d, int dcNr);
void addStop(int millimeters, int seconds);
void addStop(depth_t depth, int seconds);
void cylindersChanged();
public
slots:
@ -120,7 +120,7 @@ signals:
private:
explicit DivePlannerPointsModel(QObject *parent = 0);
void clear();
int addStop(int millimeters, int seconds, int cylinderid_in, int ccpoint, bool entered, enum divemode_t);
int addStop(depth_t depth, int seconds, int cylinderid_in, int ccpoint, bool entered, enum divemode_t);
void removePoints(const std::vector<int> &rows);
void setupStartTime();
void setupCylinders();

View file

@ -64,11 +64,11 @@ diveplan setupPlan()
cyl2->gasmix = oxygen;
reset_cylinders(&dive, true);
int droptime = M_OR_FT(79, 260) * 60 / M_OR_FT(23, 75);
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);
plan_add_segment(dp, droptime, M_OR_FT(79, 260), 0, 0, 1, OC);
plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(79, 260), 0, 0, 1, OC);
int droptime = m_or_ft(79, 260).mm * 60 / m_or_ft(23, 75).mm;
plan_add_segment(dp, 0, dive.gas_mod(ean36, po2, m_or_ft(3, 10).mm).mm, 1, 0, 1, OC);
plan_add_segment(dp, 0, dive.gas_mod(oxygen, po2, m_or_ft(3, 10).mm).mm, 2, 0, 1, OC);
plan_add_segment(dp, droptime, m_or_ft(79, 260).mm, 0, 0, 1, OC);
plan_add_segment(dp, 30 * 60 - droptime, m_or_ft(79, 260).mm, 0, 0, 1, OC);
return dp;
}
@ -99,11 +99,11 @@ diveplan setupPlanVpmb45m30mTx()
cyl2->gasmix = oxygen;
reset_cylinders(&dive, true);
int droptime = M_OR_FT(45, 150) * 60 / M_OR_FT(23, 75);
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);
plan_add_segment(dp, droptime, M_OR_FT(45, 150), 0, 0, 1, OC);
plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(45, 150), 0, 0, 1, OC);
int droptime = m_or_ft(45, 150).mm * 60 / m_or_ft(23, 75).mm;
plan_add_segment(dp, 0, dive.gas_mod(ean50, po2, m_or_ft(3, 10).mm).mm, 1, 0, 1, OC);
plan_add_segment(dp, 0, dive.gas_mod(oxygen, po2, m_or_ft(3, 10).mm).mm, 2, 0, 1, OC);
plan_add_segment(dp, droptime, m_or_ft(45, 150).mm, 0, 0, 1, OC);
plan_add_segment(dp, 30 * 60 - droptime, m_or_ft(45, 150).mm, 0, 0, 1, OC);
return dp;
}
@ -134,11 +134,11 @@ diveplan setupPlanVpmb60m10mTx()
cyl2->gasmix = oxygen;
reset_cylinders(&dive, true);
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(23, 75);
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);
plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
plan_add_segment(dp, 10 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
int droptime = m_or_ft(60, 200).mm * 60 / m_or_ft(23, 75).mm;
plan_add_segment(dp, 0, dive.gas_mod(tx50_15, po2, m_or_ft(3, 10).mm).mm, 1, 0, 1, OC);
plan_add_segment(dp, 0, dive.gas_mod(oxygen, po2, m_or_ft(3, 10).mm).mm, 2, 0, 1, OC);
plan_add_segment(dp, droptime, m_or_ft(60, 200).mm, 0, 0, 1, OC);
plan_add_segment(dp, 10 * 60 - droptime, m_or_ft(60, 200).mm, 0, 0, 1, OC);
return dp;
}
@ -158,9 +158,9 @@ diveplan setupPlanVpmb60m30minAir()
dive.surface_pressure = 1_atm;
reset_cylinders(&dive, true);
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
int droptime = m_or_ft(60, 200).mm * 60 / m_or_ft(99, 330).mm;
plan_add_segment(dp, droptime, m_or_ft(60, 200).mm, 0, 0, 1, OC);
plan_add_segment(dp, 30 * 60 - droptime, m_or_ft(60, 200).mm, 0, 0, 1, OC);
return dp;
}
@ -187,10 +187,10 @@ diveplan setupPlanVpmb60m30minEan50()
dive.surface_pressure = 1_atm;
reset_cylinders(&dive, true);
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
plan_add_segment(dp, 0, dive.gas_mod(ean50, po2, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
int droptime = m_or_ft(60, 200).mm * 60 / m_or_ft(99, 330).mm;
plan_add_segment(dp, 0, dive.gas_mod(ean50, po2, m_or_ft(3, 10).mm).mm, 1, 0, 1, OC);
plan_add_segment(dp, droptime, m_or_ft(60, 200).mm, 0, 0, 1, OC);
plan_add_segment(dp, 30 * 60 - droptime, m_or_ft(60, 200).mm, 0, 0, 1, OC);
return dp;
}
@ -217,10 +217,10 @@ diveplan setupPlanVpmb60m30minTx()
dive.surface_pressure = 1_atm;
reset_cylinders(&dive, true);
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
plan_add_segment(dp, 0, dive.gas_mod(ean50, po2, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
int droptime = m_or_ft(60, 200).mm * 60 / m_or_ft(99, 330).mm;
plan_add_segment(dp, 0, dive.gas_mod(ean50, po2, m_or_ft(3, 10).mm).mm, 1, 0, 1, OC);
plan_add_segment(dp, droptime, m_or_ft(60, 200).mm, 0, 0, 1, OC);
plan_add_segment(dp, 30 * 60 - droptime, m_or_ft(60, 200).mm, 0, 0, 1, OC);
return dp;
}
@ -240,11 +240,11 @@ diveplan setupPlanVpmbMultiLevelAir()
dive.surface_pressure = 1_atm;
reset_cylinders(&dive, true);
int droptime = M_OR_FT(20, 66) * 60 / M_OR_FT(99, 330);
plan_add_segment(dp, droptime, M_OR_FT(20, 66), 0, 0, 1, OC);
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);
int droptime = m_or_ft(20, 66).mm * 60 / m_or_ft(99, 330).mm;
plan_add_segment(dp, droptime, m_or_ft(20, 66).mm, 0, 0, 1, OC);
plan_add_segment(dp, 10 * 60 - droptime, m_or_ft(20, 66).mm, 0, 0, 1, OC);
plan_add_segment(dp, 1 * 60, m_or_ft(60, 200).mm, 0, 0, 1, OC);
plan_add_segment(dp, 29 * 60, m_or_ft(60, 200).mm, 0, 0, 1, OC);
return dp;
}
@ -274,11 +274,11 @@ diveplan setupPlanVpmb100m60min()
dive.surface_pressure = 1_atm;
reset_cylinders(&dive, true);
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330);
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);
plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
plan_add_segment(dp, 60 * 60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
int droptime = m_or_ft(100, 330).mm * 60 / m_or_ft(99, 330).mm;
plan_add_segment(dp, 0, dive.gas_mod(ean50, po2, m_or_ft(3, 10).mm).mm, 1, 0, 1, OC);
plan_add_segment(dp, 0, dive.gas_mod(oxygen, po2, m_or_ft(3, 10).mm).mm, 2, 0, 1, OC);
plan_add_segment(dp, droptime, m_or_ft(100, 330).mm, 0, 0, 1, OC);
plan_add_segment(dp, 60 * 60 - droptime, m_or_ft(100, 330).mm, 0, 0, 1, OC);
return dp;
}
@ -308,11 +308,11 @@ diveplan setupPlanVpmb100m10min()
dive.surface_pressure = 1_atm;
reset_cylinders(&dive, true);
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330);
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);
plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
plan_add_segment(dp, 10 * 60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
int droptime = m_or_ft(100, 330).mm * 60 / m_or_ft(99, 330).mm;
plan_add_segment(dp, 0, dive.gas_mod(ean50, po2, m_or_ft(3, 10).mm).mm, 1, 0, 1, OC);
plan_add_segment(dp, 0, dive.gas_mod(oxygen, po2, m_or_ft(3, 10).mm).mm, 2, 0, 1, OC);
plan_add_segment(dp, droptime, m_or_ft(100, 330).mm, 0, 0, 1, OC);
plan_add_segment(dp, 10 * 60 - droptime, m_or_ft(100, 330).mm, 0, 0, 1, OC);
return dp;
}
@ -332,9 +332,9 @@ diveplan setupPlanVpmb30m20min()
dive.surface_pressure = 1_atm;
reset_cylinders(&dive, true);
int droptime = M_OR_FT(30, 100) * 60 / M_OR_FT(18, 60);
plan_add_segment(dp, droptime, M_OR_FT(30, 100), 0, 0, 1, OC);
plan_add_segment(dp, 20 * 60 - droptime, M_OR_FT(30, 100), 0, 0, 1, OC);
int droptime = m_or_ft(30, 100).mm * 60 / m_or_ft(18, 60).mm;
plan_add_segment(dp, droptime, m_or_ft(30, 100).mm, 0, 0, 1, OC);
plan_add_segment(dp, 20 * 60 - droptime, m_or_ft(30, 100).mm, 0, 0, 1, OC);
return dp;
}
@ -367,14 +367,14 @@ diveplan setupPlanVpmb100mTo70m30min()
dive.surface_pressure = 1_atm;
reset_cylinders(&dive, true);
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(18, 60);
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);
plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
plan_add_segment(dp, 20 * 60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
plan_add_segment(dp, 3 * 60, M_OR_FT(70, 230), 0, 0, 1, OC);
plan_add_segment(dp, (30 - 20 - 3) * 60, M_OR_FT(70, 230), 0, 0, 1, OC);
int droptime = m_or_ft(100, 330).mm * 60 / m_or_ft(18, 60).mm;
plan_add_segment(dp, 0, dive.gas_mod(tx21_35, po2, m_or_ft(3, 10).mm).mm, 1, 0, 1, OC);
plan_add_segment(dp, 0, dive.gas_mod(ean50, po2, m_or_ft(3, 10).mm).mm, 2, 0, 1, OC);
plan_add_segment(dp, 0, dive.gas_mod(oxygen, po2, m_or_ft(3, 10).mm).mm, 3, 0, 1, OC);
plan_add_segment(dp, droptime, m_or_ft(100, 330).mm, 0, 0, 1, OC);
plan_add_segment(dp, 20 * 60 - droptime, m_or_ft(100, 330).mm, 0, 0, 1, OC);
plan_add_segment(dp, 3 * 60, m_or_ft(70, 230).mm, 0, 0, 1, OC);
plan_add_segment(dp, (30 - 20 - 3) * 60, m_or_ft(70, 230).mm, 0, 0, 1, OC);
return dp;
}
@ -431,19 +431,19 @@ diveplan setupPlanCcr()
cylinder_t *cyl0 = dive.get_or_create_cylinder(0);
cylinder_t *cyl1 = dive.get_or_create_cylinder(1);
cyl0->gasmix = diluent;
cyl0->depth = dive.gas_mod(diluent, po2, M_OR_FT(3, 10));
cyl0->depth = dive.gas_mod(diluent, po2, m_or_ft(3, 10).mm);
cyl0->type.size = 3_l;
cyl0->type.workingpressure = 200_bar;
cyl0->cylinder_use = DILUENT;
cyl1->gasmix = ean53;
cyl1->depth = dive.gas_mod(ean53, po2, M_OR_FT(3, 10));
cyl1->depth = dive.gas_mod(ean53, po2, m_or_ft(3, 10).mm);
cyl2->gasmix = tx19_33;
cyl2->depth = dive.gas_mod(tx19_33, po2, M_OR_FT(3, 10));
cyl2->depth = dive.gas_mod(tx19_33, po2, m_or_ft(3, 10).mm);
reset_cylinders(&dive, true);
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);
plan_add_segment(dp, 20 * 60, m_or_ft(60, 197).mm, 0, 1300, true, CCR);
return dp;
}