mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Reinstating SURFACE_THRESHOLD test in pressure_time function
The small straight parts at the end of tank pressure lines are more of a aesthetic issue, not causing real harm so it is no reason to remove the SURFACE_THRESHOLD test from pressure_time function only because of this. Also improved interpolate data debuging, rearranged get_pr_interpolate_data and removed an unused variable from get_pr_interpolate_data. No real change here, just trying to make the code clearer. [Dirk Hohndel: clean up whitespace damage from this and the previous commit] Signed-off-by: Rodrigo Severo <rodrigo@fabricadeideias.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
8f0c8be245
commit
eec5dba1c2
2 changed files with 27 additions and 21 deletions
24
profile.c
24
profile.c
|
@ -426,9 +426,9 @@ struct pr_interpolate_struct {
|
|||
};
|
||||
|
||||
#ifdef DEBUG_PR_INTERPOLATE
|
||||
static void dump_pr_interpolate(pr_interpolate_t interpolate_pr)
|
||||
static void dump_pr_interpolate(int i, pr_interpolate_t interpolate_pr)
|
||||
{
|
||||
printf("INTERPOLATE: start %d - end %d - pt %d - acc_pt %d\n",
|
||||
printf("Interpolate for entry %d: start %d - end %d - pt %d - acc_pt %d\n", i,
|
||||
interpolate_pr.start, interpolate_pr.end, interpolate_pr.pressure_time, interpolate_pr.acc_pressure_time);
|
||||
}
|
||||
#endif
|
||||
|
@ -516,6 +516,9 @@ static inline int pressure_time(struct dive *dive, struct divecomputer *dc, stru
|
|||
int time = b->sec - a->sec;
|
||||
int depth = (a->depth + b->depth)/2;
|
||||
|
||||
if (depth <= SURFACE_THRESHOLD)
|
||||
return 0;
|
||||
|
||||
return depth_to_mbar(depth, dive) * time;
|
||||
}
|
||||
|
||||
|
@ -523,13 +526,12 @@ static struct pr_interpolate_struct get_pr_interpolate_data(pr_track_t *segment,
|
|||
{
|
||||
struct pr_interpolate_struct interpolate;
|
||||
int i;
|
||||
struct plot_data *entry, *cur_entry;
|
||||
struct plot_data *entry;
|
||||
|
||||
interpolate.start = segment->start;
|
||||
interpolate.end = segment->end;
|
||||
interpolate.acc_pressure_time = 0;
|
||||
interpolate.pressure_time = 0;
|
||||
cur_entry = pi->entry + cur;
|
||||
|
||||
for (i = 0; i < pi->nr; i++) {
|
||||
entry = pi->entry + i;
|
||||
|
@ -544,7 +546,9 @@ static struct pr_interpolate_struct get_pr_interpolate_data(pr_track_t *segment,
|
|||
interpolate.pressure_time = 0;
|
||||
if (SENSOR_PRESSURE(entry))
|
||||
interpolate.start = SENSOR_PRESSURE(entry);
|
||||
} else if (i < cur) {
|
||||
continue;
|
||||
}
|
||||
if (i < cur) {
|
||||
if (SENSOR_PRESSURE(entry)) {
|
||||
interpolate.start = SENSOR_PRESSURE(entry);
|
||||
interpolate.acc_pressure_time = 0;
|
||||
|
@ -553,17 +557,19 @@ static struct pr_interpolate_struct get_pr_interpolate_data(pr_track_t *segment,
|
|||
interpolate.acc_pressure_time += entry->pressure_time;
|
||||
interpolate.pressure_time += entry->pressure_time;
|
||||
}
|
||||
} else if (i == cur) {
|
||||
continue;
|
||||
}
|
||||
if (i == cur) {
|
||||
interpolate.acc_pressure_time += entry->pressure_time;
|
||||
interpolate.pressure_time += entry->pressure_time;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
interpolate.pressure_time += entry->pressure_time;
|
||||
if (SENSOR_PRESSURE(entry)) {
|
||||
interpolate.end = SENSOR_PRESSURE(entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return interpolate;
|
||||
}
|
||||
|
||||
|
@ -612,7 +618,7 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi,
|
|||
|
||||
interpolate = get_pr_interpolate_data(segment, pi, i);
|
||||
#ifdef DEBUG_PR_INTERPOLATE
|
||||
dump_pr_interpolate(interpolate);
|
||||
dump_pr_interpolate(i, interpolate);
|
||||
#endif
|
||||
/* Overall pressure change over total pressure-time for this segment*/
|
||||
magic = (interpolate.end - interpolate.start) / (double) interpolate.pressure_time;
|
||||
|
|
Loading…
Reference in a new issue