d
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
cse47242 0841ac1d7f Update 'README.md' 3 years ago
src Upload files to 'src' 3 years ago
test Upload files to 'test' 3 years ago
LICENSE Initial commit 3 years ago
README.md Update 'README.md' 3 years ago
docker-compose.yml Upload files to '' 3 years ago
index.js Update 'index.js' 3 years ago
package-lock.json Upload files to '' 3 years ago
package.json Upload files to '' 3 years ago

README.md

IoT Dummy Data Generator

Spawn dummy IoT devices and generate custom data that can be send to some data store.

  • Test data store performance
  • Generate dummy data to play with
  • Simulate real-time usage

Installation

IoT Dummy Data Generator requires Node.js v6+ to run.

Requires docker to run example code.

To run example, install the dependencies and devDependencies and start project with docker-compose.

$ npm install -d
$ docker-compose up -d

This will create InfluxDB, Chronograf and IoT Dummy Data Generator containers

You can enter IoT Dummy Data Generator container to execute commands with the command below:

docker exec -ti iot-dummy-data-generator-master_chronograf_1 bash

To start the data generator in a terminal located in the home folder of this project use the following command:

node index.js

Afterwards open browser to

http://localhost:8888 or if it does not work find the IP from net tools (ifconfig), usually some form of 172.0....

and use Chronograf UI to visualize generated data.

In Chronograf go to the influx DB Admin tab and create a database named "dummy-data" so that the data created by the fake devices have a database to be stored

after creating the database just go to the "explore" tab and select the type of data you want to see and from which device they derive from (for example select the "airforce" data type and select the device id you want to track, lastly select "value" on the right for the data to be displayed)

Usage

const FakeDeviceManager = require('./src/fake-device-manager')
const FakeDeviceConnection = require('./src/fake-device-connection')

const connection = FakeDeviceConnection()

const deviceManager = FakeDeviceManager({
  deviceCount: 10,
  metricsInterval: 30000,
  connection: FakeDeviceConnection,
  onUpdateStats: updateStats,
  measurements: {
    temperature: {type: 'integer', min: -20, max: 60},
    air_humidity: {type: 'integer', min: 20, max: 100},
    ground_humidity: {type: 'integer', min: 20, max: 100},
    airforce: {type: 'integer', min: 0, max: 10}
  }
})
deviceManager.start()
console.log('Generating data')

API Reference

FakeDeviceManager

Use FakeDeviceManager to spawn multiple FakeDevice instances with the same behavior. Multiple manager instances can be used in parallel to create multiple FakeDevice groups with different behavior.

When invoking FakeDeviceManager instance, you can set the following options:

  • connection: Data store connection. (Use FakeDeviceConnection that write to Influx database to start with)
  • deviceCount: Number of FakeDevice instances that will be spawned. (Default: 100)
  • spawnInterval: Number of milliseconds to wait until new FakeDevice instance is spawned. (Default: 200)
  • metricsInterval: Metrics interval in ms to pass to each spawned instance. (Default: 200)
  • sendInterval: Send interval in ms to pass to each spawned instance. (Default: 15000)
  • measurements: Measurements array to pass to each spawned instance.

Methods

  • start: Start spawning FakeDevice instances
  • stop: Stop all spawned instances
  • getDevices: Get device list array
  • getStats: Get stats object

FakeDevice

Immitates the behaviour of real IoT device. Generates defined measurements in specified interval and submits data to data source. Used by FakeDeviceManager, but can also be invoked as stand alone instance.

When invoking FakeDevice instance, you can set the following options:

  • deviceId: Device identifier. Usually unique integer or string value.
  • connection: Data store connection. (Use FakeDeviceConnection that write to Influx database to start with)
  • metricsInterval: Metrics interval in ms to pass to each spawned instance. (Default: 200)
  • sendInterval: Send interval in ms to pass to each spawned instance. (Default: 15000)
  • measurements: Measurements array to pass to each spawned instance.
  • autoStart: If set to true, instance will start immediately. (Default: false)
  • onSendData: Function to be invoked after each send data interval.

Methods

  • start: Start spawning FakeDevice instances
  • stop: Stop all spawned instances
  • send: Send data to data store
  • getData: Get data buffer