aboutsummaryrefslogtreecommitdiff
path: root/tools/test-generator.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/test-generator.py')
-rwxr-xr-xtools/test-generator.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/test-generator.py b/tools/test-generator.py
index 8d7377c2c..cedbe9c69 100755
--- a/tools/test-generator.py
+++ b/tools/test-generator.py
@@ -3,11 +3,11 @@
import sys
import math
import urllib
-import httplib
+import urllib2
import time
id = '123456789012345'
-server = 'localhost:5055'
+server = 'http://localhost:5055'
period = 1
step = 0.001
@@ -32,10 +32,11 @@ for i in range(0, len(waypoints)):
lon = lon1 + (lon2 - lon1) * j / count
points.append((lat, lon))
-def send(conn, lat, lon, course):
+def send(lat, lon, course, alarm):
params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course))
- conn.request('GET', '?' + urllib.urlencode(params))
- conn.getresponse()
+ if alarm:
+ params = params + (('alarm', 'sos'),)
+ urllib2.urlopen(server + '?' + urllib.urlencode(params)).read()
def course(lat1, lon1, lat2, lon2):
lat1 = lat1 * math.pi / 180
@@ -48,11 +49,10 @@ def course(lat1, lon1, lat2, lon2):
index = 0
-conn = httplib.HTTPConnection(server)
-
while True:
(lat1, lon1) = points[index % len(points)]
(lat2, lon2) = points[(index + 1) % len(points)]
- send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2))
+ alarm = ((index % 10) == 0)
+ send(lat1, lon1, course(lat1, lon1, lat2, lon2), alarm)
time.sleep(period)
index += 1