diff --git a/site_ansto/hardsup/Monitor/cntr.c b/site_ansto/hardsup/Monitor/cntr.c index 8e2d8e1d..0486daed 100644 --- a/site_ansto/hardsup/Monitor/cntr.c +++ b/site_ansto/hardsup/Monitor/cntr.c @@ -284,6 +284,12 @@ int cntr_start(COUNTER *cp) cp->state = counter_running; cp->previous_time = cp->current_time; HCTR_TEST(hctr_read(cp->private_data, &cp->count64)); + SAMPLE* sp = cur_sample(cp); + sp->timestamp = cp->current_time; + sp->counter_value = cp->current_count; + SAMPLE* psp = prv_sample(cp, 1); + psp->timestamp = cp->current_time; + psp->counter_value = cp->current_count; make_report(cp); if (pp->output_line == 1) value = 1; @@ -419,6 +425,7 @@ static void cntr_test_term(COUNTER* cp) /* * decremented to or through terminal */ + // TODO FIXME improve wraparound handling if ((sp->counter_value <= pp->terminal_count && psp->counter_value > pp->terminal_count) || (sp->counter_value > psp->counter_value && @@ -432,10 +439,17 @@ static void cntr_test_term(COUNTER* cp) /* * incremented to or through terminal */ - if ((sp->counter_value >= pp->terminal_count && - psp->counter_value < pp->terminal_count) || + // TODO FIXME improve wraparound handling + if ( +#if 1 + sp->counter_value >= pp->terminal_count +#else + (sp->counter_value >= pp->terminal_count && + psp->counter_value < pp->terminal_count) || (sp->counter_value < psp->counter_value && - psp->counter_value > pp->terminal_count)) + psp->counter_value > pp->terminal_count) +#endif + ) { cp->terminal_due = true; }