Create a report from an event rule
When generating an EV1000 report based on an Event Rule, you might need to display some variables to better understand that report. You may also prefer to include additional information, like the temperature that triggered the event or the max speed during the event.
This article will show you how to create a report from an event rule and include parameters.
A feature that we call Report Argument allows you to add variables directly into the EV1000 event rule report.
The best way to understand the report argument feature is by using an example, so let's assume we want to create a report based on a typical speeding event rule. When we generate the standard EV1000 report, we will get the usual information. Using report argument, we can easily include the speed that triggered the event and the max speed. To do this, we add those 2 notifications:
No changes are required on the report itself. After adding the two notifications, the report will look like this:
Here is a list of variables you can add.
With GpsGate, you can use the report argument notification type on event rules.
In many cases, it is useful to use the function utility to get a more suitable result from a variable. Another practical example is the maximum or minimum speed of a vehicle during an event. There are in total 5 functions that can be used in conjunction with variables:
$START: The first value of the variable when the event starts
$END: The last value of the variable when the event is still active but is about to end
$FINAL: The final variable value when the event ended
$MIN: The minimum value of the variable while the event is active
$MAX: The maximum value of the variable while the event is active
By default, the value of the variable is the first value when the event starts; it behaves the same with the $START Function.
You have an event rule monitoring a temperature signal over 10 degrees.
The event rule has processed the following temperature values: [5, 11, 13, 12, 9]
The output for the different functions will be:
$FIRST([Temperature]) -> 11
$END([Temperature]) -> 12
$FINAL([Temperature]) -> 9
$MIN([Temperature]) -> 11
$MAX([Temperature]) -> 13
Localized (for developers)
Report arguments are localized. When creating custom reports including SUM/AVG/MIN/MAX functions, you may be using a culture (time/date display) setting generating decimal values with commas instead of dots, e.g. 45,3 instead of 45.3. That will generate an error in your reports since SUM/AVG/MIN/MAX can only handle decimal values with dots (and not commas). One solution is to modify "45,3" to "45.3". You can do that using this syntax in your report query:
SELECT REPLACE(price,',','.') AS price, REPLACE(lastprice,',','.') AS lastprice FROM products
We aren't using invariant culture in these examples, since we most often want report arguments to be localized. However, you can read more about invariant culture here.