Taking pictures every 2 minutes

Taking pictures every 2 minutes depending on input signals from the device.

This guide explains how to take a pictures every 2 minutes with Meitrack MVT600 device taking into account input signals from the device.

Prerequisites

In order to complete this task successfully it will be needed:

  • - A Meitrack MVT600 device with supported camera connected
  • Camera plugin installed
  • - Upgraded Meitrack plugin from beta repository. Log in SiteAdmin/Plugins write the name of the repository (beta.gpsgate.com) and press enter. Upgrade the Meitrack plugin.
  • - The interval time for the message updates from the device has to be shorter than the take picture action ( less than 2 minutes for this example)

Creating the Event Rule

The first step is creating an Event Rule. Log in the Vehicle Tracker application and select the Admin menu, then open the Event Rules and press Add new Event Rule button. On step 4 Expressions select Script Expression, there is more information on Script Expressions in this blog post:

http://gpsgate.com/blogComment/script_expressions

The following script activates the rule every 2 minutes:

var INTERVAL = 120000; // miliseconds for 2 min
 
if (!context.state) {
    // "active" first time (no set state)
 
      context.setState(new Date().getTime());
    return true;
}
else {
    // not first time, since there is stuff in state
 
    var oldDate = new Date(context.state);
    var now = new Date();
 
    var diffMilis = now.getTime() - oldDate.getTime();
 
    if (diffMilis < INTERVAL) {
      // interval didn't pass yet
      return false;
    }
    else {
      // interval passed, trigger again, set new time reference
      context.setState(now);
      return true;
    }
}

Regarding the variables that we want to take into account we can add them as complementary expressions.complementary 2 It is also needed to insert an ending expression so the rule is not kept true. Use an expression that will always be true while the rule is active like might be speed greater or equal than 0.ending2 The last step would be setting up the command notification on step 5 Notifications. After selecting Command from the drop-down list, another drop-down list will be displayed with the available commands. Select the _TakeOnePicture command:notification2 There is another command available to take pictures called _TakePicture but should not be used for this purpose. _TakePicturenot only takes the picture but it also downloads it to the server, which takes longer than just taking the picture. _TakeOnePicture does not download the picture taken which makes the command quicker but the pictures have to be downloaded later on.

Downloading the pictures

To download the pictures taken look for the “Commands” section located by default under the map on the application, just below the Geofences section.getpictures The command that should be used to retrieve the pictures taken should be _TryGetAllPictures displayed on the picture above.