DOOR = 1
SWITCH = 2
KEY = 3
+TICK = 4
class DispenseDatabaseException(Exception): pass
e = v.next_event()
if e == None: break
(event, params) = e
+ if event == TICK: break
+
if event == DOOR:
if params == 1: # door closed
logging.warning('Leaving open door mode')
vstatus.cur_pin = ''
vstatus.mk.set_message(GREETING)
+def handle_tick_event(event, params, v, vstatus):
+ # don't care right now.
+ pass
+
def handle_switch_event(event, params, v, vstatus):
# don't care right now.
pass
vstatus.cur_selection = ''
vstatus.mk.set_message(GREETING)
- if vstatus.time_to_autologout and not vstatus.mk.done(): vstatus.time_to_autologout = None
- if vstatus.cur_user == '' and vstatus.time_to_autologout: vstatus.time_to_autologout = None
+ if vstatus.time_to_autologout and not vstatus.mk.done():
+ vstatus.time_to_autologout = None
+ if vstatus.cur_user == '' and vstatus.time_to_autologout:
+ vstatus.time_to_autologout = None
if len(vstatus.cur_pin) == PIN_LENGTH and vstatus.mk.done() and vstatus.time_to_autologout == None:
# start autologout
vstatus.time_to_autologout = time() + 15
if vstatus.time_to_idle == None and vstatus.cur_user == '':
vstatus.time_to_idle = time() + 5
choose_idler()
- if vstatus.time_to_idle is not None and vstatus.cur_user != '': vstatus.time_to_idle = None
- if vstatus.time_to_idle is not None and time() > vstatus.time_to_idle: idle_step()
- if vstatus.time_to_idle is not None and time() > vstatus.time_to_idle + 300:
+ if vstatus.time_to_idle is not None and vstatus.cur_user != '':
+ vstatus.time_to_idle = None
+
+ if vstatus.time_to_idle is not None and time() > vstatus.time_to_idle:
+ idle_step()
+
+ if vstatus.time_to_idle is not None and time() > vstatus.time_to_idle + 30:
vstatus.time_to_idle = time()
choose_idler()
vstatus.mk.update_display()
e = v.next_event(0)
- if e == None:
+ (event, params) = e
+
+ if event == TICK:
e = v.next_event(0.05)
- if e == None:
+ (event, params) = e
+
+ if event == TICK:
+ handle_tick_event(event, params, v, vstatus)
continue
vstatus.time_to_idle = None
- (event, params) = e
logging.debug('Got event: ' + repr(e))
if event == DOOR:
from CRC import do_crc
from select import select
import socket, logging
+from time import time, sleep
asynchronous_responses = [ '400', '401', # door open/closed
'610', # switches changed
DOOR = 1
SWITCH = 2
KEY = 3
+TICK = 4
class VendingException(Exception): pass
timeout = 0
else:
break
- if len(self.events) == 0: return None
+ if len(self.events) == 0: return (TICK, time())
ret = self.events[0]
del self.events[0]
return ret