mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Handle CCR setpoint when replanning a dive
When replanning a dive, the setpoint information from the profile waypoints were reset to 0, resulting in a dive that has a dive mode of CCR, but only with OC legs in the profile. This is just wrong, and is corrected here. Notice that there is no averaging involved (in the reduction of a replanned real dive that has more than 100 waypoints) as is done for depth. This is just fine for setpoint data. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is contained in:
parent
89b914e47d
commit
abbb0a244d
1 changed files with 5 additions and 2 deletions
|
@ -69,6 +69,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
|
|||
{
|
||||
int depthsum = 0;
|
||||
int samplecount = 0;
|
||||
o2pressure_t last_sp;
|
||||
bool oldRec = recalc;
|
||||
struct divecomputer *dc = &(d->dc);
|
||||
recalc = false;
|
||||
|
@ -97,11 +98,13 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
|
|||
int plansamples = dc->samples <= 100 ? dc->samples : 100;
|
||||
int j = 0;
|
||||
int cylinderid = 0;
|
||||
last_sp.mbar = 0;
|
||||
for (int i = 0; i < plansamples - 1; i++) {
|
||||
while (j * plansamples <= i * dc->samples) {
|
||||
const sample &s = dc->sample[j];
|
||||
if (s.time.seconds != 0 && (!hasMarkedSamples || s.manually_entered)) {
|
||||
depthsum += s.depth.mm;
|
||||
last_sp = s.setpoint;
|
||||
++samplecount;
|
||||
newtime = s.time;
|
||||
}
|
||||
|
@ -110,7 +113,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
|
|||
if (samplecount) {
|
||||
cylinderid = get_cylinderid_at_time(d, dc, lasttime);
|
||||
if (newtime.seconds - lastrecordedtime.seconds > 10) {
|
||||
addStop(depthsum / samplecount, newtime.seconds, cylinderid, 0, true);
|
||||
addStop(depthsum / samplecount, newtime.seconds, cylinderid, last_sp.mbar, true);
|
||||
lastrecordedtime = newtime;
|
||||
}
|
||||
lasttime = newtime;
|
||||
|
@ -119,7 +122,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
|
|||
}
|
||||
}
|
||||
// make sure we get the last point right so the duration is correct
|
||||
if (!hasMarkedSamples) addStop(0, d->dc.duration.seconds,cylinderid, 0, true);
|
||||
if (!hasMarkedSamples) addStop(0, d->dc.duration.seconds,cylinderid, last_sp.mbar, true);
|
||||
recalc = oldRec;
|
||||
emitDataChanged();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue