Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 37x 47x 41x 41x 12x 12x 1x 37x 37x | import type { SmartCubeMoveEvent } from '@wstein/regrip-core/bindings/smartCubeTransport';
import * as SmartCubeBindings from '@wstein/regrip-core/bindings/Bindings_SmartCube';
import * as MoveBuffer from '@wstein/regrip-core/domain/MoveBuffer';
type TimingDiagnosticsOptions = {
setSkew: (value: string) => void;
};
/** Track transport-clock quality independently from solve and session timing. */
export function createTimingDiagnostics(options: TimingDiagnosticsOptions) {
let moves = MoveBuffer.initial<SmartCubeMoveEvent>();
function onMove(move: SmartCubeMoveEvent): void {
if (move.cubeTimestamp === null) {
options.setSkew('- n/a - (cube clock unavailable)');
return;
}
moves = MoveBuffer.pushRecent(moves, move);
if (MoveBuffer.recentReady(moves)) {
options.setSkew(`${SmartCubeBindings.cubeTimestampCalcSkew(MoveBuffer.recentMoves(moves))}%`);
}
}
function reset(): void {
moves = MoveBuffer.reset(moves);
}
return { onMove, reset };
}
export type TimingDiagnostics = ReturnType<typeof createTimingDiagnostics>;
|