Trip & Idle with parking report

This guide explains how to use a more advanced Trip & Idle report which contains the possibility to handle the Parking state.

In this report:

  • Idling: Engine On / No movement
  • Parking: Engine Off / No movement

(click in the image to enlarge)preview

Report setup

1. Download this Zip. Content:

  • Trip & Idle & Parking (Detailed).xml > the report.
  • Trip Idle Parking Rule.xml > Event Rule that collects data.

2. Import the report, following this guide.

3. Enable the imported report into your application following this guide.

4. Login to your application.

5. Import the Trip Idle Parking Rule following this guide.

6. Navigate to Reports > Manage Reports.

7. At the bottom of the window select Trip & Idle & Parking (Detailed) report definition and click Open.

8. Select a Tag for testing.

9. Select the Trip Idle Parking Rule in the Event Rule list, and mark the hide checkbox next to it.

10. Click Save.

11. Select a period where you have test data with ignition variable and click Preview to see your report.    parameters

Customizations

Adding Parking State

To use a different variable for the indication of the parking state, you need to modify the script expression in the event rule:

1. Go To Admin > Event Rules and open the Trip Idle Parking Rule

2. Go to the 4. Expression part and click the Edit button.
(If the Edit button is disabled you need to enable _EditScriptExpression privilege to your application. Read more here).

3. Find the line containing report.tripIdle.useParkedVariable('Ignition'); and change it to another variable you have used in your device mapper that defines the parking state.

// This scipt creates events that correspond to trip states.
// Use Ignition=Off to indicate parking state.
report.tripIdle.useParkedVariable('Ignition');
if (report.tripIdle.state == 'sleep') {
    return false;
}
if (report.tripIdle.hasChanged) {
    // End the ongoing event that corresponds to the previous trip state.
    context.endEvent(report.tripIdle.previousState);
}
if(report.context.isLastInDay) {
    // Avoid events to span multiple days.
    context.endAllEvents();
} else {
    var tripState = report.tripIdle.state;
    // Start an event for the current trip state.
    // If it is started it will be kept ongoing.
    context.startEvent(tripState);
    // Set the variable for the ReportArgument notifier that stores the Trip state.
    context.setVariable('TRIP_STATE', tripState);
}
return false;

4. Click Save.

5. Reprocess tracking data to see the new changes in your report.

Adding Driver information 

To add a driver for the trip, you need to modify the script expression in the event rule:

1. Go To Admin > Event Rules and open the Trip Idle Parking Rule

2. Go to the 4. Expression part and click the Edit button.
(If the Edit button is disabled you need to enable _EditScriptExpression privilege to your application. Read more here)

You will see this script in the script editor as shown above

3. Replace the existant expression for this one instead:

// This scipt creates events that correspond to trip states.
// Use Ignition=Off to indicate parking state.
report.tripIdle.useParkedVariable('Ignition');
if (report.tripIdle.state == 'sleep') {
return false;
}
if (report.tripIdle.hasChanged) {
//Adds Driver information to the trip
if(session.driver != null){
context.setVariable("DriverName", session.driver.name,report.tripIdle.previousState);
}
// End the ongoing event that corresponds to the previous trip state
context.endEvent(report.tripIdle.previousState);
}
if(report.context.isLastInDay) {
// Avoid events to span multiple days.
context.endAllEvents();
} else {
var tripState = report.tripIdle.state;
// Start an event for the current trip state.
// If it is started it will be kept ongoing.
context.startEvent(tripState);
// Set the variable for the ReportArgument notifier that stores the Trip state.
context.setVariable('TRIP_STATE', tripState);
}
return false;

4. Add a Report Argument using $FINAL([DriverName])

5. Click Save.

6. Reprocess tracking data to see the new changes in your report.

Note: as shown above, if you have modified the useParkedVariable from Ignition to another variable name, replace it in this script too.

Adding more columns to your reports

You can add more columns using ReportArguments. Here is a list of variables you can add.

Please note that you need to re-process the report after you have made any change to the Event Rule for the changes to take effect on historical data.

Troubleshooting

  • Problem: I only see Run and Parked trip state and I never see Idle.
    Solution: You may have problem with the variable that indicates the parking state. Check if it is mapped correctly using the DeviceMapper and TrackPoints panel.
  • Problem: I customized the event rule, but I do not see the changes I made when rendering a new report.
    Solution: Event rule modification does not affect the reporting data that has already been processed. You need to reprocess it to see the changes