diff options
Diffstat (limited to 'tools/test-generator.py')
-rwxr-xr-x | tools/test-generator.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/tools/test-generator.py b/tools/test-generator.py index a23e2576e..7f8916f4d 100755 --- a/tools/test-generator.py +++ b/tools/test-generator.py @@ -33,13 +33,14 @@ 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, speed): - params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course)) +def send(conn, lat, lon, course, speed, alarm, ignition, accuracy): + params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course), ('speed', speed)) if alarm: params = params + (('alarm', 'sos'),) if ignition: params = params + (('ignition', 'true'),) - params = params + (('speed', speed),) + if accuracy: + params = params + (('accuracy', accuracy),) conn.request('GET', '?' + urllib.urlencode(params)) conn.getresponse().read() @@ -59,12 +60,10 @@ conn = httplib.HTTPConnection(server) while True: (lat1, lon1) = points[index % len(points)] (lat2, lon2) = points[(index + 1) % len(points)] - alarm = ((index % 10) == 0) - ignition = ((index % len(points)) != 0) - if (index % len(points)) != 0: - speed = device_speed - else: - speed = 0 - send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), alarm, ignition, speed) + speed = device_speed if (index % len(points)) != 0 else 0 + 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) time.sleep(period) index += 1 |