mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Only do 9 minute interval for min/max/avg
We don't use 3 and 6 minute values anywhere, so why calculate them. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e0ac1c9a26
commit
eb07faef00
4 changed files with 24 additions and 31 deletions
|
@ -21,7 +21,7 @@ struct plot_info {
|
||||||
int minpressure, maxpressure;
|
int minpressure, maxpressure;
|
||||||
int minhr, maxhr;
|
int minhr, maxhr;
|
||||||
int mintemp, maxtemp;
|
int mintemp, maxtemp;
|
||||||
enum {AIR, NITROX, TRIMIX, FREEDIVING} dive_type;
|
enum {AIR, NITROX, TRIMIX, FREEDIVING} dive_type;
|
||||||
double endtempcoord;
|
double endtempcoord;
|
||||||
double maxpp;
|
double maxpp;
|
||||||
bool has_ndl;
|
bool has_ndl;
|
||||||
|
|
|
@ -196,37 +196,37 @@ static int get_local_sac(struct plot_data *entry1, struct plot_data *entry2, str
|
||||||
return airuse / atm * 60 / duration;
|
return airuse / atm * 60 / duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define HALF_INTERVAL 9 * 30
|
||||||
/*
|
/*
|
||||||
* We do three min/max/avg calculations: over 3, 6 and 9 minutes
|
* Run the min/max calculations: over a 9 minute interval
|
||||||
* around the entry point (indices 0, 1, 2 respectively).
|
* around the entry point (indices 0, 1, 2 respectively).
|
||||||
*/
|
*/
|
||||||
static void analyze_plot_info_minmax_minute(struct plot_info *pi, int entry, int index)
|
static void analyze_plot_info_minmax(struct plot_info *pi, int entry_index)
|
||||||
{
|
{
|
||||||
struct plot_data *plot_entry = pi->entry + entry; // fixed
|
struct plot_data *plot_entry = pi->entry + entry_index; // fixed
|
||||||
struct plot_data *p = plot_entry; // moves with 'entry'
|
struct plot_data *p = plot_entry; // moves with 'entry'
|
||||||
int seconds = 90 * (index + 1);
|
int start = p->sec - HALF_INTERVAL, end = p->sec + HALF_INTERVAL;
|
||||||
int start = p->sec - seconds, end = p->sec + seconds;
|
|
||||||
int min, max;
|
int min, max;
|
||||||
int firsttime, lasttime, lastdepth;
|
int firsttime, lasttime, lastdepth;
|
||||||
int depth_time_2;
|
int depth_time_2;
|
||||||
|
|
||||||
/* Go back 'seconds' in time */
|
/* Go back 'seconds' in time */
|
||||||
while (entry > 0) {
|
while (entry_index > 0) {
|
||||||
if (p[-1].sec < start)
|
if (p[-1].sec < start)
|
||||||
break;
|
break;
|
||||||
entry--;
|
entry_index--;
|
||||||
p--;
|
p--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// indexes to the min/max entries
|
// indexes to the min/max entries
|
||||||
min = max = entry;
|
min = max = entry_index;
|
||||||
// accumulated depth*time*2
|
// accumulated depth*time*2
|
||||||
depth_time_2 = 0;
|
depth_time_2 = 0;
|
||||||
firsttime = lasttime = p->sec;
|
firsttime = lasttime = p->sec;
|
||||||
lastdepth = p->depth;
|
lastdepth = p->depth;
|
||||||
|
|
||||||
/* Then go forward until we hit an entry past the time */
|
/* Then go forward until we hit an entry past the time */
|
||||||
while (entry < pi->nr) {
|
while (entry_index < pi->nr) {
|
||||||
int time = p->sec;
|
int time = p->sec;
|
||||||
int depth = p->depth;
|
int depth = p->depth;
|
||||||
|
|
||||||
|
@ -238,27 +238,20 @@ static void analyze_plot_info_minmax_minute(struct plot_info *pi, int entry, int
|
||||||
lastdepth = depth;
|
lastdepth = depth;
|
||||||
|
|
||||||
if (depth < pi->entry[min].depth)
|
if (depth < pi->entry[min].depth)
|
||||||
min = entry;
|
min = entry_index;
|
||||||
if (depth > pi->entry[max].depth)
|
if (depth > pi->entry[max].depth)
|
||||||
max = entry;
|
max = entry_index;
|
||||||
|
|
||||||
p++;
|
p++;
|
||||||
entry++;
|
entry_index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
plot_entry->min[index] = min;
|
plot_entry->min = min;
|
||||||
plot_entry->max[index] = max;
|
plot_entry->max = max;
|
||||||
if (firsttime == lasttime)
|
if (firsttime == lasttime)
|
||||||
plot_entry->avg[index] = pi->entry[min].depth;
|
plot_entry->avg = pi->entry[min].depth;
|
||||||
else
|
else
|
||||||
plot_entry->avg[index] = depth_time_2 / 2 / (lasttime - firsttime);
|
plot_entry->avg = depth_time_2 / 2 / (lasttime - firsttime);
|
||||||
}
|
|
||||||
|
|
||||||
static void analyze_plot_info_minmax(struct plot_info *pi, int entry)
|
|
||||||
{
|
|
||||||
analyze_plot_info_minmax_minute(pi, entry, 0);
|
|
||||||
analyze_plot_info_minmax_minute(pi, entry, 1);
|
|
||||||
analyze_plot_info_minmax_minute(pi, entry, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static velocity_t velocity(int speed)
|
static velocity_t velocity(int speed)
|
||||||
|
@ -322,7 +315,7 @@ struct plot_info *analyze_plot_info(struct plot_info *pi)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 3, 6 and 9-minute minmax data */
|
/* get minmax data */
|
||||||
for (i = 0; i < nr; i++)
|
for (i = 0; i < nr; i++)
|
||||||
analyze_plot_info_minmax(pi, i);
|
analyze_plot_info_minmax(pi, i);
|
||||||
|
|
||||||
|
|
|
@ -50,9 +50,9 @@ struct plot_data {
|
||||||
double mod, ead, end, eadd;
|
double mod, ead, end, eadd;
|
||||||
velocity_t velocity;
|
velocity_t velocity;
|
||||||
int speed;
|
int speed;
|
||||||
// stats over 3, 6, 9 minute windows:
|
// stats over 9 minute window:
|
||||||
int min[3], max[3]; // indices into pi->entry[]
|
int min, max; // indices into pi->entry[]
|
||||||
int avg[3]; // actual depth average
|
int avg; // actual depth average
|
||||||
/* values calculated by us */
|
/* values calculated by us */
|
||||||
unsigned int in_deco_calc : 1;
|
unsigned int in_deco_calc : 1;
|
||||||
int ndl_calc;
|
int ndl_calc;
|
||||||
|
|
|
@ -227,9 +227,9 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI
|
||||||
for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
|
for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
|
||||||
struct plot_data *pd = dataModel->data().entry;
|
struct plot_data *pd = dataModel->data().entry;
|
||||||
struct plot_data *entry = pd + i;
|
struct plot_data *entry = pd + i;
|
||||||
// "min/max[2]" are the 9-minute window min/max indices
|
// "min/max" are the 9-minute window min/max indices
|
||||||
struct plot_data *min_entry = pd + entry->min[2];
|
struct plot_data *min_entry = pd + entry->min;
|
||||||
struct plot_data *max_entry = pd + entry->max[2];
|
struct plot_data *max_entry = pd + entry->max;
|
||||||
|
|
||||||
if (entry->depth < 2000)
|
if (entry->depth < 2000)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Reference in a new issue