How it works

state diagram

The reaction tester is an example of a simple state machine. It has three states, each represented by a traffic sign.

  • The one way sign marks the idle state, in which nothing happens. This is the tester's initial state.
  • The priority sign marks the delay state, in which the tester runs a timer but otherwise sits idle.
  • The stop sign marks the measure state, in which the tester runs another timer and counts milli-seconds.

There are four possible events, each of which triggers a transition from one state to another.

  • Clicking 'GO' puts the tester in the delay state, regardless of the state it was in previously. You would normally click 'GO' to start the tester when it is in the idle state.
  • Clicking 'STOP' puts the tester in the idle state, also regardless of the state it was in previously. You would normally click 'STOP' in reaction to the stop sign appearing on the screen when the tester enters the measure state.
  • In the delay state, if the timer reaches its end count then a transition to the measure state occurs. The timer's end count is a random value between 3 and 10 seconds, to make the moment of the transition not predictable.
  • In the measure state, if the timer reaches 10 seconds then a transition to the idle state occurs. This ensures that the tester does not stay in the measure state for all eternity if you forget to click 'STOP'.

In the diagram the normal sequence of transitions is marked by the three darker blue arrows.

  • Initially the tester is in the idle state.
  • When you click 'GO', the tester enters the delay state.
  • After a random period of between 3 and 10 seconds, the tester enters the measure state.
  • When you click 'STOP', the tester reports the number of milli-seconds it has spent in the measure state and then enters the idle state.

The five lighter blue arrows mark transitions that restart the tester or abort its operation.