Trip and Idle in Event Rule Reports
Trip and idle data can now be combined with tools available in Event Rules for use in Event Rule reports. In this example, we will create a report that shows total duration of trip time and total of duration idle time within periods spent outside a Geofence.
You should have the latest version of Patch.v4 installed, be familiar with creating reports and using Script Expressions in Event Rules.
Trip/Idle in Script Expressions
Trip and idle data is a part of reporting data available only if you set the Event Rule that you want to use it in to Disabled. This way, rule is not evaluated in live mode, but you can still generate reports for it.
In the Expressions section, add a Script Expression and edit it. New report object can be used to access trip and idle information.
Click on elements of the “report” object in the “Exposed objects and test values” panel to see additional information (same goes for other items in the panel).
This new data could be used to regenerate a Trip/Idle-like report through events. This script would include:
- creating events using
reporting the current duration by
ending the events on trip/idle state change by
However, the key power of the newly available data is in combining it with the rest of the tools available in Script Expressions.
Example: Trip/idle While Outside Geofences
Let us say that we want to collect the total duration of trip time and total of duration idle time within periods spent outside a Geofence, and also track the time that has passed from the previous event.
This can be done using the script below. See the comments in the script to see what it does and why.
You may wish to remove the comments before saving the rule so as not to exceed the maximum allowed length of the script.
In the Notifiers section, add Report Argument notifiers corresponding to event variables set from the script, like in the picture below.
Using $FINAL(), we can correctly pick up the value of the variables set from the script even if they were set during an evaluation in which the event was switched off.
Now save the rule, and run the default “Event Rule” report for this rule.
The result should look something like this.
- You can use report.tripIdle.useParkedVariable(strVarName) at the beginning of a script to specify a mapped field that will be interpreted as an “Ignition” or “Engine” variable and further split the “idle” state into “idle” (idle with engine running) and “parked” (idle with engine off) states.
- When testing the script from the editor using the Test Script button, enter the exact UTC time of an existing track point for the user selected in the vehicle list into the trackPoint.utcTimestamp field in the editor. For the test run, values in the report object should represent the expected values at that track point.
Discuss this blog post on the forum please