Changeset 8acbeed in subsurface for qt-models


Ignore:
Timestamp:
May 28, 2016, 2:24:10 PM (17 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
android_test, master
Children:
2582972
Parents:
47a2e8b
git-author:
Rick Walsh <rickmwalsh@…> (05/21/16 18:00:22)
git-committer:
Dirk Hohndel <dirk@…> (05/28/16 14:24:10)
Message:

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@…>
Signed-off-by: Dirk Hohndel <dirk@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • qt-models/cylindermodel.cpp

    r67dda48 r8acbeed  
    250250                if (CHANGED()) {
    251251                        cyl->gasmix.o2 = string_to_fraction(vString.toUtf8().data());
     252                        // fO2 + fHe must not be greater than 1
     253                        if (((cyl->gasmix.o2.permille == 0) ? O2_IN_AIR : cyl->gasmix.o2.permille) + cyl->gasmix.he.permille > 1000)
     254                                cyl->gasmix.he.permille = 1000 - ((cyl->gasmix.o2.permille == 0) ? O2_IN_AIR : cyl->gasmix.o2.permille);
    252255                        pressure_t modpO2;
    253256                        if (displayed_dive.dc.divemode == PSCR)
     
    263266                if (CHANGED()) {
    264267                        cyl->gasmix.he = string_to_fraction(vString.toUtf8().data());
     268                        // fO2 + fHe must not be greater than 1
     269                        if (((cyl->gasmix.o2.permille == 0) ? O2_IN_AIR : cyl->gasmix.o2.permille) + cyl->gasmix.he.permille > 1000)
     270                                cyl->gasmix.o2.permille = 1000 - cyl->gasmix.he.permille;
    265271                        changed = true;
    266272                }
Note: See TracChangeset for help on using the changeset viewer.