def handle_hal(self, resp): putil.trace("rfid check data: \"{}\"".format(resp)) if not resp or len(resp) < 2: putil.trace("HAL doesnt know user or no contact") Foodputer.set_state(start) GUI.no_rfid() return Foodputer.new_order( resp['user'], resp['token']) Foodputer.set_state(ordering) Pin_check.tries_left = 3; GUI.valid_rfid()
def handle_hal(self, json_data): """handles the dict generated from parsing the json data fields: status: Hal.ACCEPT ect as int REQUIRED """ status = int(json_data['status']) print "status: ", status if status == Hal.ACCEPT: Foodputer.set_state(start) GUI.accepted_order() elif status == Hal.DENY: if Pin_check.tries_left == 0: self.handle_abort() else: Foodputer.set_state(ordering) GUI.wrong_pin(Pin_check.tries_left) Pin_check.tries_left -= 1; elif status == Hal.NOFUNDS: Foodputer.set_state(ordering) GUI.not_enough_money(); else: putil.trace("no such return is nice {}".format(status)); self.handle_abort()
# SETTINGS # TODO FULLSCREEN = 0 W = 800 H = 600 BG = (0, 0, 0) pygame.init() # vars surface = pygame.display.set_mode((W, H)) clock = pygame.time.Clock() Foodputer.set_state(State.start) GUI.set_state(GUI.start) def valid_id_char(s): return s.isalnum() or "-" in s def quit(): print "bye bye" sys.exit(0) walltime = 0 strbuf = "" running = 1
def handle_pin(self, str): putil.trace("shop smart, shop k-mart") Pin_check.pin = str Foodputer.set_state(pin_check)
def handle_fail(self, e): GUI.hal_error(e) Foodputer.set_state(start)
def handle_rfid(self, str): putil.trace("Velcome user") rfid_check.nr = str Foodputer.set_state(rfid_check)
def handle_abort(self): Foodputer.set_state(start) GUI.abort()