next up previous

The State Transition Diagram

The State Transition diagram shows the state space of a given context, the events that cause a transition from one state to another, and the actions that result. Figure 6 is an example of a state transition diagram, again drawing from the Postal Commodity Machine.

[State  
Figure: State Transition Diagram for the Postal Machine CPU

With this diagram, you can see that the machine starts up and goes immediately to attract mode. If a customer deposits money, the machine goes without recourse into ready mode. The machine can leave readmy mode in one of two ways. If the customer makes a product selection, then the machine goes to search mode. If the customer put counterfeit currency into the machine, then the machine exits ready mode and returns to attract mode.

In search mode, the machine can look for the product that the customer selected. If the machine finds the product, then the machine enters finalize mode. Otherwise the product is out of stock or never existed so the machine returns to ready mode.

Once in finalize mode, the machine calls debit() on itself to reduce the customer's credit by the amount of the purchase, returning to finalize mode. The machine can leave finalize mode two ways: by delivering the product to the customer and printing the receipt or by delivering the product and going back to ready mode to allow the customer to select another item.



wbrooks@galaxy.csc.calpoly.edu