Create fatigue alerts with scripting
Scripting can be used to ensure that drivers follow regulations about driving hours and rest periods.
This article is another example of how to create advanced solutions using script expressions.
The fatigue event rule checks that drivers are not driving for too long and that they are resting sufficiently.
Installation
- Download this XML file. Import it in the application.
- Import it using this article for help.
Features
Regulations the script is monitoring (based on European Union regulations):
- 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.
The script
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.
|
var driving = fields.get( 'Engine on' , false ) == 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.
Customization
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.
Variable | Description |
---|---|
minContinuousRest | The least amount of rest needed before actually counting it as resting. The value should be in number of minutes. Default: 180 (3 hours). |
minDailyRest | The minimum rest per day (per 24 hours). The value should be in number of minutes. Default: 660 (11 hours). |
minDailyRestExemption | Exemption to the minDailyRest rule that can be violated maxRestExemptions times. The value should be in number of minutes. Default: 540 (9 hours). |
maxRestExemptions | Number of times minDailyRest can be violated. This is reset every Monday. Default: 3. |
maxDailyDriving | The maximum driving time per day (per 24 hours). The value should be in number of minutes. Default: 540 (9 hours). |
maxDailyDrivingExemption | Exemption to the maxDailyDriving rule that can be violated maxDrivingExemptionstimes. The value should be in number of minutes. Default: 600 (10 hours). |
maxDrivingExemptions | Number of times maxDailyDriving can be violated. This is reset every drivingExemptionResetTime. Default: 2. |
drivingExemptionResetTime | See maxDrivingExemptions. The value should be in number of minutes. Default: 10080 (per week). |
maxWeeklyDriving | The maximum driving time per week. The value should be in number of minutes. Default: 3360 (56 hours). |
maxFortnightlyDriving | The maximum driving time per fortnight/two weeks. The value should be in number of minutes. Default: 5400 (90 hours). |
Output
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. Specific information about event rule reports can be found here.
Variable | Description |
---|---|
Reason | Contains the rule that was broken (minDailyRest, drivingExemptions, maxDailyDriving, maxWeeklyDriving, maxFortnightlyDriving) |
DailyRest | The amount of rest today (in minutes) |
RestExemptionsLeft | Number of exemptions left regarding the resting rules |
DailyDriving | The amount of driving today (in minutes) |
WeeklyDriving | The amount of driving this week (in minutes) |
FortnightlyDriving | The amount of fortnightly driving (in minutes) |
DrivingExemptionsLeft | The number of exemptions remaining for the driving rules |