aboutsummaryrefslogtreecommitdiff
path: root/tools/test-generator.py
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-12 14:22:03 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-12 15:20:07 +0500
commitb19f1a505f7088ff48f467b32b5f1c207aa3be01 (patch)
tree663ef14ec15af04e5d9062c2185cd020fb5b9e42 /tools/test-generator.py
parent4f3830d844dd0542e9e7b09e7a6c17ffbb796264 (diff)
downloadtrackermap-server-b19f1a505f7088ff48f467b32b5f1c207aa3be01.tar.gz
trackermap-server-b19f1a505f7088ff48f467b32b5f1c207aa3be01.tar.bz2
trackermap-server-b19f1a505f7088ff48f467b32b5f1c207aa3be01.zip
- Handle rfid attributes and populate driverUniqueId
- Add Driver Name to Trip report
Diffstat (limited to 'tools/test-generator.py')
-rwxr-xr-xtools/test-generator.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/test-generator.py b/tools/test-generator.py
index 9e9cf892e..47c1c478f 100755
--- a/tools/test-generator.py
+++ b/tools/test-generator.py
@@ -12,6 +12,7 @@ server = 'localhost:5055'
period = 1
step = 0.001
device_speed = 40
+driver_id = '123456'
waypoints = [
(40.722412, -74.006288),
@@ -34,7 +35,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, rpm, fuel):
+def send(conn, lat, lon, course, speed, alarm, ignition, accuracy, rpm, fuel, rfid):
params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course), ('speed', speed))
if alarm:
params = params + (('alarm', 'sos'),)
@@ -46,6 +47,8 @@ def send(conn, lat, lon, course, speed, alarm, ignition, accuracy, rpm, fuel):
params = params + (('rpm', rpm),)
if fuel:
params = params + (('fuel', fuel),)
+ if rfid:
+ params = params + (('rfid', rfid),)
conn.request('GET', '?' + urllib.urlencode(params))
conn.getresponse().read()
@@ -71,6 +74,7 @@ while True:
accuracy = 100 if (index % 10) == 0 else 0
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)
+ rfid = driver_id if (index % len(points)) == 0 else False
+ send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), speed, alarm, ignition, accuracy, rpm, fuel, rfid)
time.sleep(period)
index += 1