HTTP Expression can be used to include custom expression in Event Rules. This can be used with live or buffered data that can later be used in reporting.
Another area of usage is to get real-time position updates from GpsGate to another system.
Example of usage
GpsGate will make an HTTP request to a URL specified by you. The URL contains complete time, position, variables and user information. Your service response if the expression evaluates to true or false, and it can also include notification variables.
For instance, if you have a database of different speed limits for different roads and you want an Event Rules which generates an alarm if a specific speed limit is broken. GpsGate makes an HTTP request for each position update, your service makes a look up in the database and returns true or false depending on if the speed limit was broken or not.
1. Go to Site Admin > Plugins > Get More Plugins
2. Install Http Expression
3. Enable Http Expression for your application under Site Admin > Applications > [click in your app] > Privileges and Features
Read how to access the application privileges and features here.
Event Rule setup
1. Inside the application, create an Event Rule
2. On Step 4, select Http Expression.
3. Fill the Url field.
This is the URL to your web service (e.g. http://myserver.com/eventrule.php)
This is an example of a request URL:
POS_LATITUDE, POS_LONGITUDE is position in decimal degrees.
POS_TIME time in UTC/GMT
POS_HEADING heading in degrees. 0 is north.
POS_VALID True if position was up to date at POS_TIME.
USER_USERNAME user in GpsGate.
SIGNAL_SPEED speed in meters per second.
SIGNAL_BARCODE example of variable from device mapper.
Your web service should response with XML in the following format
<HttpExpression> <Result>1</Result> </HttpExpression>
Result = 1 if expression is true, and 0 if false.
Use the "Test Settings" button. It will display the request URL, and the response from your web service. If there are any errors those will be written in clear text.
Read how to test using the device simulator here.
The request URL includes a method= variable which can be test, live, buffer or report.
method=test - The request was made using the Test Settings button.
method=live - Live Gate Message from tracker going forward in time.
method=buffer - Buffered data from device.
method=report - Reporting/Analyze mode.
You can enable the buffer and report methods under "Advanced". By default, those methods are disabled.
Enable "Support notifiers" under "Advanced".
Response XML example with one notifier variable:
Code: Select all
<HttpExpression> <Result>0</Result> <Notification> <Variable> <Name>Hello</Name> <Value>Hello World!</Value> <Type>System.String</Type> </Variable> </Notification> </HttpExpression>
If the web service times out, returns an HTTP error or invalid XML the connection to the device will be closed. Devices/protocols that require an ACK will typically resend the same data again until success.
Timeout and parallel requests
Under Advanced set "Request timeout", which is the time before GpsGate will consider the request to be a time out.
"Max connections" the number of parallel requests that are allowed to be made to your web service.
By default, HTTP Expression will make the request once the message comes in from the device. If the request fails, for example if the 3rd party server is down or overloaded, then the connection to the device is closed. If the device has a re-send mechanism, it will later try to resend the message. This mode is required for HTTP Expression to work as part of a Live Event Rule.
In case you do not need HTTP Expression to be part of any live events, but rather just use it to forward live tracking data to a 3rd party server, you can instead have HTTP Expression send data asynchronously. You enable this under "Advanced" options. If the 3rd party server fails to respond, HTTP Expression will later resend the request, but the connection to the device is not affected.
Extra variables in request URL
You can add custom variables to the service URL. e.g. http://myserver.com/eventrule.php?myvalue=6