missed a place where I had to rename open -> unlock
[saartuer.git] / actor.py
index 3abd2328af97172cd04481b28d7dc7d5f7f77c48..0a53263d3cdd9485da0b26ddaa2039f18c8ebea4 100644 (file)
--- a/actor.py
+++ b/actor.py
@@ -1,19 +1,20 @@
 from libtuer import ThreadFunction, logger
 import RPi.GPIO as GPIO
+import time
        
 class Actor:
        CMD_BUZZ = 0
-       CMD_OPEN = 1
-       CMD_CLOSE = 2
+       CMD_UNLOCK = 1
+       CMD_LOCK = 2
        
        CMDs = {
-               CMD_BUZZ:  ("buzz", 12, [(True, 0.3), (False, 2.0)]),
-               CMD_OPEN:  ("open", 16, [(None, 0.2), (True, 0.3), (False, 1.0)]),
-               CMD_CLOSE: ("close", 22, [(None, 0.2), (True, 0.3), (False, 1.0)]),
+               CMD_UNLOCK:  ("unlock", 12, [(True, 0.3), (False, 0.1)]),
+               CMD_LOCK:  ("lock", 16, [(True, 0.3), (False, 0.1)]),
+               CMD_BUZZ: ("buzz", 22, [(True, 2.0), (False, 0.1)]),
        }
        
        def __init__(self):
-               self.act = ThreadFunction(self._act)
+               self.act = ThreadFunction(self._act, name="Actor")
                for (name, pin, todo) in self.CMDs.values():
                        GPIO.setup(pin, GPIO.OUT)
        
@@ -23,10 +24,11 @@ class Actor:
                        logger.info("Actor: Running command %s" % name)
                        for (value, delay) in todo:
                                if value is not None:
+                                       logger.debug("Actor: Setting pin %d to %d" % (pin, value))
                                        GPIO.output(pin, value)
                                time.sleep(delay)
                else:
-                       logger.error("Actor: Gut unknown command %d" % cmd)
+                       logger.critical("Actor: Got unknown command %d" % cmd)
        
        def stop(self):
-               pass
+               self.act.stop()