-from libtuer import ThreadFunction, logger
+from libtuer import ThreadFunction, logger, fire_and_forget
from actor import Actor
+import os, random
# logger.{debug,info,warning,error,critical}
+def play_sound (what):
+ try:
+ soundfiles = os.listdir(SOUNDS_DIRECTORY+what)
+ except FileNotFoundError:
+ logger.error("StateMachine: Unable to list sound files in %s" % (SOUNDS_DIRECTORY+what))
+ return
+ soundfile = SOUNDS_DIRECTORY + what + '/' + random.choice(soundfiles)
+ fire_and_forget ([SOUNDS_PLAYER,soundfile], logger.error, "StateMachine: ")
+
+
# StateOpening constants
OPEN_REPEAT_TIMEOUT = 8
OPEN_REPEAT_NUMBER = 3
-def play_sound (what):
- print ("I would now play the sound %s... IF I HAD SOUNDS!" % what)
-
# StateAboutToOpen constants
-ABOUTOPEN_NERVLIST = [(5, lambda : play_sound("heydrückdenknopf.mp3")), (10, lambda:play_sound("alterichmeinsernst.mp3"))]
-# TODO: erzeuge mehr nerv
+ABOUTOPEN_NERVLIST = [(5, lambda : play_sound("flipswitch")), (10, lambda:play_sound("flipswitch")), (10, lambda:Logger.warning("Space open but switch not flipped for 10 seconds")),\
+ (20, lambda:play_sound("flipswitch")), (30, lambda:play_sound("flipswitch")), (30, lambda:Logger.error("Space open but switch not flipped for 30 seconds")),\
+ (40, lambda:play_sound("flipswitch")), (50, lambda:play_sound("flipswitch")), (56, lambda:play_sound("flipswitch")), (60, lambda:Logger.critical("Space open but switch not flipped for 60 seconds"))]
+
+# play_sound constants
+SOUNDS_DIRECTORY = "/opt/tuer/sounds/"
+SOUNDS_PLAYER = "/usr/bin/mplayer"
+
class StateMachine():
# commands you can send