local: replace is_step_change parameter of change handler with enum
Prepare for a new change type that will be added later.
This commit is contained in:
parent
b69b648d18
commit
44c9744d69
10 changed files with 32 additions and 26 deletions
14
local.c
14
local.c
|
@ -251,12 +251,12 @@ void LCL_RemoveParameterChangeHandler(LCL_ParameterChangeHandler handler, void *
|
|||
static void
|
||||
invoke_parameter_change_handlers(struct timeval *raw, struct timeval *cooked,
|
||||
double dfreq, double doffset,
|
||||
int is_step_change)
|
||||
LCL_ChangeType change_type)
|
||||
{
|
||||
ChangeListEntry *ptr;
|
||||
|
||||
for (ptr = change_list.next; ptr != &change_list; ptr = ptr->next) {
|
||||
(ptr->handler)(raw, cooked, dfreq, doffset, is_step_change, ptr->anything);
|
||||
(ptr->handler)(raw, cooked, dfreq, doffset, change_type, ptr->anything);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,7 +401,7 @@ LCL_SetAbsoluteFrequency(double afreq_ppm)
|
|||
LCL_CookTime(&raw, &cooked, NULL);
|
||||
|
||||
/* Dispatch to all handlers */
|
||||
invoke_parameter_change_handlers(&raw, &cooked, dfreq, 0.0, 0);
|
||||
invoke_parameter_change_handlers(&raw, &cooked, dfreq, 0.0, LCL_ChangeAdjust);
|
||||
|
||||
current_freq_ppm = afreq_ppm;
|
||||
|
||||
|
@ -431,7 +431,7 @@ LCL_AccumulateDeltaFrequency(double dfreq)
|
|||
LCL_CookTime(&raw, &cooked, NULL);
|
||||
|
||||
/* Dispatch to all handlers */
|
||||
invoke_parameter_change_handlers(&raw, &cooked, dfreq, 0.0, 0);
|
||||
invoke_parameter_change_handlers(&raw, &cooked, dfreq, 0.0, LCL_ChangeAdjust);
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
@ -450,7 +450,7 @@ LCL_AccumulateOffset(double offset, double corr_rate)
|
|||
(*drv_accrue_offset)(offset, corr_rate);
|
||||
|
||||
/* Dispatch to all handlers */
|
||||
invoke_parameter_change_handlers(&raw, &cooked, 0.0, offset, 0);
|
||||
invoke_parameter_change_handlers(&raw, &cooked, 0.0, offset, LCL_ChangeAdjust);
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
@ -469,7 +469,7 @@ LCL_ApplyStepOffset(double offset)
|
|||
(*drv_apply_step_offset)(offset);
|
||||
|
||||
/* Dispatch to all handlers */
|
||||
invoke_parameter_change_handlers(&raw, &cooked, 0.0, offset, 1);
|
||||
invoke_parameter_change_handlers(&raw, &cooked, 0.0, offset, LCL_ChangeStep);
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
@ -479,7 +479,7 @@ LCL_NotifyExternalTimeStep(struct timeval *raw, struct timeval *cooked,
|
|||
double offset, double dispersion)
|
||||
{
|
||||
/* Dispatch to all handlers */
|
||||
invoke_parameter_change_handlers(raw, cooked, 0.0, offset, 1);
|
||||
invoke_parameter_change_handlers(raw, cooked, 0.0, offset, LCL_ChangeStep);
|
||||
|
||||
lcl_InvokeDispersionNotifyHandlers(dispersion);
|
||||
}
|
||||
|
|
11
local.h
11
local.h
|
@ -67,16 +67,21 @@ extern void LCL_GetOffsetCorrection(struct timeval *raw, double *correction, dou
|
|||
doffset : delta offset applied (positive => make local system fast
|
||||
by that amount, negative => make it slow by that amount)
|
||||
|
||||
is_step_change : true if change is being applied as a jump (using
|
||||
settimeofday rather than adjtime)
|
||||
change_type : what type of change is being applied
|
||||
|
||||
anything : Passthrough argument from call to registration routine */
|
||||
|
||||
|
||||
typedef enum {
|
||||
LCL_ChangeAdjust,
|
||||
LCL_ChangeStep
|
||||
} LCL_ChangeType;
|
||||
|
||||
typedef void (*LCL_ParameterChangeHandler)
|
||||
(struct timeval *raw, struct timeval *cooked,
|
||||
double dfreq,
|
||||
double doffset, int is_step_change,
|
||||
double doffset,
|
||||
LCL_ChangeType change_type,
|
||||
void *anything
|
||||
);
|
||||
|
||||
|
|
4
manual.c
4
manual.c
|
@ -66,7 +66,7 @@ slew_samples(struct timeval *raw,
|
|||
struct timeval *cooked,
|
||||
double dfreq,
|
||||
double doffset,
|
||||
int is_step_change,
|
||||
LCL_ChangeType change_type,
|
||||
void *not_used);
|
||||
|
||||
/* ================================================== */
|
||||
|
@ -216,7 +216,7 @@ slew_samples(struct timeval *raw,
|
|||
struct timeval *cooked,
|
||||
double dfreq,
|
||||
double doffset,
|
||||
int is_step_change,
|
||||
LCL_ChangeType change_type,
|
||||
void *not_used)
|
||||
{
|
||||
double delta_time;
|
||||
|
|
|
@ -94,7 +94,7 @@ slew_sources(struct timeval *raw,
|
|||
struct timeval *cooked,
|
||||
double dfreq,
|
||||
double doffset,
|
||||
int is_step_change,
|
||||
LCL_ChangeType change_type,
|
||||
void *anything);
|
||||
|
||||
/* ================================================== */
|
||||
|
@ -479,7 +479,7 @@ slew_sources(struct timeval *raw,
|
|||
struct timeval *cooked,
|
||||
double dfreq,
|
||||
double doffset,
|
||||
int is_step_change,
|
||||
LCL_ChangeType change_type,
|
||||
void *anything)
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -97,7 +97,7 @@ static int valid_sample_time(RCL_Instance instance, struct timeval *tv);
|
|||
static int pps_stratum(RCL_Instance instance, struct timeval *tv);
|
||||
static void poll_timeout(void *arg);
|
||||
static void slew_samples(struct timeval *raw, struct timeval *cooked, double dfreq,
|
||||
double doffset, int is_step_change, void *anything);
|
||||
double doffset, LCL_ChangeType change_type, void *anything);
|
||||
static void add_dispersion(double dispersion, void *anything);
|
||||
static void log_sample(RCL_Instance instance, struct timeval *sample_time, int filtered, int pulse, double raw_offset, double cooked_offset, double dispersion);
|
||||
|
||||
|
@ -577,7 +577,7 @@ poll_timeout(void *arg)
|
|||
|
||||
static void
|
||||
slew_samples(struct timeval *raw, struct timeval *cooked, double dfreq,
|
||||
double doffset, int is_step_change, void *anything)
|
||||
double doffset, LCL_ChangeType change_type, void *anything)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -144,10 +144,10 @@ handle_slew(struct timeval *raw,
|
|||
struct timeval *cooked,
|
||||
double dfreq,
|
||||
double doffset,
|
||||
int is_step_change,
|
||||
LCL_ChangeType change_type,
|
||||
void *anything)
|
||||
{
|
||||
if (is_step_change) {
|
||||
if (change_type == LCL_ChangeStep) {
|
||||
UTI_AddDoubleToTimeval(&last_ref_update, -doffset, &last_ref_update);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -265,7 +265,8 @@ static void
|
|||
slew_samples
|
||||
(struct timeval *raw, struct timeval *cooked,
|
||||
double dfreq,
|
||||
double doffset, int is_step_change,
|
||||
double doffset,
|
||||
LCL_ChangeType change_type,
|
||||
void *anything)
|
||||
{
|
||||
int i;
|
||||
|
|
6
sched.c
6
sched.c
|
@ -123,7 +123,7 @@ handle_slew(struct timeval *raw,
|
|||
struct timeval *cooked,
|
||||
double dfreq,
|
||||
double doffset,
|
||||
int is_step_change,
|
||||
LCL_ChangeType change_type,
|
||||
void *anything);
|
||||
|
||||
/* ================================================== */
|
||||
|
@ -503,14 +503,14 @@ handle_slew(struct timeval *raw,
|
|||
struct timeval *cooked,
|
||||
double dfreq,
|
||||
double doffset,
|
||||
int is_step_change,
|
||||
LCL_ChangeType change_type,
|
||||
void *anything)
|
||||
{
|
||||
TimerQueueEntry *ptr;
|
||||
double delta;
|
||||
int i;
|
||||
|
||||
if (is_step_change) {
|
||||
if (change_type != LCL_ChangeAdjust) {
|
||||
/* If a step change occurs, just shift all raw time stamps by the offset */
|
||||
|
||||
for (ptr = timer_queue.next; ptr != &timer_queue; ptr = ptr->next) {
|
||||
|
|
|
@ -154,7 +154,7 @@ static double combine_limit;
|
|||
|
||||
static void
|
||||
slew_sources(struct timeval *raw, struct timeval *cooked, double dfreq,
|
||||
double doffset, int is_step_change, void *anything);
|
||||
double doffset, LCL_ChangeType change_type, void *anything);
|
||||
static void
|
||||
add_dispersion(double dispersion, void *anything);
|
||||
static char *
|
||||
|
@ -1087,7 +1087,7 @@ slew_sources(struct timeval *raw,
|
|||
struct timeval *cooked,
|
||||
double dfreq,
|
||||
double doffset,
|
||||
int is_step_change,
|
||||
LCL_ChangeType change_type,
|
||||
void *anything)
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -93,9 +93,9 @@ static void handle_end_of_slew(void *anything);
|
|||
|
||||
static void
|
||||
handle_step(struct timeval *raw, struct timeval *cooked, double dfreq,
|
||||
double doffset, int is_step_change, void *anything)
|
||||
double doffset, LCL_ChangeType change_type, void *anything)
|
||||
{
|
||||
if (is_step_change)
|
||||
if (change_type == LCL_ChangeStep)
|
||||
UTI_AddDoubleToTimeval(&slew_start, -doffset, &slew_start);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue