aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-04-17 17:25:05 -0700
committerAnton Tananaev <anton@traccar.org>2022-04-17 17:25:05 -0700
commitade1d98a4ee19265acff946716d6f5a6af5ce58d (patch)
tree3a0d3accb880d11e50f73bcd4eee141f7fbc3d4f
parentef8cfea50d6ca763a4af6eb75287325e91f5f5ca (diff)
downloadtrackermap-server-ade1d98a4ee19265acff946716d6f5a6af5ce58d.tar.gz
trackermap-server-ade1d98a4ee19265acff946716d6f5a6af5ce58d.tar.bz2
trackermap-server-ade1d98a4ee19265acff946716d6f5a6af5ce58d.zip
Add battery level test
-rwxr-xr-xtools/test-generator.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/test-generator.py b/tools/test-generator.py
index ca7871e1d..b8a06ac32 100755
--- a/tools/test-generator.py
+++ b/tools/test-generator.py
@@ -35,12 +35,14 @@ 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, driverUniqueId):
- params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course), ('speed', speed))
+def send(conn, lat, lon, course, speed, battery, alarm, ignition, accuracy, rpm, fuel, driverUniqueId):
+ params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course), ('speed', speed), ('batt', battery))
if alarm:
params = params + (('alarm', 'sos'),)
if ignition:
params = params + (('ignition', 'true'),)
+ else:
+ params = params + (('ignition', 'false'),)
if accuracy:
params = params + (('accuracy', accuracy),)
if rpm:
@@ -70,11 +72,12 @@ while True:
(lat2, lon2) = points[(index + 1) % len(points)]
speed = device_speed if (index % len(points)) != 0 else 0
alarm = (index % 10) == 0
+ battery = random.randint(0, 100)
ignition = (index % len(points)) != 0
accuracy = 100 if (index % 10) == 0 else 0
rpm = random.randint(500, 4000)
fuel = random.randint(0, 80)
driverUniqueId = driver_id if (index % len(points)) == 0 else False
- send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), speed, alarm, ignition, accuracy, rpm, fuel, driverUniqueId)
+ send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), speed, battery, alarm, ignition, accuracy, rpm, fuel, driverUniqueId)
time.sleep(period)
index += 1