mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add some gas mix validation to the planner
A few basic rules for gas validation: We can't have <0%, or >100% of either O2 or He O2 + He must not be >100% Switch depth can't be <0% This places limits on user-input values Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
47a2e8b1d9
commit
8acbeed555
2 changed files with 15 additions and 0 deletions
|
@ -249,6 +249,9 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||
case O2:
|
||||
if (CHANGED()) {
|
||||
cyl->gasmix.o2 = string_to_fraction(vString.toUtf8().data());
|
||||
// fO2 + fHe must not be greater than 1
|
||||
if (((cyl->gasmix.o2.permille == 0) ? O2_IN_AIR : cyl->gasmix.o2.permille) + cyl->gasmix.he.permille > 1000)
|
||||
cyl->gasmix.he.permille = 1000 - ((cyl->gasmix.o2.permille == 0) ? O2_IN_AIR : cyl->gasmix.o2.permille);
|
||||
pressure_t modpO2;
|
||||
if (displayed_dive.dc.divemode == PSCR)
|
||||
modpO2.mbar = prefs.decopo2 + (1000 - get_o2(&cyl->gasmix)) * SURFACE_PRESSURE *
|
||||
|
@ -262,6 +265,9 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||
case HE:
|
||||
if (CHANGED()) {
|
||||
cyl->gasmix.he = string_to_fraction(vString.toUtf8().data());
|
||||
// fO2 + fHe must not be greater than 1
|
||||
if (((cyl->gasmix.o2.permille == 0) ? O2_IN_AIR : cyl->gasmix.o2.permille) + cyl->gasmix.he.permille > 1000)
|
||||
cyl->gasmix.o2.permille = 1000 - cyl->gasmix.he.permille;
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue