405 Documentation  9.0
lab01.py File Reference

A reintroduction to Python and finite state machines. More...

Classes

class  lab01.Conditions
 Class to keep track of vending machine conditions to instruct master mind. More...
 

Functions

def lab01.printWelcome ()
 Prints welcome message. More...
 
def lab01.state0 (c)
 Perform State 0 operations. More...
 
def lab01.state1 (c)
 Perform State 1 operations. More...
 
def lab01.state2 (c)
 Perform State 2 operations. More...
 
def lab01.state3 (c)
 Perform State 3 operations. More...
 
def lab01.state4 (c)
 Perform State 4 operations. More...
 
def lab01.state5 (c)
 Perform State 5 operations. More...
 
def lab01.state6 (c)
 Perform State 6 operations. More...
 
def lab01.state7 (c)
 Perform State 7 operations. More...
 
def lab01.state8 (c)
 Perform State 8 operations. More...
 
def lab01.state9 (c)
 Perform State 9 operations. More...
 
def lab01.state10 (c)
 Perform State 10 operations. More...
 
def lab01.state11 (c)
 Perform State 11 operations. More...
 
def lab01.state12 (c)
 Perform State 12 operations. More...
 
def lab01.state13 (c)
 Perform State 13 operations. More...
 
def lab01.state14 (c)
 Perform State 14 operations. More...
 
def lab01.state15 (c)
 Perform State 15 operations. More...
 
def lab01.main_loop (c)
 FSM Main loop. More...
 
def lab01.main ()
 Main. More...
 

Detailed Description

A reintroduction to Python and finite state machines.

The goal of this lab is to regain comfort with python and the concepts learned in ME 305 by developing a program that "embodies the function of a vending machine."

Author
Hunter Morse
Date
Jan. 14, 2021

Function Documentation

◆ main()

def lab01.main ( )

Main.

Initialize FSM

◆ main_loop()

def lab01.main_loop (   c)

FSM Main loop.

Implement the FSM using a while loop and an if statement. Will run eternallly intil the user presses CTRL-C

Parameters
cA Conditions object used to keep track of the conditions of the vending machine

◆ printWelcome()

def lab01.printWelcome ( )

Prints welcome message.

Prints a Vendotron^TM^ welcome message with beverage prices

◆ state0()

def lab01.state0 (   c)

Perform State 0 operations.

This init state intializes the FSM itself

Parameters
cA Conditions object used to keep track of the conditions of the vending machine

◆ state1()

def lab01.state1 (   c)

Perform State 1 operations.

Displays the startup message and awaits any input from the machine before incrementing the state

Parameters
cA Conditions object used to keep track of the conditions of the vending machine
cA Conditions object used to keep track of the conditions of the vending machine

◆ state10()

def lab01.state10 (   c)

Perform State 10 operations.

Raise return money flag so that money is returned on the next MM loop

Parameters
cA Conditions object used to keep track of the conditions of the vending machine

◆ state11()

def lab01.state11 (   c)

Perform State 11 operations.

Dispense soda and recalculate current balance

Parameters
cA Conditions object used to keep track of the conditions of the vending machine

◆ state12()

def lab01.state12 (   c)

Perform State 12 operations.

Return change and reset to State 1

Parameters
cA Conditions object used to keep track of the conditions of the vending machine

◆ state13()

def lab01.state13 (   c)

Perform State 13 operations.

Reset flags and return to state 1

Parameters
cA Conditions object used to keep track of the conditions of the vending machine

◆ state14()

def lab01.state14 (   c)

Perform State 14 operations.

Wait for key to be pressed

Parameters
cA Conditions object used to keep track of the conditions of the vending machine

◆ state15()

def lab01.state15 (   c)

Perform State 15 operations.

Wait for key to be released

Parameters
cA Conditions object used to keep track of the conditions of the vending machine

◆ state2()

def lab01.state2 (   c)

Perform State 2 operations.

Master Mind dictates which state operates next based on the flags raised

Parameters
cA Conditions object used to keep track of the conditions of the vending machine

◆ state3()

def lab01.state3 (   c)

Perform State 3 operations.

The Cuke Handler sets the current soda selection and price. If the balance is insufficient an error is raised

Parameters
cA Conditions object used to keep track of the conditions of the vending machine

◆ state4()

def lab01.state4 (   c)

Perform State 4 operations.

The Popsi Handler sets the current soda selection and price. If the balance is insufficient an error is raised

Parameters
cA Conditions object used to keep track of the conditions of the vending machine

◆ state5()

def lab01.state5 (   c)

Perform State 5 operations.

The Spryte Handler sets the current soda selection and price. If the balance is insufficient an error is raised

Parameters
cA Conditions object used to keep track of the conditions of the vending machine

◆ state6()

def lab01.state6 (   c)

Perform State 6 operations.

The Dr. Pupper Handler sets the current soda selection and price. If the balance is insufficient an error is raised

Parameters
cA Conditions object used to keep track of the conditions of the vending machine

◆ state7()

def lab01.state7 (   c)

Perform State 7 operations.

Update the balance besed on the coin inserted. Raise a flag to update the display to reflect the new balance

Parameters
cA Conditions object used to keep track of the conditions of the vending machine

◆ state8()

def lab01.state8 (   c)

Perform State 8 operations.

If error flag is raised it's because there's an insufficient balance

Parameters
cA Conditions object used to keep track of the conditions of the vending machine

◆ state9()

def lab01.state9 (   c)

Perform State 9 operations.

Update the display to the message stored in disp_next

Parameters
cA Conditions object used to keep track of the conditions of the vending machine