State Machine
A state machine drawn and driven on the canvas: states are nodes, transitions are labelled edges routed round the states in their way, and the toolbar fires the events the current state accepts. The current state is marked through RunStates and announced, and the transition just taken is animated.
Press Tab to move between the nodes and edges of the diagram.
Press Enter or Space to select it, Shift with Enter to add it to the selection, the arrow keys to move the selected nodes, Delete to remove them and Escape to clear the selection. Press C to start a connection from it.
Press Enter or Space to select it, Delete to remove it and Escape to clear the selection. Press C to move its end to another node.
bit BlowTry it
- The toolbar shows the events the current state accepts. Press fetch, then resolve or reject: the ring moves to the new state, the edge just taken is animated, and a screen reader hears where the machine is now.
- In Ready, refresh follows the loop that leaves Ready and comes straight back to it.
- Start over returns to Idle.
- Drag from a state's handle to another state to add a transition. It is named event 1, event 2 and so on, routed like the others, and its button appears whenever the machine is in the state it leaves.
- Click a transition and press Delete: its button is gone. The states themselves cannot be deleted.
- Drag a state across another's transitions: the routed edges find a new way round it.
How it works
- States are
BlowNodes withDeletable = false, so the toolbar always has a current state to name. Transitions areBlowEdges whoseLabelis the event and whoseSourceandTargetare the states before and after it. - The toolbar lists the edges leaving the current state, one button each; firing one makes its
Targetthe current state, setsAnimatedon that edge only, and callsAnnouncewith the new state for screen readers. RunStatesmarks the current state withnew BlowRunState(BlowRunStatus.Running, "Current state"): the running ring and thebit-blow-run-runningclass, read out with the node. Every other state has no entry, so it shows nothing.BlowEdgeType.Routedroutes each edge round the nodes in its way and re-routes it when a node moves. An edge whoseSourceandTargetare the same node is drawn as a loop. Ready and Error leave from the top and the bottom (SourcePosition), so the ways back do not share the ways there.DefaultEdgeOptionsgives a transition drawn on the canvas the same routed shape and arrowhead, andOnConnect- raised once the new edge is in the list - gives it a name, so it has a label to show and a button to fire it.