mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +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
46
profile.c
46
profile.c
|
@ -422,14 +422,14 @@ struct pr_interpolate_struct {
|
||||||
int start;
|
int start;
|
||||||
int end;
|
int end;
|
||||||
int pressure_time;
|
int pressure_time;
|
||||||
int acc_pressure_time;
|
int acc_pressure_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef DEBUG_PR_INTERPOLATE
|
#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);
|
interpolate_pr.start, interpolate_pr.end, interpolate_pr.pressure_time, interpolate_pr.acc_pressure_time);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ static void fill_missing_segment_pressures(pr_track_t *list)
|
||||||
if (pt_sum)
|
if (pt_sum)
|
||||||
pressure -= (start-end)*(double)pt/pt_sum;
|
pressure -= (start-end)*(double)pt/pt_sum;
|
||||||
list->end = pressure;
|
list->end = pressure;
|
||||||
if (list == tmp)
|
if (list == tmp)
|
||||||
break;
|
break;
|
||||||
list = list->next;
|
list = list->next;
|
||||||
list->start = pressure;
|
list->start = pressure;
|
||||||
|
@ -516,6 +516,9 @@ static inline int pressure_time(struct dive *dive, struct divecomputer *dc, stru
|
||||||
int time = b->sec - a->sec;
|
int time = b->sec - a->sec;
|
||||||
int depth = (a->depth + b->depth)/2;
|
int depth = (a->depth + b->depth)/2;
|
||||||
|
|
||||||
|
if (depth <= SURFACE_THRESHOLD)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return depth_to_mbar(depth, dive) * time;
|
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;
|
struct pr_interpolate_struct interpolate;
|
||||||
int i;
|
int i;
|
||||||
struct plot_data *entry, *cur_entry;
|
struct plot_data *entry;
|
||||||
|
|
||||||
interpolate.start = segment->start;
|
interpolate.start = segment->start;
|
||||||
interpolate.end = segment->end;
|
interpolate.end = segment->end;
|
||||||
interpolate.acc_pressure_time = 0;
|
interpolate.acc_pressure_time = 0;
|
||||||
interpolate.pressure_time = 0;
|
interpolate.pressure_time = 0;
|
||||||
cur_entry = pi->entry + cur;
|
|
||||||
|
|
||||||
for (i = 0; i < pi->nr; i++) {
|
for (i = 0; i < pi->nr; i++) {
|
||||||
entry = pi->entry + 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;
|
interpolate.pressure_time = 0;
|
||||||
if (SENSOR_PRESSURE(entry))
|
if (SENSOR_PRESSURE(entry))
|
||||||
interpolate.start = SENSOR_PRESSURE(entry);
|
interpolate.start = SENSOR_PRESSURE(entry);
|
||||||
} else if (i < cur) {
|
continue;
|
||||||
|
}
|
||||||
|
if (i < cur) {
|
||||||
if (SENSOR_PRESSURE(entry)) {
|
if (SENSOR_PRESSURE(entry)) {
|
||||||
interpolate.start = SENSOR_PRESSURE(entry);
|
interpolate.start = SENSOR_PRESSURE(entry);
|
||||||
interpolate.acc_pressure_time = 0;
|
interpolate.acc_pressure_time = 0;
|
||||||
|
@ -553,15 +557,17 @@ static struct pr_interpolate_struct get_pr_interpolate_data(pr_track_t *segment,
|
||||||
interpolate.acc_pressure_time += entry->pressure_time;
|
interpolate.acc_pressure_time += entry->pressure_time;
|
||||||
interpolate.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.acc_pressure_time += entry->pressure_time;
|
||||||
interpolate.pressure_time += entry->pressure_time;
|
interpolate.pressure_time += entry->pressure_time;
|
||||||
} else {
|
continue;
|
||||||
interpolate.pressure_time += entry->pressure_time;
|
}
|
||||||
if (SENSOR_PRESSURE(entry)) {
|
interpolate.pressure_time += entry->pressure_time;
|
||||||
interpolate.end = SENSOR_PRESSURE(entry);
|
if (SENSOR_PRESSURE(entry)) {
|
||||||
break;
|
interpolate.end = SENSOR_PRESSURE(entry);
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return interpolate;
|
return interpolate;
|
||||||
|
@ -589,7 +595,7 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi,
|
||||||
for (i = 1; i < pi->nr; i++) {
|
for (i = 1; i < pi->nr; i++) {
|
||||||
double magic;
|
double magic;
|
||||||
pr_track_t *segment;
|
pr_track_t *segment;
|
||||||
pr_interpolate_t interpolate;
|
pr_interpolate_t interpolate;
|
||||||
|
|
||||||
entry = pi->entry + i;
|
entry = pi->entry + i;
|
||||||
cyl = entry->cylinderindex;
|
cyl = entry->cylinderindex;
|
||||||
|
@ -599,7 +605,7 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the right pressure segment for this entry.. */
|
/* Find the right pressure segment for this entry.. */
|
||||||
segment = track_pr[cyl];
|
segment = track_pr[cyl];
|
||||||
while (segment && segment->t_end < entry->sec)
|
while (segment && segment->t_end < entry->sec)
|
||||||
segment = segment->next;
|
segment = segment->next;
|
||||||
|
@ -610,9 +616,9 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
interpolate = get_pr_interpolate_data(segment, pi, i);
|
interpolate = get_pr_interpolate_data(segment, pi, i);
|
||||||
#ifdef DEBUG_PR_INTERPOLATE
|
#ifdef DEBUG_PR_INTERPOLATE
|
||||||
dump_pr_interpolate(interpolate);
|
dump_pr_interpolate(i, interpolate);
|
||||||
#endif
|
#endif
|
||||||
/* Overall pressure change over total pressure-time for this segment*/
|
/* Overall pressure change over total pressure-time for this segment*/
|
||||||
magic = (interpolate.end - interpolate.start) / (double) interpolate.pressure_time;
|
magic = (interpolate.end - interpolate.start) / (double) interpolate.pressure_time;
|
||||||
|
@ -969,7 +975,7 @@ static void populate_pressure_information(struct dive *dive, struct divecomputer
|
||||||
|
|
||||||
/* discrete integration of pressure over time to get the SAC rate equivalent */
|
/* discrete integration of pressure over time to get the SAC rate equivalent */
|
||||||
if (current) {
|
if (current) {
|
||||||
entry->pressure_time = pressure_time(dive, dc, entry-1, entry);
|
entry->pressure_time = pressure_time(dive, dc, entry-1, entry);
|
||||||
current->pressure_time += entry->pressure_time;
|
current->pressure_time += entry->pressure_time;
|
||||||
current->t_end = entry->sec;
|
current->t_end = entry->sec;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct plot_data {
|
||||||
int tts_calc;
|
int tts_calc;
|
||||||
int stoptime_calc;
|
int stoptime_calc;
|
||||||
int stopdepth_calc;
|
int stopdepth_calc;
|
||||||
int pressure_time;
|
int pressure_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
void calculate_max_limits(struct dive *dive, struct divecomputer *dc, struct graphics_context *gc);
|
void calculate_max_limits(struct dive *dive, struct divecomputer *dc, struct graphics_context *gc);
|
||||||
|
|
Loading…
Reference in a new issue