Rearrange File Slightly
authorMitchell Pomery <[email protected]>
Sun, 8 Mar 2015 15:16:11 +0000 (23:16 +0800)
committerMark Tearle <[email protected]>
Sun, 5 Apr 2015 11:41:19 +0000 (19:41 +0800)
VendServer/VendServer.py

index d079b4e..4eb2986 100755 (executable)
@@ -22,6 +22,7 @@ from SnackConfig import get_snack#, get_snacks
 import socket
 from posix import geteuid
 from LDAPConnector import get_uid,get_uname, set_card_id
+from OpenDispense import OpenDispense as Dispense
 
 CREDITS="""
 This vending machine software brought to you by:
@@ -65,6 +66,16 @@ STATE_GRANDFATHER_CLOCK,
 TEXT_SPEED = 0.8
 IDLE_SPEED = 0.05
 
+_pin_uid = 0
+_pin_uname = 'root'
+_pin_pin = '----'
+
+_last_card_id = -1
+
+idlers = []
+idler = None
+
+
 class DispenseDatabaseException(Exception): pass
 
 class DispenseDatabase:
@@ -96,6 +107,38 @@ class DispenseDatabase:
                        self.process_requests()
                        notify = self.db.getnotify()
 
+class VendState:
+       def __init__(self,v):
+               self.state_table = {}
+               self.state = STATE_IDLE
+               self.counter = 0
+
+               self.mk = MessageKeeper(v)
+               self.cur_user = ''
+               self.cur_pin = ''
+               self.username = ''
+               self.cur_selection = ''
+               self.time_to_autologout = None
+
+               self.last_timeout_refresh = None
+
+       def change_state(self,newstate,newcounter=None):
+               if self.state != newstate:
+                       #print "Changing state from: ", 
+                       #print self.state,
+                       #print " to ", 
+                       #print newstate 
+                       self.state = newstate
+
+               if newcounter is not None and self.counter != newcounter:
+                       #print "Changing counter from: ", 
+                       #print self.counter,
+                       #print " to ", 
+                       #print newcounter 
+                       self.counter = newcounter
+
+
+
 def scroll_options(username, mk, welcome = False):
        if welcome:
                # Balance checking
@@ -142,10 +185,6 @@ def scroll_options(username, mk, welcome = False):
        msg.append((choices, False, None))
        mk.set_messages(msg)
 
-_pin_uid = 0
-_pin_uname = 'root'
-_pin_pin = '----'
-
 def _check_pin(uid, pin):
        global _pin_uid
        global _pin_uname
@@ -248,11 +287,6 @@ def center(str):
        LEN = 10
        return ' '*((LEN-len(str))/2)+str
 
-
-
-idlers = []
-idler = None
-
 def setup_idlers(v):
        global idlers, idler
        idlers = [
@@ -336,36 +370,6 @@ def idle_step(vstatus):
                nextidle = IDLE_SPEED
        vstatus.time_of_next_idlestep = time()+nextidle
 
-class VendState:
-       def __init__(self,v):
-               self.state_table = {}
-               self.state = STATE_IDLE
-               self.counter = 0
-
-               self.mk = MessageKeeper(v)
-               self.cur_user = ''
-               self.cur_pin = ''
-               self.username = ''
-               self.cur_selection = ''
-               self.time_to_autologout = None
-
-               self.last_timeout_refresh = None
-
-       def change_state(self,newstate,newcounter=None):
-               if self.state != newstate:
-                       #print "Changing state from: ", 
-                       #print self.state,
-                       #print " to ", 
-                       #print newstate 
-                       self.state = newstate
-
-               if newcounter is not None and self.counter != newcounter:
-                       #print "Changing counter from: ", 
-                       #print self.counter,
-                       #print " to ", 
-                       #print newcounter 
-                       self.counter = newcounter
-
 
 
 def handle_tick_event(event, params, v, vstatus):
@@ -844,7 +848,6 @@ def handle_door_event(state, event, params, v, vstatus):
                logging.warning('Leaving open door mode')
                v.display("-YUM YUM!-")
 
-_last_card_id = -1
 
 def handle_mifare_event(state, event, params, v, vstatus):
        global _last_card_id

UCC git Repository :: git.ucc.asn.au