Vending Machine FSM Benjamin Welton 03/20/2010 CS 480
Overview System Overview Design Considerations Development methods Architecture Architecture Strategy's System Architecture System Design Overview
System Overview Build a FSM that mimics the functionality of a standard vending machine (such as a coke machine) Web based interface that is portable and does not require a full web server (such as apache) to run Database used for storage of states of the vending machine
Design Considerations Need for multiplatform support to allow for cross platform development and testing Distributed version control Ability to demonstrat the web interface without access to the internet (self contained)
Dependencies Python 2.x line (2.5+ required) Django web framework Web-browser with AJAX and Javascript support
Development Methods Bazaar / Launchpad for version control Python Enhancement Proposal 8 Used for coding style guidelines Comment guidelines / ect
Architecture Strategies Python Large standard library Multi-platform support Allows for focus on application logic instead of implementation issues. Django MVC Structure Simple database integration Out of the box development web server
Architecture Strategies (cont) AJAX Allows for communication with Django without page refreshes Does not rely on external dependencies on the client machine (such as java or silverlight) Smaller and more dynamic code base
System Architecture Functionality broken up into two pieces Front end Consists of the user interface Handles interaction with the user and displays balance / selection of products Back end Handles the programming logic Communicates with the front end via AJAX / XML Request's
System Design Overview XML DTD Database scheme Django Function / Web API URL's
XML DTD Communicates user actions and responses between django and the web interface Transaction XML DTD Handles transaction request (purchase, balance change, balance inquery, ect) Response XML DTD Handles the response to the transaction DTD request (after the business logic has been preformed)
Transaction DTD
Response XML DTD
Django Database Modes Products Users
Django (cont) Database Models (cont) State
Example FSM Diagram
Django (cont) Views GetIndex ajax
AJAX Functions AJAX : Sends and receives ajax request from django Product_Selected : Generates an AJAX Request when a user selects a product Insert_Money : Handles when a coin/bill is inserted Dandle_Response : Handles the response from django (callback function)
References Python Django Style guide for python code PEP 8:
Questions