Matching results

Simulate a fleet of systems with Vleet

Introduction

Vleet is a node.js application which allows you to create a fleet of systems and simulate embedded applications with specific behavior for each data type. Both device and application-generated data can be simulated.

Prerequisite

  • node.js v 4.2 or v 4.3 must be installed on your computer.

Step 1: Install vleet

  1. Install the vleet engine by cloning this Github repository

  2. Install the dependencies: npm install from the root folder

Feature list

  • Create (optionally) a list of systems with their own applications
  • Simulate device data or application-generated data
  • Use a generic or custom simulation function to generate consistent values
  • Generate data using several generation policies (default: data history for the previous days), or implement custom data types.

Step 2: Configure the simulation

First take a look at the config/simulations/trucks.json.template file, which will help you understand how to create your own simulated systems.

Let’s say you want to simulate an alarm system. First create an alarmSystem.json file in the config/simulations folder. (You can have as many simulators as you want.) The name of the file will be used to reference your simulation.

This file contains several sections and data:

  • name: supply a suitable name
  • label: a descriptive label to be added to each system and application
  • fleet: contains information about the fleet to be simulated. If the fleet doesn’t already exist, it will be created.
  • generation: contains information about the data generation
  • application: describes the application to associate to your systems
  • clean: if enabled, this deletes existing systems before starting any simulation (thus recreating the fleet). By default this parameter is set to false.

Example:

{
    "name": "Building",
    "label": "Buildings",
    "fleet": {
       ...
    },
    "generation": {
        ...
    },
    "application": {
        ...
    },
    "clean": false
}

Each section is explained in more detail below.

Fleet description

  • size: Number of systems to simulate.
  • namePrefix: Each created system name will start with this namePrefix, plus an index number. For example: if namePrefix is Truck (note the space at the end), the first system will be Truck 0.

Example:

"fleet": {
        "size": 96,
        "namePrefix": "Asset "
    },

Data Generation description

  • mode: mode name. Used to identify the script which describes how to simulate the fleet (for example: backToTheFuture)
  • options: mode options. The parameter name is the mode name supplied above.
  • data: describes the data to simulate

Example:

"generation": {
        "mode": "backToTheFuture",
        "backToTheFuture": { // Use mode name to specify options for the generation mode
            "nbDaysInPast": 1,
            "valuesPerDay": 10
        },
        "data": {
        }
    }
Generators

This section describes options for some data generators. This section is not exhaustive. Have a look at lib/engine.

backToTheFuture This engine generates values from a given date in the past until the current day:

  • nbDaysInPast:
  • valuesPerDay

Data

This section specifies options that the generator will use for the given data type.

You can use Device Management processed data to display data about connectivity or device (go to References menu > System > Fields and scroll down to the second table).

Default generators are:

  • randomBoolean (no options)
  • randomFloat with the following options:
    • min: the lower limit
    • max: the upper limit
    • fixed: the number of decimal digits
  • incremental with the following options:
    • start: first value
    • step: value to be added to the previous value.

You can add a new generator (see next section).

Example:

"data": {
            "phone.custom.dn.1": {
                "generator": "randomFloat",
                "options": {
                    "min": -5,
                    "max": 35,
                    "fixed": 1
                }
            },
            "phone.custom.dn.2": {
                "generator": "randomBoolean", // Default generator
                "options": {
                    "likelihood": 1
                }
            },
            "_RSSI": {
                "generator": "RSSIGenerator", // Custom generator
                "options": {
                }
            }
        }

Need a custom data generator?

Add these in the custom-generators folder, whatever the filename. The exported function name is the identifier declared in the data section described above. Tip: look at existing generators to help you to create your own.

You can use Chance library , Math library , …

Example:

function RSSIGenerator() {}

RSSIGenerator.prototype.generate = function() {
    return -100 + (Math.round(Math.random() * 30));
};

module.exports = RSSIGenerator;

Application description

This section describes the application associated with the fleet systems. This application will be automatically created for all systems of your fleet. All applicative data must be specified so it can be be used in AirVantage, for example to plot charts. However you don’t need to describe Device Management processed data in this file, as this is already specified for AirVantage.

  • name is the application name as it will be displayed in AirVantage
  • type is the application’s identifier used by AirVantage. This id must be unique in AirVantage. For example, you can add your company name or your project name in the type.
  • data describes the application data and commands in the system. (Only data will be used but you can specify commands if you need). You can simulate a data sub-set if needed. In the example below, you can find the two data types which are simulated in the previous data section.
"application": {
        "name": "SecurityApp",
        "type": "avphone.demo.security",
        "data": [{
            "id": "phone.custom.dn.1",
            "label": "Temperature",
            "elementType": "variable",
            "type": "double"
        }, {
            "id": "phone.custom.dn.2",
            "label": "Leakage",
            "elementType": "variable",
            "type": "boolean"
        },{
              "id": "phone.alarmSystem",
              "label": "Alarm System",
              "description":"The command description",
              "elementType": "command",
              "parameters": [
                 {
                    "id": "TurnON",
                    "defaultValue": true,
                    "defaultLabel": "TurnON",
                    "type": "boolean",
                    "optional": false
                  }]
            }]
        }

If you need help to create an application model manually, refer to the Application Format Reference page and use the following howto .

Final setup

  1. Create a setup.json out of the setup.json.template file.
  2. Provide the name of the simulation you want to run (name of the simulation you created in config/simulations)
  3. Select the AirVantage DataCenter to target: eu or na
  4. Define the company to use by supplying the id, taken from the url when you are logged into a company account in AirVantage
  5. Provide your credentials (or those of a technical user) for the selected AirVantage DataCenter.
{
    "simulation": "building", 
    "dataCenter": "eu", 
    "companyUid": "78c45b83021c450ebefca60635314090",
    "credentials": {
        "username": "rjacolin@sierrawireless.com",
        "password": "t0t0!"
    }
}

Step 3: Simulate the systems

From the root folder, launch npm start to run a fleet simulation.

$ npm start

> virtual-fleet@0.0.1 start /vleet-engine
> node .

Authenticated
Application already exists
Fleet already exists
Start simulation -  Buildings
For  96 systems
start
init engine for mode: backToTheFuture
init "backToTheFuture" engine
send data for system: Asset 210
Generate data for system: Asset 210
Minutes offset by day: 144
Day # 0
Nth value of day: 0 Time : Monday, April 4th 2016, 2:24:00 am
generate value for data: phone.custom.dn.1
## generatorConfig: { generator: 'randomFloat',
  options: { min: -5, max: 35, fixed: 1 } }
generate value for data: phone.custom.dn.2
## generatorConfig: { generator: 'randomBoolean', options: { likelihood: 1 } }
generate value for data: phone.custom.up.1
## generatorConfig: { generator: 'randomBoolean', options: { likelihood: 1 } }
generate value for data: _RSSI
## generatorConfig: { generator: 'RSSIGenerator', options: {} }
generate value for data: _ECIO
## generatorConfig: { generator: 'ECIOGenerator', options: {} }
generate value for data: _BYTES_RECEIVED
## generatorConfig: { generator: 'BytesReceivedGenerator', options: {} }
generate value for data: _BYTES_SENT
...
TOP