aboutsummaryrefslogtreecommitdiff
path: root/tools/test-generator.py
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-08-20 13:13:09 +0300
committerGitHub <noreply@github.com>2016-08-20 13:13:09 +0300
commit6c6b62351aadd68928b9bd3e39e2bf96d78695e8 (patch)
tree8d9f5617aada94e3c8784c0bee6a201fbced54b3 /tools/test-generator.py
parent6b6d28695600fee509ee37a7225dd6518879ac9c (diff)
parent804c56a76dc8406e4ff072289a4a9f97322dfe83 (diff)
downloadtrackermap-server-6c6b62351aadd68928b9bd3e39e2bf96d78695e8.tar.gz
trackermap-server-6c6b62351aadd68928b9bd3e39e2bf96d78695e8.tar.bz2
trackermap-server-6c6b62351aadd68928b9bd3e39e2bf96d78695e8.zip
Merge pull request #2228 from Abyss777/reports_trips
Implement trips reports
Diffstat (limited to 'tools/test-generator.py')
-rwxr-xr-xtools/test-generator.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/test-generator.py b/tools/test-generator.py
index 0b8e4113c..a23e2576e 100755
--- a/tools/test-generator.py
+++ b/tools/test-generator.py
@@ -10,6 +10,7 @@ id = '123456789012345'
server = 'localhost:5055'
period = 1
step = 0.001
+device_speed = 40
waypoints = [
(40.722412, -74.006288),
@@ -32,12 +33,13 @@ for i in range(0, len(waypoints)):
lon = lon1 + (lon2 - lon1) * j / count
points.append((lat, lon))
-def send(conn, lat, lon, course, alarm, ignition):
+def send(conn, lat, lon, course, alarm, ignition, speed):
params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course))
if alarm:
params = params + (('alarm', 'sos'),)
if ignition:
params = params + (('ignition', 'true'),)
+ params = params + (('speed', speed),)
conn.request('GET', '?' + urllib.urlencode(params))
conn.getresponse().read()
@@ -59,6 +61,10 @@ while True:
(lat2, lon2) = points[(index + 1) % len(points)]
alarm = ((index % 10) == 0)
ignition = ((index % len(points)) != 0)
- send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), alarm, ignition)
+ if (index % len(points)) != 0:
+ speed = device_speed
+ else:
+ speed = 0
+ send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), alarm, ignition, speed)
time.sleep(period)
index += 1