Stuff done
[uccvend-vendserver.git] / sql-edition / servers / Idler.py
index d11fe90..ff73c2a 100755 (executable)
@@ -13,8 +13,8 @@ class Idler:
                self.v = v
 
        def next(self):
-               """Displays next stage of the idler"""
-               pass
+               """Displays next stage of the idler. Returns time to the next step"""
+               return 1
 
        def reset(self):
                """Resets the idler to a known intial state"""
@@ -28,6 +28,32 @@ class Idler:
                """How much we want this idler to be the next one chosen"""
                return 1
 
+class GreetingIdler(Idler):
+       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:
+                       x = self.secs_to_greeting
+                       self.secs_to_greeting = None
+                       return x
+
+               self.v.display('UCC SNACKS')
+               self.message_displayed = True
+               return 5
+
+       def reset(self):
+               self.message_displayed = False
+               self.secs_to_greeting = None
+
+       def finished(self):
+               return self.message_displayed
+
+       def affinity(self):
+               return 0
+
 class TrainIdler(Idler):
        def __init__(self, v):
                self.idle_state = 0
@@ -240,7 +266,9 @@ class ClockIdler(Idler):
                self.last = None
 
        def next(self):
-               output = time.strftime("%H:%M:%S")
+               colonchar = ':'
+               if int(time.time()*2) & 1: colonchar = ' '
+               output = time.strftime("%%H%c%%M%c%%S"%(colonchar,colonchar))
                if output != self.last:
                        self.v.display(" %8.8s " % (output))
                        self.last = output
@@ -276,8 +304,9 @@ class PipeIdler(StringIdler):
                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')
@@ -286,4 +315,4 @@ class FileIdler(StringIdler):
                StringIdler.__init__(self, v, text,repeat=repeat)
 
        def affinity(self):
-               return 
+               return self._affinity

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