+ABOUTOPEN_NERVLIST = [(5, lambda : play_sound("flipswitch")), (5, lambda:play_sound("flipswitch")), (0, lambda:Logger.warning("Space open but switch not flipped for 10 seconds")),\
+ (10, lambda:play_sound("flipswitch")), (10, lambda:play_sound("flipswitch")), (0, lambda:Logger.error("Space open but switch not flipped for 30 seconds")),\
+ (10, lambda:play_sound("flipswitch")), (10, lambda:play_sound("flipswitch")), (6, lambda:play_sound("flipswitch")), (4, lambda:Logger.critical("Space open but switch not flipped for 60 seconds"))]
+
+# StateAuf constants
+# time that must pass between two bell_ringing events to buzz the door again (seconds)
+AUF_BELLBUZZ_REPEAT_TIME = 2
+
+# Timeout we wait after the switch was switched to "Closed", until we assume nobody will open the door and we just lock it
+LEAVE_TIMEOUT = 30
+
+# play_sound constants
+SOUNDS_DIRECTORY = "/opt/tuer/sounds/"
+SOUNDS_PLAYER = "/usr/bin/mplayer"
+
+
+class Nerver():
+ # A little utility class used to run the nervlists. A nervlist is a list of (n, f) tuples where f() is run after n seconds.
+ # If f returns something, that's also returned by nerv.
+ def __init__(self, nervlist):
+ self.nervlist = list(nervlist)
+
+ def nerv(self, total_time):
+ if len(self.nervlist):
+ (time, f) = self.nervlist[0]
+ # check if the first element is to be triggered
+ if time >= total_time:
+ self.nervlist = self.nervlist[1:] # "pop" the first element, but do not modify original list
+ return f()
+