diff options
Diffstat (limited to 'tomorrowtheground.py')
| -rwxr-xr-x | tomorrowtheground.py | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/tomorrowtheground.py b/tomorrowtheground.py index 7b68b12..2ffdf7e 100755 --- a/tomorrowtheground.py +++ b/tomorrowtheground.py @@ -1,11 +1,45 @@ #!/usr/bin/python #UDP listener +from latLng import * +from layers import * +from xml2obj import * + +doc=xml2obj(open("ttg01.xml")) +gpslayers=[] +for i in doc.gps.index: + #should catch invalid xml + g=indexlayer(i.file,i.ll1,i.ll2) + for t in i.trigger: + g.triggers.append(trigger(int(t.id),t.command,t.param)) + gpslayers.append(g) + import socket -UDP_IP="127.0.0.1" -UDP_PORT=5204 -sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) -sock.bind( (UDP_IP,UDP_PORT) ) + +GUI_IP="127.0.0.1" +GUI_PORT=5400 +insock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) +insock.bind( (GUI_IP,GUI_PORT) ) +insock.settimeout(0.01) +PD_IP="127.0.0.1" +PD_PORT=5401 +outsock = socket.socket( socket.AF_INET,socket.SOCK_DGRAM ) + +pos=latLng() +posChanged=False + while True: - data, addr = sock.recvfrom( 1024 ) - print "received message:", data
\ No newline at end of file + data="" + try: + data, addr = insock.recvfrom(128) + pos.parse(data) + posChanged=True + except: + nothing=None + if posChanged: + print "received message:", data + for layer in gpslayers: + r=layer.checkcoord(pos) + if layer.checkcoord!=None: + outsock.sendto( r, (PD_IP, PD_PORT) ) +
\ No newline at end of file |
