Trip and Idle and Parking report using event rule

Scripting is a very powerful tool inside GpsGate server when it comes to customization. In this example we will show you how to use scripting to extend trip and idle report with parking state.


Stay with me even if you are not familiar with scripting. We provide you templates to make the setup easier, however we recommend you to get familiar with basic concepts of reporting before moving on. The vehicles must provide a variable(Ignition or Engine on) to denote the parking state when idling. You just need to follow this guide to get a report like this (click on the image to enlarge):
preview

Setup:
  1. Download this Zip, you will find a report definition (Trip & Idle & Parking (Detailed).xml), and an event rule (Trip Idle Parking Rule.xml) inside that we will import shortly.   You may ask why an event rule has anything to do with a trip/idle/parking report. In this case the event rule generates the data for the report, it is only active for reporting and it contains a script expression to create events that correspond to trip states.
  2. Go to SiteAdmin -> Import. Select template from the drop-down list and browse Trip & Idle & Parking (Detailed).xml file that contains the report definition and click Import.
  3. Go to SiteAdmin -> Applications -> Search and Manage, select an application for testing. In the Privileges and Features section,   make sure you have the Admin/_ImportTemplate feature and Plugins/Reporting/_CreateReport/Trip & Idle & Parking (Detailed) enabled for your application.
  4. Log in to the application. In the Admin menu, select Import Template and pick “Trip Idle Parking Rule.xml” file to import the event rule.
  5. Navigate to Reports -> Manage Reports. At the bottom of the window select “Trip & Idle & Parking (Detailed)” report definition and click Open.
  6. Select a Tag for testing.
  7. Select the Trip Idle Parking Rule in the Event Rule list, and mark the “hide” checkbox next to it, because this report layout was made for that event rule, it does not make sense to use it with different one.
  8. Click Save.
  9. Select a period where you have test data with ignition variable and click Preview to see your report.     parameters
Customizations:
     
  •   To use 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.      
    3. Go to the expression part and click the Edit button.
      (If the Edit button is disabled you need to enable _EditScriptExpression privilege.)
    4.      
    5. You will see this script in the script editor as show below:


    6. Find the line containing report.tripIdle.useParkedVariable(‘Ignition’); and change the Ignition to another variable you want to use.
    7. Click Save and you are ready to go.
  • You can add more ReportArgument notifier to the event rule.
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
Related guides:


Download free GpsGate Server

Install it on your own server. The installation is free for 5 users.

Download Now