-def log (what):
- print (datetime.now(),what)
-
-def waynesend (conn, what):
- try:
- conn.send(what)
- except:
- log("Couldn't send %s" % str(what))
-
-class Pinoutput:
- # actionsanddelays is a list of pairs: (bool to send, delay in seconds to wait afterwards)
- def __init__ (self, name, pinnumber, actionsanddelays):
- self.name = name
- self.pin = pinnumber
- self.todo = actionsanddelays
- GPIO.setup(pinnumber, GPIO.OUT)
- log ("Pin %d set to be an output pin for %s." % (pinnumber,name))
-
- def __call__ (self, conn):
- for (value,delay) in self.todo:
- GPIO.output(self.pin, value)
- log ("%s: Pin %d set to %s." % (self.name,self.pin,str(value)))
- time.sleep(delay)
- waynesend(conn,b"1")
-
-tuergroupid = 1005
-
-pinlist = [Pinoutput("open", 12, [(True, 0.3), (False, 5.0)]),
- Pinoutput("close", 16, [(True, 0.3), (False, 5.0)]),
- Pinoutput("buzz", 22, [(True, 2.0), (False, 5.0)])]
-
-socketname = "/run/tuer.sock"
-
-
-def doNothing (conn):
- log ("doing nothing")
- waynesend(conn,b"0")
- pass
-
-sock = socket.socket (socket.AF_UNIX, socket.SOCK_STREAM)
+# bring 'em all up
+the_actor = actor.Actor()
+the_machine = statemachine.StateMachine(the_actor)
+the_socket = tysock.TySocket(the_machine)
+the_pins = pins.PinsWatcher(the_machine)
+the_waker = waker.Waker(the_machine)