Fix adaptive gain stats not getting set on stats_current -> zeros
appearing in stats output. Now we have a validity flag for the stats members where we have to pick one value and not simply sum data.
This commit is contained in:
parent
b3172181d5
commit
fd8f2d77e1
|
|
@ -399,6 +399,7 @@ static void adaptive_end_of_block()
|
||||||
adaptive_burst_control_update();
|
adaptive_burst_control_update();
|
||||||
adaptive_range_control_update();
|
adaptive_range_control_update();
|
||||||
|
|
||||||
|
Modes.stats_current.adaptive_valid = true;
|
||||||
unsigned current = Modes.stats_current.adaptive_gain = sdrGetGain();
|
unsigned current = Modes.stats_current.adaptive_gain = sdrGetGain();
|
||||||
++Modes.stats_current.adaptive_gain_seconds[current < STATS_GAIN_COUNT ? current : STATS_GAIN_COUNT-1];
|
++Modes.stats_current.adaptive_gain_seconds[current < STATS_GAIN_COUNT ? current : STATS_GAIN_COUNT-1];
|
||||||
if (adaptive_burst_suppressing)
|
if (adaptive_burst_suppressing)
|
||||||
|
|
|
||||||
5
net_io.c
5
net_io.c
|
|
@ -1859,6 +1859,7 @@ static char * appendStatsJson(char *p,
|
||||||
}
|
}
|
||||||
p = safe_snprintf(p, end, "]");
|
p = safe_snprintf(p, end, "]");
|
||||||
|
|
||||||
|
if (st->adaptive_valid) {
|
||||||
p = safe_snprintf(p, end,
|
p = safe_snprintf(p, end,
|
||||||
",\"adaptive\":"
|
",\"adaptive\":"
|
||||||
"{\"gain_db\":%.1f"
|
"{\"gain_db\":%.1f"
|
||||||
|
|
@ -1881,7 +1882,9 @@ static char * appendStatsJson(char *p,
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p = safe_snprintf(p, end, "]}}");
|
p = safe_snprintf(p, end, "]}");
|
||||||
|
}
|
||||||
|
p = safe_snprintf(p, end, "}");
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
18
stats.c
18
stats.c
|
|
@ -115,7 +115,7 @@ void display_stats(struct stats *st) {
|
||||||
st->strong_signal_count);
|
st->strong_signal_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Modes.adaptive_burst_control || Modes.adaptive_range_control) {
|
if (st->adaptive_valid) {
|
||||||
printf("Adaptive gain:\n"
|
printf("Adaptive gain:\n"
|
||||||
" %5u loud undecoded bursts\n"
|
" %5u loud undecoded bursts\n"
|
||||||
" %5u loud decoded messages\n"
|
" %5u loud decoded messages\n"
|
||||||
|
|
@ -315,7 +315,7 @@ void add_stats(const struct stats *st1, const struct stats *st2, struct stats *t
|
||||||
target->start = st2->start;
|
target->start = st2->start;
|
||||||
|
|
||||||
const struct stats *newer;
|
const struct stats *newer;
|
||||||
if (st1->end > st2->end) {
|
if (st1->end > st2->end || (st1->end == st2->end && st1->start > st2->start)) {
|
||||||
newer = st1;
|
newer = st1;
|
||||||
} else {
|
} else {
|
||||||
newer = st2;
|
newer = st2;
|
||||||
|
|
@ -395,11 +395,21 @@ void add_stats(const struct stats *st1, const struct stats *st2, struct stats *t
|
||||||
target->range_histogram[i] = st1->range_histogram[i] + st2->range_histogram[i];
|
target->range_histogram[i] = st1->range_histogram[i] + st2->range_histogram[i];
|
||||||
|
|
||||||
// adaptive gain measurements
|
// adaptive gain measurements
|
||||||
target->adaptive_gain = newer->adaptive_gain;
|
|
||||||
|
const struct stats *adaptive_best;
|
||||||
|
if (st1->adaptive_valid && st2->adaptive_valid)
|
||||||
|
adaptive_best = newer;
|
||||||
|
else if (st1->adaptive_valid)
|
||||||
|
adaptive_best = st1;
|
||||||
|
else
|
||||||
|
adaptive_best = st2;
|
||||||
|
|
||||||
|
target->adaptive_valid = adaptive_best->adaptive_valid;
|
||||||
|
target->adaptive_gain = adaptive_best->adaptive_gain;
|
||||||
for (unsigned i = 0; i < STATS_GAIN_COUNT; ++i)
|
for (unsigned i = 0; i < STATS_GAIN_COUNT; ++i)
|
||||||
target->adaptive_gain_seconds[i] = st1->adaptive_gain_seconds[i] + st2->adaptive_gain_seconds[i];
|
target->adaptive_gain_seconds[i] = st1->adaptive_gain_seconds[i] + st2->adaptive_gain_seconds[i];
|
||||||
target->adaptive_gain_reduced_seconds = st1->adaptive_gain_reduced_seconds + st2->adaptive_gain_reduced_seconds;
|
target->adaptive_gain_reduced_seconds = st1->adaptive_gain_reduced_seconds + st2->adaptive_gain_reduced_seconds;
|
||||||
target->adaptive_loud_undecoded = st1->adaptive_loud_undecoded + st2->adaptive_loud_undecoded;
|
target->adaptive_loud_undecoded = st1->adaptive_loud_undecoded + st2->adaptive_loud_undecoded;
|
||||||
target->adaptive_loud_decoded = st1->adaptive_loud_decoded + st2->adaptive_loud_decoded;
|
target->adaptive_loud_decoded = st1->adaptive_loud_decoded + st2->adaptive_loud_decoded;
|
||||||
target->adaptive_noise_dbfs = newer->adaptive_noise_dbfs;
|
target->adaptive_noise_dbfs = adaptive_best->adaptive_noise_dbfs;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
stats.h
3
stats.h
|
|
@ -132,7 +132,8 @@ struct stats {
|
||||||
|
|
||||||
// adaptive gain measurements
|
// adaptive gain measurements
|
||||||
#define STATS_GAIN_COUNT 64
|
#define STATS_GAIN_COUNT 64
|
||||||
unsigned adaptive_gain; // Current gain step in use
|
bool adaptive_valid; // is the following data valid?
|
||||||
|
int adaptive_gain; // Current gain step in use
|
||||||
uint32_t adaptive_gain_seconds[STATS_GAIN_COUNT]; // Seconds spent at each gain step
|
uint32_t adaptive_gain_seconds[STATS_GAIN_COUNT]; // Seconds spent at each gain step
|
||||||
uint32_t adaptive_gain_reduced_seconds; // Seconds spent at a reduced gain due to burst detection
|
uint32_t adaptive_gain_reduced_seconds; // Seconds spent at a reduced gain due to burst detection
|
||||||
uint32_t adaptive_loud_undecoded; // Total number of loud, undecoded bursts
|
uint32_t adaptive_loud_undecoded; // Total number of loud, undecoded bursts
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue