diff options
author | Abyss777 <abyss@fox5.ru> | 2016-08-19 10:45:33 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-08-19 10:45:33 +0500 |
commit | 1c7437d6de01fffbe3f69853717808b1790413fd (patch) | |
tree | ae6fa7144b30321e754773af4a2d464c9e52c624 /tools/test-generator.py | |
parent | 3826a93f1009942e22ec80c1e13be71e8e917b01 (diff) | |
download | trackermap-server-1c7437d6de01fffbe3f69853717808b1790413fd.tar.gz trackermap-server-1c7437d6de01fffbe3f69853717808b1790413fd.tar.bz2 trackermap-server-1c7437d6de01fffbe3f69853717808b1790413fd.zip |
- Added trips report
- Refactored reports models
- Added tests for ReportUtils
- Added speed to test-generator.py
- Other changes
Diffstat (limited to 'tools/test-generator.py')
-rwxr-xr-x | tools/test-generator.py | 10 |
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 |