X-Git-Url: https://git.ucc.asn.au/?p=uccvend-vendserver.git;a=blobdiff_plain;f=sql-edition%2Fservers%2FVendServer.py;h=00e33b120676c7d80620cd4282fddaadd747a53e;hp=17d29d0a412a9d5951e51d47d63a046387406a54;hb=edd78a42d003a467dae652c9908403a26d38cf08;hpb=b20f1351704e4e2ae94cb8cee201969f6363dc54 diff --git a/sql-edition/servers/VendServer.py b/sql-edition/servers/VendServer.py index 17d29d0..00e33b1 100755 --- a/sql-edition/servers/VendServer.py +++ b/sql-edition/servers/VendServer.py @@ -45,13 +45,15 @@ KEY = 3 TICK = 4 -STATE_IDLE = 1 -STATE_DOOR_OPENING = 2 -STATE_DOOR_CLOSING = 3 -STATE_GETTING_UID = 4 -STATE_GETTING_PIN = 5 -STATE_GET_SELECTION = 6 -STATE_GRANDFATHER_CLOCK = 7 +( +STATE_IDLE, +STATE_DOOR_OPENING, +STATE_DOOR_CLOSING, +STATE_GETTING_UID, +STATE_GETTING_PIN, +STATE_GET_SELECTION, +STATE_GRANDFATHER_CLOCK, +) = range(1,8) TEXT_SPEED = 0.8 IDLE_SPEED = 0.05 @@ -375,10 +377,17 @@ def handle_get_selection_key(state, event, params, v, vstatus): return else: vstatus.cur_selection += chr(key + ord('0')) - make_selection(v,vstatus) - vstatus.cur_selection = '' - vstatus.time_to_autologout = time() + 8 - vstatus.last_timeout_refresh = None + if vstatus.cur_user: + make_selection(v,vstatus) + vstatus.cur_selection = '' + vstatus.time_to_autologout = time() + 8 + vstatus.last_timeout_refresh = None + else: + # Price check mode. + price_check(v,vstatus) + vstatus.cur_selection = '' + vstatus.time_to_autologout = None + vstatus.last_timeout_refresh = None def make_selection(v, vstatus): # should use sudo here @@ -428,6 +437,19 @@ def make_selection(v, vstatus): sleep(1) +def price_check(v, vstatus): + if vstatus.cur_selection[1] == '8': + v.display(center('SEE COKE')) + else: + # first see if it's a named slot + try: + price, shortname, name = get_snack( vstatus.cur_selection ) + except: + price, shortname, name = get_snack( '--' ) + dollarprice = "$%.2f" % ( price / 100.0 ) + v.display(vstatus.cur_selection+' - %s'%dollarprice) + + def handle_getting_pin_key(state, event, params, v, vstatus): #print "handle_getting_pin_key (s,e,p)", state, " ", event, " ", params key = params @@ -470,7 +492,14 @@ def handle_getting_uid_key(state, event, params, v, vstatus): # complicated key handling here: - + if len(vstatus.cur_user) == 0 and key == 9: + vstatus.cur_selection = '' + vstatus.time_to_autologout = None + vstatus.mk.set_message('PRICECHECK') + sleep(0.5) + scroll_options('', vstatus.mk) + vstatus.change_state(STATE_GET_SELECTION) + return if len(vstatus.cur_user) <8: if key == 11: