This article is an example of how to create advanced solutions using script expressions.
We will create a fatigue event rule that will check that drivers are not driving for too long and that they are resting sufficiently. We use the European Union rules for this example, but it is easy to modify the script for your country’s rules.
Download this XML file. Import it in the application. To import the application, go to Admin => Import Template
These are the regulations that the script is monitoring:
- Daily driving period: shall not exceed 9 hours, with an exemption of twice per week when it can be extended to 10 hours.
- Total weekly driving time: may not exceed 56 hours and the total fortnightly driving time may not exceed 90 hours.
- Daily rest period: shall be at least 11 hours, with an exception of going down to 9 hours maximum three times a week. Daily rest can be split into 3 hours rest followed by a 9 hours rest to make a total of 12 hours daily rest.
Download the script here. Unzip the ZIP file and import the included XML file in VehicleTracker to automatically create an event rule with the fatigue script.
The first line of the script contains the “driving” definition. You can change this to suit your needs. It should be an expression that is true when the vehicle/driver is considered to be driving. The opposite (when it is false) means that the driver is resting. In this example, “driving” is when the “Engine on” signal is true.
The bottom part (the part below the “——Do not edit below this line——” comment) should remain untouched unless you are an expert. Changes to the bottom part of the script are not supported.
You can, however, change more settings by using custom fields. See the Customization section of this article for more information.
The script includes custom fields that you can change to modify the rules to your own needs.
See this article for more information about setting up custom fields.
The least amount of rest needed before actually counting it as resting. The value should be in number of minutes. Default: 180 (3 hours).
The minimum rest per day (per 24 hours). The value should be in number of minutes. Default: 660 (11 hours).
Exemption to the minDailyRest rule that can be violated maxRestExemptions times. The value should be in number of minutes. Default: 540 (9 hours).
Number of times minDailyRest can be violated. This is reset every Monday. Default: 3.
The maximum driving time per day (per 24 hours). The value should be in number of minutes. Default: 540 (9 hours).
Exemption to the maxDailyDriving rule that can be violated maxDrivingExemptionstimes. The value should be in number of minutes. Default: 600 (10 hours).
Number of times maxDailyDriving can be violated. This is reset every drivingExemptionResetTime. Default: 2.
See maxDrivingExemptions. The value should be in number of minutes. Default: 10080 (per week).
The maximum driving time per week. The value should be in number of minutes. Default: 3360 (56 hours).
The maximum driving time per fortnight/two weeks. The value should be in number of minutes. Default: 5400 (90 hours).
When a driver breaks any of the rules mentioned above, an event will be triggered. How you use these events is up to you. You may choose to show a notification in the application interface, or maybe create something more powerful like a report.
The script produces a few variables that you can use in your notifiers and reports.
More general help about notifiers can be found here.
Contains the rule that was broken (minDailyRest, drivingExemptions, maxDailyDriving, maxWeeklyDriving, maxFortnightlyDriving)
The amount of rest today (in minutes)
Number of exemptions left regarding the resting rules
The amount of driving today (in minutes)
The amount of driving this week (in minutes)
The amount of fortnightly driving (in minutes)
The number of exemptions remaining for the driving rules