From: Mark Tearle Date: Wed, 29 Sep 2004 10:02:23 +0000 (+0000) Subject: add support for one shot Idlers X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=a8e66437967941cd59b3da7461a8b99a0d1bb2e6;p=zanchey%2Fdispense2.git add support for one shot Idlers --- diff --git a/sql-edition/servers/Idler.py b/sql-edition/servers/Idler.py index 48e819a..a231d96 100755 --- a/sql-edition/servers/Idler.py +++ b/sql-edition/servers/Idler.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -import string +import string, time from random import random from MessageKeeper import MessageKeeper @@ -15,6 +15,9 @@ class Idler: def reset(self): pass + + def finished(self): + return False class TrainIdler(Idler): def __init__(self, v): @@ -210,6 +213,13 @@ class StringIdler(Idler): def next(self): self.mk.update_display() - def reset(self): - pass - #self.mk.update_display(forced=True) +class ClockIdler(Idler): + def __init__(self, v): + self.v = v + self.last = None + + def next(self): + output = time.strftime("%H:%M:%S") + if output != self.last: + self.v.display(" %8.8s " % (output)) + self.last = output diff --git a/sql-edition/servers/VendServer.py b/sql-edition/servers/VendServer.py index c82dda8..eda4dc9 100755 --- a/sql-edition/servers/VendServer.py +++ b/sql-edition/servers/VendServer.py @@ -15,7 +15,7 @@ from VendingMachine import VendingMachine, VendingException from MessageKeeper import MessageKeeper from HorizScroll import HorizScroll from random import random, seed -from Idler import TrainIdler,GrayIdler,StringIdler +from Idler import TrainIdler,GrayIdler,StringIdler,ClockIdler import socket from posix import geteuid @@ -189,6 +189,7 @@ idler = None def setup_idlers(v): global idlers, idler idlers = [ + ClockIdler(v), StringIdler(v), StringIdler(v, text=CREDITS), StringIdler(v, text=str(math.pi) + " "), @@ -211,6 +212,8 @@ def choose_idler(): def idle_step(): global idler + if idler.finished(): + choose_idler() idler.next() def run_forever(rfh, wfh, options, cf):