Modify SST_GetSelectionData to return only necessary data
This commit is contained in:
parent
9666831818
commit
22e5ed44c2
3 changed files with 28 additions and 37 deletions
17
sources.c
17
sources.c
|
@ -56,10 +56,7 @@ struct SelectInfo {
|
||||||
int stratum;
|
int stratum;
|
||||||
int select_ok;
|
int select_ok;
|
||||||
double variance;
|
double variance;
|
||||||
double root_delay;
|
|
||||||
double root_dispersion;
|
|
||||||
double root_distance;
|
double root_distance;
|
||||||
double best_offset;
|
|
||||||
double lo_limit;
|
double lo_limit;
|
||||||
double hi_limit;
|
double hi_limit;
|
||||||
};
|
};
|
||||||
|
@ -541,20 +538,16 @@ SRC_SelectSource(uint32_t match_refid)
|
||||||
si = &(sources[i]->sel_info);
|
si = &(sources[i]->sel_info);
|
||||||
SST_GetSelectionData(sources[i]->stats, &now,
|
SST_GetSelectionData(sources[i]->stats, &now,
|
||||||
&(si->stratum),
|
&(si->stratum),
|
||||||
&(si->best_offset),
|
&(si->lo_limit),
|
||||||
&(si->root_delay),
|
&(si->hi_limit),
|
||||||
&(si->root_dispersion),
|
&(si->root_distance),
|
||||||
&(si->variance),
|
&(si->variance),
|
||||||
&(si->select_ok));
|
&(si->select_ok));
|
||||||
|
|
||||||
si->root_distance = si->root_dispersion + 0.5 * si->root_delay;
|
|
||||||
si->lo_limit = si->best_offset - si->root_distance;
|
|
||||||
si->hi_limit = si->best_offset + si->root_distance;
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
LOG(LOGS_INFO, LOGF_Sources, "%s off=%f dist=%f lo=%f hi=%f",
|
LOG(LOGS_INFO, LOGF_Sources, "%s dist=%f lo=%f hi=%f",
|
||||||
source_to_string(sources[i]),
|
source_to_string(sources[i]),
|
||||||
si->best_offset, si->root_distance,
|
si->root_distance,
|
||||||
si->lo_limit, si->hi_limit);
|
si->lo_limit, si->hi_limit);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -514,21 +514,16 @@ SST_GetFrequencyRange(SST_Stats inst,
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SST_GetSelectionData(SST_Stats inst, struct timeval *now,
|
SST_GetSelectionData(SST_Stats inst, struct timeval *now,
|
||||||
int *stratum,
|
int *stratum,
|
||||||
double *best_offset, double *best_root_delay,
|
double *offset_lo_limit,
|
||||||
double *best_root_dispersion,
|
double *offset_hi_limit,
|
||||||
|
double *root_distance,
|
||||||
double *variance, int *select_ok)
|
double *variance, int *select_ok)
|
||||||
{
|
{
|
||||||
double average_offset;
|
double offset, sample_elapsed;
|
||||||
double sample_elapsed;
|
|
||||||
double elapsed;
|
|
||||||
int i, j;
|
int i, j;
|
||||||
int average_ok;
|
|
||||||
double peer_distance;
|
|
||||||
|
|
||||||
i = get_runsbuf_index(inst, inst->best_single_sample);
|
i = get_runsbuf_index(inst, inst->best_single_sample);
|
||||||
j = get_buf_index(inst, inst->best_single_sample);
|
j = get_buf_index(inst, inst->best_single_sample);
|
||||||
|
@ -536,30 +531,33 @@ SST_GetSelectionData(SST_Stats inst, struct timeval *now,
|
||||||
*stratum = inst->strata[get_buf_index(inst, inst->n_samples - 1)];
|
*stratum = inst->strata[get_buf_index(inst, inst->n_samples - 1)];
|
||||||
*variance = inst->variance;
|
*variance = inst->variance;
|
||||||
|
|
||||||
peer_distance = inst->peer_dispersions[j] + 0.5 * inst->peer_delays[j];
|
|
||||||
UTI_DiffTimevalsToDouble(&elapsed, now, &(inst->offset_time));
|
|
||||||
|
|
||||||
UTI_DiffTimevalsToDouble(&sample_elapsed, now, &inst->sample_times[i]);
|
UTI_DiffTimevalsToDouble(&sample_elapsed, now, &inst->sample_times[i]);
|
||||||
*best_offset = inst->offsets[i] + sample_elapsed * inst->estimated_frequency;
|
offset = inst->offsets[i] + sample_elapsed * inst->estimated_frequency;
|
||||||
*best_root_delay = inst->root_delays[j];
|
*root_distance = 0.5 * inst->root_delays[j] +
|
||||||
*best_root_dispersion = inst->root_dispersions[j] + sample_elapsed * inst->skew;
|
inst->root_dispersions[j] + sample_elapsed * inst->skew;
|
||||||
|
|
||||||
|
*offset_lo_limit = offset - *root_distance;
|
||||||
|
*offset_hi_limit = offset + *root_distance;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
double average_offset, elapsed;
|
||||||
|
int average_ok;
|
||||||
/* average_ok ignored for now */
|
/* average_ok ignored for now */
|
||||||
|
UTI_DiffTimevalsToDouble(&elapsed, now, &(inst->offset_time));
|
||||||
average_offset = inst->estimated_offset + inst->estimated_frequency * elapsed;
|
average_offset = inst->estimated_offset + inst->estimated_frequency * elapsed;
|
||||||
if (fabs(average_offset - *best_offset) <= peer_distance) {
|
if (fabs(average_offset - offset) <=
|
||||||
|
inst->peer_dispersions[j] + 0.5 * inst->peer_delays[j]) {
|
||||||
average_ok = 1;
|
average_ok = 1;
|
||||||
} else {
|
} else {
|
||||||
average_ok = 0;
|
average_ok = 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
*select_ok = inst->regression_ok;
|
*select_ok = inst->regression_ok;
|
||||||
|
|
||||||
#ifdef TRACEON
|
#ifdef TRACEON
|
||||||
LOG(LOGS_INFO, LOGF_SourceStats, "n=%d off=%f del=%f dis=%f var=%f pdist=%f avoff=%f avok=%d selok=%d",
|
LOG(LOGS_INFO, LOGF_SourceStats, "n=%d off=%f dist=%f var=%f selok=%d",
|
||||||
inst->n_samples, *best_offset, *best_root_delay, *best_root_dispersion, *variance,
|
inst->n_samples, offset, *root_distance, *variance, *select_ok);
|
||||||
peer_distance, average_offset, average_ok, *select_ok);
|
|
||||||
#else
|
|
||||||
(void)average_ok;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,10 +82,10 @@ extern void SST_GetFrequencyRange(SST_Stats inst, double *lo, double *hi);
|
||||||
extern void
|
extern void
|
||||||
SST_GetSelectionData(SST_Stats inst, struct timeval *now,
|
SST_GetSelectionData(SST_Stats inst, struct timeval *now,
|
||||||
int *stratum,
|
int *stratum,
|
||||||
double *best_offset, double *best_root_delay,
|
double *offset_lo_limit,
|
||||||
double *best_root_dispersion,
|
double *offset_hi_limit,
|
||||||
double *variance,
|
double *root_distance,
|
||||||
int *select_ok);
|
double *variance, int *select_ok);
|
||||||
|
|
||||||
/* Get data needed when setting up tracking on this source */
|
/* Get data needed when setting up tracking on this source */
|
||||||
extern void
|
extern void
|
||||||
|
|
Loading…
Reference in a new issue