Changeset 8fa205a in subsurface


Ignore:
Timestamp:
Feb 10, 2015, 2:56:33 PM (3 years ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
Mtest, android_test, dcDownload, foratdotde, gitMerge, gitdebug, gitpictures, ios, master, mergeKirigamiPort, pictimeshift, resolutionIndependence, spinner, testTomaz, testing, v4.5-branch
Children:
6374d9c
Parents:
e44deed
git-author:
Robert C. Helling <helling@…> (02/07/15 12:02:02)
git-committer:
Dirk Hohndel <dirk@…> (02/10/15 14:56:33)
Message:

Be a bit more careful when deleting pO2 values

This patch adds tests if the computer is actually a Predator and
if the value is close to what we would have computed anyway.

[Dirk Hohndel: minor change to use same_string() ]

Signed-off-by: Robert C. Helling <helling@…>
Signed-off-by: Dirk Hohndel <dirk@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • dive.c

    r585d6a0 r8fa205a  
    884884                new_setpoint = prefs.defaultsetpoint;
    885885
    886         if (dc->divemode == OC)
     886        if (dc->divemode == OC && same_string(dc->model, "Shearwater Predator")) {
    887887                // make sure there's no setpoint in the samples
    888888                // this is an irreversible change - so switching a dive to OC
    889889                // by mistake when it's actually CCR is _bad_
    890                 for (int i = 0; i < dc->samples; i++)
    891                         dc->sample[i].setpoint.mbar = 0;
     890                // So we make sure, this comes from a Predator and we only remove
     891                // pO2 values we would have computed anyway.
     892                struct event *ev = get_next_event(dc->events, "gaschange");
     893                struct gasmix *gasmix = get_gasmix_from_event(ev);
     894                struct event *next = get_next_event(ev, "gaschange");
     895
     896                for (int i = 0; i < dc->samples; i++) {
     897                        struct gas_pressures pressures;
     898                        if (next && dc->sample[i].time.seconds >= next->time.seconds) {
     899                                ev = next;
     900                                gasmix = get_gasmix_from_event(ev);
     901                                next = get_next_event(ev, "gaschange");
     902                        }
     903                        fill_pressures(&pressures, calculate_depth_to_mbar(dc->sample[i].depth.mm, dc->surface_pressure, 0), gasmix ,0, OC);
     904                        if (abs(dc->sample[i].setpoint.mbar - (int)(1000 * pressures.o2) <= 50))
     905                                dc->sample[i].setpoint.mbar = 0;
     906                }
     907        }
    892908
    893909        // an "SP change" event at t=0 is currently our marker for OC vs CCR
Note: See TracChangeset for help on using the changeset viewer.