Taking pictures every 2 minutes

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

This guide explains how to take 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 device with supported camera connected.
  • Camera plugin installed
  • 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

1. Enable Script Expressions.

2. Create an Event Rule:  On step 4. Expressions select Script Expression.

3. Add the following script: 

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.

mceclip0.png

4. Insert an End 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.

mceclip1.png

5. Set 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.

6. Select the _TakeOnePicture command:

mceclip2.png

_TakeOnePicture does not download the picture taken which makes the command quicker but the pictures have to be downloaded later on.

7. Don't select 6. Presentation and click Next to save your rule.

Downloading the pictures

To download the pictures taken look for the Commands panel located by default under the map on the application:

mceclip3.png

The command that should be used to retrieve the pictures taken should be _TryGetAllPictures displayed on the picture above.