Eco Report Scripted

The Eco Scripted report measures harsh driving, speeding, use of seat belt and idling and it produces an eco score for each vehicle.

Requirements and installation

1. Follow the ECO report setup guide until Configure the RPT_Speeding Event Rule section included.

2. Download this .zip file and extract the XML-files in your computer.

3. Import the event rule Eco Report.xml in VehicleTracker. See this article to know how to import an Event Rule in your application.

4. Open the event rule, and make sure the rule is disabled for live processing. You can do this by selecting this parameter and set it in No.


Configuring ECO scripted report weight parameters

The reports show a single score for each vehicle based on the harsh events and idling time. To do this, a formula is used, based on the following parameters:

Eco Formula
EventOccurrences (harsh braking, acceleration, turning, over speeding, use of seat belt, + any wanted measurements)
Score = Weight * EventOccurrences / Distance   + IdleTime / (IdleTime+ TripTime)

The weights are defined as variables in the script. Look for the passage in the script that is enclosed with //Replace below to get “Custom Fields” and //Replace above to get “Custom Fields” and adjust them if necessary.

For each “Harsh” parameter the default value is 30. Preview the report to determine if any of the weights need to be altered. Note: You might want to use different weights for different for trucks, cars, etc, in the same Application. For that purpose, please have a look at Using Custom Fields further down.

See Modify Script below for more info, (steps 2-5 and 8-11).

Modifying the Script

  1. Choose an editor, e.g. Notepad++.
  2. In the application, open the Admin > Event Rules window.
  3. Notice the new rule called Eco Report that you just imported. This rule includes a Script Expression including most of the calculations for the report.
  4. Click Edit in the Script Expression under the 4. Expression section
  5. Get familiar with the output of the script by pressing the test button and observe the result
  6. Copy the whole script and paste it into the editor.
  7. Open one of the files, (included in the .zip-file you just downloaded), called EcoAddFunctionality.txt
  8. Modify your script, see different alternatives below.
  9. Make sure the script runs, accept and save the event rule.
  10. Make sure to reprocess the data for the report. Read how to reprocess a report.
  11. Generate the report and see updated results.

Optional: Using Real Speed Limits

  1. Install the SpeedingExpression plugin.
  2. Follow steps 1-7 in the Modify Script section.
  3. Replace what’s in between Replace below - “Get Dynamic Speedlimits from OSM” and Replace above - “Get Dynamic Speedlimits from OSM”. There are two parts; a function and some variables. Both are needed.
  4. Follow steps 9-11 in the “Modify Script” section.

Optional: Using Custom Fields

You might want to use different weights for different trucks, cars, etc., in the same application:

  1. Follow steps 1-7 in the “Modify Script” section.
  2. Replace what’s in between Replace below - “Get Custom Fields” and Replace above - “Get Custom Fields”.
  3. Create these custom_fields and use them in the script, e.g. ‘harshAccWeight’ in the picture below.
  4. Follow steps 9-11 in the “Modify Script” section.
//Replacebelow toget "Custom Fields"
var harshAccWeight = parseFloat(session.user.getCustomFieldValue('harshAccWeight') || 0);
var harshBrakeWeight = parseFloat(session.user.getCustomFieldValue('harshBrakeWeight') || 0);
var harshTurnWeight = parseFloat(session.user.getCustomFieldValue('harshTurnWeight') || 0);
var oSpeedWeight = parseFloat(session.user.getCustomFieldValue('oSpeedWeight') || 0);
var sBeltWeight = parseFloat(session.user.getCustomFieldValue('sBeltWeight') || 0);
var tripIdleWeight = parseFloat(session.user.getCustomFieldValue('tripIdleWeight') || 0);
var excellent = parseFloat(session.user.getCustomFieldValue('excellent') || 0);
var good = parseFloat(session.user.getCustomFieldValue('good') || 0);
var fair = parseFloat(session.user.getCustomFieldValue('fair') || 0);
//Replaceabove toget "Custom Fields"


Optional: Report driver instead of the vehicle

If you have a driver connected to your vehicle you can report that driver instead of the vehicle:

  1. In the application, open the Admin > Event Rules window.
  2. Alter “Who this rule applies to” to a tag with your drivers instead of your vehicles
  3. Follow steps 1-7 in the “Modify Script” section.
  4. Search for the lines of code below in the script and comment out driver.username in 3 different places so that the script looks like the code below.
  5. Follow steps 9-11 in the “Modify Script” section.
//DriverOrVehicle: session.driver.username, // place 1
DriverOrVehicle: session.vehicle.username, //
//var newDriverOrVehicle = (state.DriverOrVehicle != session.driver.username);//place 2
var newDriverOrVehicle = (state.DriverOrVehicle != session.vehicle.username);
//state.DriverOrVehicle = session.driver.username; // place 3
state.DriverOrVehicle = session.vehicle.username;

Strategy for adjusting your report

One strategy to get useful weights and evaluation criteria is to record drivers you know to drive well. Let the resulting score define “Excellent” driving. Record the same driver when driving badly for a day or two, and let that score define “Fair” or “Risky” driving.
If you prefer to exclude the idling time points in your score, just edit the “Score” column according to this:

//Total Score
//Score per day

instead of this:

//Total Score
$math.round(($sum([EventArgument12])/$sum([EventArgument])) + $sum([EventArgument15])/($sum([EventArgument13])+$sum([EventArgument14])))
//Score per day
$math.round(([EventArgument12]/[EventArgument]) + [EventArgument15] / ([EventArgument13] + [EventArgument14]))

If you prefer to exclude seat belt points, modify the script according to this:

eventScore = accPts + brakePts + turnPts + oSpeedPts;

instead of this:

eventScore = accPts + brakePts + turnPts + oSpeedPts + sBeltPts;