def __init__(self, v, secs_to_greeting = None):
self.v = v
self.secs_to_greeting = secs_to_greeting
+ self.message_displayed = False
def next(self):
if not self.secs_to_greeting is None:
return x
self.v.display('UCC SNACKS')
- return 2
+ self.message_displayed = True
+ return 5
def reset(self):
- pass
+ self.message_displayed = False
+ self.secs_to_greeting = None
def finished(self):
- return self.secs_to_greeting == None
+ return self.message_displayed
def affinity(self):
return 0
return 20
class FileIdler(StringIdler):
- def __init__(self, v, thefile=None, repeat=False):
+ def __init__(self, v, thefile=None, repeat=False, affinity=8):
text = "I broke my wookie...."
+ self._affinity = affinity
if file and os.access(thefile,os.F_OK|os.R_OK):
f = file(thefile,'r')
StringIdler.__init__(self, v, text,repeat=repeat)
def affinity(self):
- return 8
+ return self._affinity
GrayIdler(v,one="/",zero="\\"),
ClockIdler(v),
GrayIdler(v,one="X",zero="O"),
- FileIdler(v, '/usr/share/common-licenses/GPL-2'),
+ FileIdler(v, '/usr/share/common-licenses/GPL-2',affinity=2),
GrayIdler(v,one="*",zero="-",reorder=1),
StringIdler(v, text=str(math.pi) + " "),
ClockIdler(v),
StringIdler(v, text=str(math.e) + " "),
GrayIdler(v,one="X",zero="O",reorder=1),
StringIdler(v, text=" I want some pizza - please call Pizza Hut Shenton Park on +61 8 9381 9979 - and order as Quinn - I am getting really hungry", repeat=False),
- PipeIdler(v, "/usr/bin/ypcat", "passwd"),
+ PipeIdler(v, "/usr/bin/getent", "passwd"),
FortuneIdler(v),
ClockIdler(v),
StringIdler(v),
vstatus.cur_user = ''
vstatus.cur_selection = ''
- reset_idler(v, vstatus)
-
vstatus.mk.set_messages([(center('BYE!'), False, 1.5)])
+ reset_idler(v, vstatus, 2)
return
vstatus.cur_selection += chr(key + ord('0'))
vstatus.mk.set_message('SELECT: '+vstatus.cur_selection)
if len(vstatus.cur_user) == 5:
uid = int(vstatus.cur_user)
+ if uid == 0:
+ logging.info('user '+vstatus.cur_user+' has a bad PIN')
+ pfalken="""
+CARRIER DETECTED
+
+CONNECT 128000
+
+Welcome to Picklevision Sytems, Sunnyvale, CA
+
+Greetings Professor Falken.
+
+
+
+
+Shall we play a game?
+
+
+Please choose from the following menu:
+
+1. Tic-Tac-Toe
+2. Chess
+3. Checkers
+4. Backgammon
+5. Poker
+6. Toxic and Biochemical Warfare
+7. Global Thermonuclear War
+
+7 [ENTER]
+
+Wouldn't you prefer a nice game of chess?
+
+""".replace('\n',' ')
+ vstatus.mk.set_messages([(pfalken, False, 10)])
+ vstatus.cur_user = ''
+ vstatus.cur_pin = ''
+
+ reset_idler(v, vstatus, 10)
+
+ return
+
if not has_good_pin(uid):
logging.info('user '+vstatus.cur_user+' has a bad PIN')
vstatus.mk.set_messages(
- [(' '*10+'INVALID PIN SETUP'+' '*10, False, 3)])
+ [(' '*10+'INVALID PIN SETUP'+' '*11, False, 3)])
vstatus.cur_user = ''
vstatus.cur_pin = ''
- reset_idler(v, vstatus, 5)
+ reset_idler(v, vstatus, 3)
return
def handle_idle_tick(state, event, params, v, vstatus):
### State idling
- idle_step(vstatus)
+ if vstatus.mk.done():
+ idle_step(vstatus)
if vstatus.time_of_next_idler and time() > vstatus.time_of_next_idler:
vstatus.time_of_next_idler = time() + 30
def get_state_table_handler(vstatus, state, event, counter):
return vstatus.state_table[(state,event,counter)]
+def time_to_next_update(vstatus):
+ idle_update = vstatus.time_of_next_idlestep - time()
+ if not vstatus.mk.done() and vstatus.mk.next_update is not None:
+ mk_update = vstatus.mk.next_update - time()
+ if mk_update < idle_update:
+ idle_update = mk_update
+ return idle_update
+
def run_forever(rfh, wfh, options, cf):
v = VendingMachine(rfh, wfh)
vstatus = VendState(v)
logging.error('Database error: '+str(e))
- e = v.next_event(vstatus.time_of_next_idlestep-time())
+ timeout = time_to_next_update(vstatus)
+ e = v.next_event(timeout)
(event, params) = e
run_handler(event, params, v, vstatus)