Create fatigue alerts with scripting

We show you how scripting is used to measure that drivers follow regulations about driving hours and rest periods.


This article is another example of how to create advanced solutions using script expressions. For more information about script expressions, see this article.

We will create a fatigue event rule that will check that your drivers are not driving for too long periods, 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.

Installation

The fatigue script is available as an exported event rule. Follow these steps to install it:

  1. Go to SiteAdmin / Plugins.
  2. Upgrade or install Patch.v4 from the http://beta.gpsgate.com/ repository.
  3. Download this XML file. Import in VehicleTracker. See this article for help.
Features

These are the regulations that the script is monitoring:

  1. Daily driving period shall not exceed 9 hours, with an exemption of twice per week when it can be extended to 10 hours.
  2. Total weekly driving time may not exceed 56 hours and the total fortnightly driving time may not exceed 90 hours.
  3. 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 9 hour rest to make a total of 12 hours daily rest.
The script

Download the script here. Unpack 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 need to 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 really know what you are doing. 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 blog 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 information how you setup custom fields.

                                                                                                                                                                                                                                                                                                                           
VariableDescription
minContinuousRestThe least amount of rest needed before actually counting it as resting. The value should be in number of minutes. Default: 180 (3 hours)        
minDailyRestThe minimum rest per day (per 24 hours). The value should be in number of minutes. Default: 660 (11 hours)        
minDailyRestExemptionExemption to the minDailyRest rule, that can be violated maxRestExemptions times. The value should be in number of minutes. Default: 540 (9 hours)        
maxRestExemptionsNumber of times minDailyRest can be violated. This is reset every Monday. Default: 3        
maxDailyDrivingThe maximum driving time per day (per 24 hours). The value should be in number of minutes. Default: 540 (9 hours)        
maxDailyDrivingExemptionExemption to the maxDailyDriving rule, that can be violated maxDrivingExemptions times. 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        
drivingExemptionResetTimeSee maxDrivingExemptions. The value should be in number of minutes. Default: 10080 (every week)        
maxWeeklyDrivingThe maximum driving time per week. The value should be in number of minutes. Default: 3360 (56 hours)        
maxFortnightlyDrivingThe maximum driving time fortnightly. The value should be in number of minutes. Default: 5400 (90 hours)        
Output

When a driver break any of the rules mentioned above (see Features), an event will be triggered. How you use these events is up to you. Maybe you just want a notification in the GUI, or maybe 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.

                                                                                                                                                                                                                                       
VariableDescription
ReasonContains the rule that was broken. (minDailyRest, drivingExemptions, maxDailyDriving, maxWeeklyDriving, maxFortnightlyDriving)
DailyRestThe amount of rest today (in minutes).
RestExemptionsLeftNumber of exemptions left regarding the resting rules.
DailyDrivingThe amount of driving today (in minutes).
WeeklyDrivingThe amount of driving this week (in minutes).
FortnightlyDrivingThe amount of fortnightly driving (in minutes);
DrivingExemptionsLeftNumber of exemptions left regarding the driving rules.

  Discuss this blog post on the forum please



Download free GpsGate Server

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

Download Now