Skip to content

Commit

Permalink
Sped up redis receiver a little. Also better configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
at8eqeq3 committed Jan 7, 2021
1 parent bd82307 commit 264f5a0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
plot/*
plot*
plot.*
output.*
.ipynb_checkpoints
17 changes: 13 additions & 4 deletions redis_feeder.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
import socket
import redis
import socket

# redis server
REDIS_HOST = 'localhost'
REDIS_PORT = 6379
# ADSB feeder
FEEDER_HOST = '192.168.249.26'
FEEDER_PORT = 30003
# TTL of records, in seconds
EXPIRATION = 1200

r = redis.Redis(host='localhost', port=6379, db=0)
r = redis.Redis(host=REDIS_HOST, port=REDIS_PORT, db=0)


sock = socket.socket()
sf = sock.makefile()
sock.connect(('192.168.249.26', 30003))
sock.connect((FEEDER_HOST, FEEDER_PORT))
while(True):
fields = sf.readline().split(',')
if(fields[0] == 'MSG' and fields[1] == '3'):
if(fields[14].strip != '' and fields[15].strip != '' and fields[11].strip != ''):
coords = ','.join([fields[14], fields[15], fields[11]])
r.setex(coords, 3600, coords)
r.setex(coords, EXPIRATION, '')

18 changes: 12 additions & 6 deletions redis_plotter.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import redis
import numpy as np
from PIL import Image
import colorsys
import redis
import time
from PIL import Image

r = redis.Redis(host='localhost', port=6379, db=0, decode_responses=True)

# redis server
REDIS_HOST = 'localhost'
REDIS_PORT = 6379
# crop parameters
RADAR_COORDS = [55.83871, 37.18298]
COEFS = [300, 300, 40000]
SIZE = [3000, 1000]


r = redis.Redis(host=REDIS_HOST, port=REDIS_PORT, db=0, decode_responses=True)

i = 0
while(True):
im = Image.new('RGB', SIZE, color=(10, 0, 20))
for key in r.scan_iter():
try:
data = r.get(key).split(',')
data = key.split(',')
cdata = []
cdata.append(int(((float(data[1]) - RADAR_COORDS[1]) * COEFS[0]) + SIZE[0]/2))
cdata.append(int(((float(data[0]) - RADAR_COORDS[0]) * COEFS[1]) + SIZE[1]/2))
Expand All @@ -26,6 +30,8 @@
pass
except AttributeError as e:
pass
except IndexError as e:
pass
im = im.transpose(Image.FLIP_TOP_BOTTOM)
im.save("plot/frame_%06d.png" % i)
i += 1
Expand Down

0 comments on commit 264f5a0

Please sign in to comment.