Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn hard coded values into parameters. #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion main_sim_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ simfile_readline(struct ocx *ocx, struct todolist *tdl, void *priv)
u1 -= sf->t0;
TS_Nanosec(&sf->when, u1, u2);
dt = TS_Diff(&sf->when, &t0);
if (dt >= 1e-3) {
if (dt >= param_sim_min_sched) {
TODO_ScheduleAbs(tdl, simfile_readline, priv,
&sf->when, 0.0, "Readline");
return (TODO_OK);
Expand Down
3 changes: 1 addition & 2 deletions ntp_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ nf_filter(struct ocx *ocx, const struct ntp_peer *np)
}

// This is almost never a good sign.
if (r > 2048) {
/* XXX: 2048 -> param */
if (r > param_ntp_filter_ancient) {
Put(ocx, OCX_TRACE, "NF ancient ref %.3e\n", r);
return;
}
Expand Down
40 changes: 38 additions & 2 deletions param_tbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
/* name, min, max, default, docs */

#ifdef PARAM_CLIENT
PARAM_CLIENT(poll_rate, 16.0, 4096.0, 64.0, "")
PARAM_CLIENT(foo, 16.0, 4096.0, 64.0, "")
PARAM_CLIENT(poll_rate, 16.0, 4096.0, 64.0, "Client poll rate")
PARAM_CLIENT(sim_min_sched,
1e-6, 1e-2, 1e-3,
"Minimum delay before simulator scheduling")
#endif

#ifdef PARAM_NTP_FILTER
Expand All @@ -60,6 +62,14 @@ PARAM_NTP_FILTER(ntp_filter_threshold,
" Setting it too low throws away adequate timestamps."
)

PARAM_NTP_FILTER(ntp_filter_ancient,
256, 4096, 2048,
"Packet delays exceeding the average by this amount are too old."
" These events are logged."
" Setting this too high and the clock may become erratic."
" Setting it too low throws away useful timestamps."
)

#endif

/**********************************************************************
Expand Down Expand Up @@ -109,6 +119,32 @@ PARAM_PLL_STD(pll_std_p_limit,
" Increasing this makes the PLL more agile and prone to noise."
)

PARAM_PLL_STD(pll_std_mode1_step,
1e-6, 3e2, 1e-3,
"Treshold for stepping clock at startup.\n\n"
"Reducing this will step the clock at smaller errors."
" Increasing this makes the PLL more tolerant and"
" reduces the chance that the clock is stepped."
)

PARAM_PLL_STD(pll_std_mode1_rt,
1e-3, 1e3, 2,
"Cut off value for internal offset in PLL-mode 1\n\n"
"Increasing this will delay the initial clock step."
)

PARAM_PLL_STD(pll_std_mode1_weight,
1e-3, 1e3, 3,
"Cut off value for weight in PLL-mode 1\n\n"
"Increasing this will delay the initial clock step."
)

PARAM_PLL_STD(pll_std_mode2_rt,
1e-3, 1e3, 6,
"Cut off value for internal offset in PLL-mode 2\n\n"
"Increasing this will delay the transition to mode 3."
)

#endif


Expand Down
7 changes: 4 additions & 3 deletions pll_std.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ pll_std(struct ocx *ocx, double offset, double weight)
case 1: /* Wait until we have a good estimate, then step */

rt = TS_Diff(&t0, &pll_t0);
if (rt > 2.0 && weight > 3) { // XXX param
if (fabs(offset) > 1e-3) // XXX param
if (rt > param_pll_std_mode1_rt
&& weight > param_pll_std_mode1_weight) {
if (fabs(offset) > param_pll_std_mode1_step)
TB_Step(ocx, -offset);
pll_mode = 2;
pll_t0 = t0;
Expand All @@ -88,7 +89,7 @@ pll_std(struct ocx *ocx, double offset, double weight)
case 2: /* Wait for another good estimate, then PLL */

rt = TS_Diff(&t0, &pll_t0);
if (rt > 6.0) {
if (rt > param_pll_std_mode2_rt) {
pll_b = pll_a / param_pll_std_i_init;
pll_t0 = t0;
pll_mode = 3;
Expand Down