aboutsummaryrefslogtreecommitdiff
path: root/tools/test-generator.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/test-generator.py')
-rwxr-xr-xtools/test-generator.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/test-generator.py b/tools/test-generator.py
index 7f8916f4d..9e9cf892e 100755
--- a/tools/test-generator.py
+++ b/tools/test-generator.py
@@ -5,6 +5,7 @@ import math
import urllib
import httplib
import time
+import random
id = '123456789012345'
server = 'localhost:5055'
@@ -33,7 +34,7 @@ for i in range(0, len(waypoints)):
lon = lon1 + (lon2 - lon1) * j / count
points.append((lat, lon))
-def send(conn, lat, lon, course, speed, alarm, ignition, accuracy):
+def send(conn, lat, lon, course, speed, alarm, ignition, accuracy, rpm, fuel):
params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course), ('speed', speed))
if alarm:
params = params + (('alarm', 'sos'),)
@@ -41,6 +42,10 @@ def send(conn, lat, lon, course, speed, alarm, ignition, accuracy):
params = params + (('ignition', 'true'),)
if accuracy:
params = params + (('accuracy', accuracy),)
+ if rpm:
+ params = params + (('rpm', rpm),)
+ if fuel:
+ params = params + (('fuel', fuel),)
conn.request('GET', '?' + urllib.urlencode(params))
conn.getresponse().read()
@@ -64,6 +69,8 @@ while True:
alarm = (index % 10) == 0
ignition = (index % len(points)) != 0
accuracy = 100 if (index % 10) == 0 else 0
- send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), speed, alarm, ignition, accuracy)
+ rpm = random.randint(500, 4000)
+ fuel = random.randint(0, 80)
+ send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), speed, alarm, ignition, accuracy, rpm, fuel)
time.sleep(period)
index += 1