Ticket Vending Sample |
The ticket vending sample demonstrates StaMa running on the Microsoft .NET Micro Framework emulator.
As with real ticket vending machines, the usage of the vending machine is intricate. The introduction text on the left side screenshot below explains how to use the buttons to fetch something out of the machine. Good luck!
The central points of the sample are:
The button pressed events of the UP, DOWN, SELECT and RIGHT buttons trigger different transitions dependent on the state machine active state. UP and DOWN iterate through the selected list (either Destination or Coin), SELECT executes an action and RIGHT cancels.
In the implementation there is a single exit action ExitEmitRequired of the composite state EmitRequired which ensures that the vending machine delivers in any case either the inserted money or the product or the product and change pair.
The code for setting up the state machine structure and string constants for the states and transitions are generated from Microsoft Visio.
Timeouts are implemented through Microsoft.SPOT.DispatcherTimer instances.