--- /dev/null
+#!/usr/bin/python
+# vim:ts=4
+
+import sys, os, string, re, pwd, signal
+from HorizScroll import HorizScroll
+from random import random, seed
+
+class MessageKeeper:
+ def __init__(self, vendie):
+ # Each element of scrolling_message should be a 3-tuple of
+ # ('message', True/False if it is to be repeated, time to display)
+ self.scrolling_message = []
+ self.v = vendie
+ self.next_update = None
+
+ def set_message(self, string):
+ self.scrolling_message = [(string, False, None)]
+ self.update_display(True)
+
+ def set_messages(self, strings):
+ self.scrolling_message = strings
+ self.update_display(True)
+
+ def update_display(self, forced = False):
+ if not forced and self.next_update != None and time() < self.next_update:
+ return
+ if len(self.scrolling_message) > 0:
+ if len(self.scrolling_message[0][0]) > 10:
+ (m, r, t) = self.scrolling_message[0]
+ a = []
+ exp = HorizScroll(m).expand(padding = 0, wraparound = True)
+ if t == None:
+ t = 0.1
+ else:
+ t = t / len(exp)
+ for x in exp:
+ a.append((x, r, t))
+ del self.scrolling_message[0]
+ self.scrolling_message = a + self.scrolling_message
+ newmsg = self.scrolling_message[0]
+ if newmsg[2] != None:
+ self.next_update = time() + newmsg[2]
+ else:
+ self.next_update = None
+ self.v.display(self.scrolling_message[0][0])
+ if self.scrolling_message[0][1]:
+ self.scrolling_message.append(self.scrolling_message[0])
+ del self.scrolling_message[0]
+
+ def done(self):
+ return len(self.scrolling_message) == 0
+
from popen2 import popen2
from LATClient import LATClient, LATClientException
from VendingMachine import VendingMachine, VendingException
+from MessageKeeper import MessageKeeper
from HorizScroll import HorizScroll
from random import random, seed
-from Idler import TrainIdler,GrayIdler
+from Idler import TrainIdler,GrayIdler,StringIdler
import socket
from posix import geteuid
+CREDITS="""
+This vending machine software brought to you by:
+Bernard Blackham
+Mark Tearle
+Nick Bannon
+Cameron Patrick
+and a collective of hungry alpacas.
+"""
+
GREETING = 'UCC SNACKS'
PIN_LENGTH = 4
LEN = 10
return ' '*((LEN-len(str))/2)+str
-class MessageKeeper:
- def __init__(self, vendie):
- # Each element of scrolling_message should be a 3-tuple of
- # ('message', True/False if it is to be repeated, time to display)
- self.scrolling_message = []
- self.v = vendie
- self.next_update = None
-
- def set_message(self, string):
- self.scrolling_message = [(string, False, None)]
- self.update_display(True)
-
- def set_messages(self, strings):
- self.scrolling_message = strings
- self.update_display(True)
-
- def update_display(self, forced = False):
- if not forced and self.next_update != None and time() < self.next_update:
- return
- if len(self.scrolling_message) > 0:
- if len(self.scrolling_message[0][0]) > 10:
- (m, r, t) = self.scrolling_message[0]
- a = []
- exp = HorizScroll(m).expand(padding = 0, wraparound = True)
- if t == None:
- t = 0.1
- else:
- t = t / len(exp)
- for x in exp:
- a.append((x, r, t))
- del self.scrolling_message[0]
- self.scrolling_message = a + self.scrolling_message
- newmsg = self.scrolling_message[0]
- if newmsg[2] != None:
- self.next_update = time() + newmsg[2]
- else:
- self.next_update = None
- self.v.display(self.scrolling_message[0][0])
- if self.scrolling_message[0][1]:
- self.scrolling_message.append(self.scrolling_message[0])
- del self.scrolling_message[0]
- def done(self):
- return len(self.scrolling_message) == 0
idlers = []
idler = None
global idlers, idler
idlers = [
TrainIdler(v),
+ StringIdler(v),
+ StringIdler(v, text=CREDITS),
GrayIdler(v),
GrayIdler(v,one="*",zero="-"),
GrayIdler(v,one="/",zero="\\"),