Exemplo n.º 1
0
void clksyncProcessSamples(SyncStatus sync) {

    unsigned long current_offset;
    long average_offset;

    current_offset = sclockGetOffsetTicks();
    average_offset = sync->accumulator/sync->responses;

    sclockSetOffsetTicks(current_offset - average_offset);

    sync->accumulator = 0;
    sync->requests = 0;
    sync->responses = 0;
    sync->iterations++;

    if((average_offset < sync->tolerance) && 
            (average_offset > -(sync->tolerance))) {
        sync->state = STATE_SYNCED;
    }

    if(sync->iterations > MAX_ITERATIONS) {
        sync->state = STATE_ITERS_EXCEEDED;
    }

}
Exemplo n.º 2
0
void sclockSetOffsetMillis(unsigned long offset) {

    sclockSetOffsetTicks(offset*MILLIS_FACTOR);

}