diff options
author | tv <tv@xso> | 2011-09-01 00:31:07 +0200 |
---|---|---|
committer | tv <tv@xso> | 2011-09-01 00:31:07 +0200 |
commit | 73f953023b0baae827d1f5f288a9629c67db10c3 (patch) | |
tree | 8d5f0e9ff96c9e742462557d6ef30963b97e3d61 /god | |
parent | 2c112849f29620db6824bc9ad2762e52d857d079 (diff) |
Reaktor: add shackspace map
Diffstat (limited to 'god')
-rwxr-xr-x | god/Reaktor | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/god/Reaktor b/god/Reaktor index 54bc5099..47d2d7c9 100755 --- a/god/Reaktor +++ b/god/Reaktor @@ -1,11 +1,36 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 +# coding=UTF-8 +location = 'shackspace' +host = '0.0.0.0' +port = 2342 + +map = { + 'shackspace': { + 'device': { + 0: 'Licht0, Tensau\'s Kuschelecke; Fenster', + 1: 'Licht1, Sofaecke; Fenster', + 2: 'Licht2, Tensau\'s Kuschelecke; Ghetto', + 3: 'Licht3, Sofaecke; Ghetto', + 4: 'Licht4, Richtung Getränkelager', + 5: 'Licht5, Porschekonsole', + 6: 'Licht6, Tomatenecke', + 7: 'Licht7, Ghetto', + 10: 'Hauptschalter' + }, + 'state': { + 0: 'aus', + 1: 'an', + 2: 'aus in T-10s' + }, + '->': 'ist' + } +} + import socket +from string import join from struct import unpack -listen_address = '0.0.0.0' -listen_port = 2342 - # create udp socket mysocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) @@ -14,9 +39,12 @@ mysocket.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1) # allow the socket to be re-used mysocket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) -mysocket.bind((listen_address, listen_port)) +mysocket.bind((host, port)) + +map = map[location] while True: - dev, state = unpack('BB', mysocket.recv(2)) - print "dev: " + str(dev) - print "state: " + str(state) + did, sid = unpack('BB', mysocket.recv(2)) + device, state = map['device'][did], map['state'][sid] + arrow = map['->'] + print join([device, arrow, state], ' ') |