Tutorial: Using Device Simulator


The device simulator enables you to simulate a device that connects to and sends data to EnOS without using the EnOS Java SDK. To connect a device by using EnOS Java SDK, see Connecting a Simulated Device to EnOS.


This tutorial is a step-by-step guide on how to use the device simulator to simulate a device to send and view the data sent to EnOS. It will simulate an ammeter to report its reading once every minute, where the data will be stored in the Time Series Database (TSDB). If the current is above 60mA, a “Current is above the threshold” alert will be triggered and sent to EnOS. Both the readings and alert generated (if any) can be viewed in EnOS.

../../../_images/simulated_ammeter.png


The procedure to simulate the ammeter is as follows.

../../../_images/simulated_ammeter_flowchart.png

Before You Start

Procedure

Step 1: Create Model, Product, and Register Device

  1. Create a model for the simulated ammeter using the following parameters. For information on how to create a model, see Creating a Model.

    Model for Simulated Ammeter

    Field

    Value

    Model ID

    test.ammeter

    Model Name

    Simulated Ammeter Model

    Category

    None

    Created From

    No

    Source Model

    No

    Description

    None


  2. Define the following elements for the model created in the above step.


  3. Create a product based on the Simulated Ammeter Model using the following parameters. For information on how to create a product, see Creating a Device Collection (Product).

    Simulated Ammeter Product

    Field

    Value

    Product Name

    Simulated Ammeter Product

    Asset Type

    Device

    Model

    Simulated Ammeter Model

    Data Type

    Json

    Certificate-based Authentication

    Disabled

    Description

    None


  4. Register a device based on the Simulated Ammeter Product, using the following parameters. For information on how to create a device, see Creating a Device.

    Simulated Ammeter Device

    Field

    Value

    Product

    Simulated Ammeter Product

    Device Key

    simulatedAmmeter

    Device Name

    Simulated Ammeter Device

    Time Zone/City

    UTC+08:00

Step 2: Configure TSDB Stroage Policy

To configure the storage policy for the simulated ammeter, go to Time Series Data Management > Storage Policies.

  1. Select an existing group or create a new group. If you select an existing group, click Edit Group. If you create a new group, give a name for the group.

  2. Select test.ammeter for the Group Model and click OK to include the ammeter model into the policy group.

  3. Click edit beside AI Raw Data. Select a storage time from the drop-down list, and select test.ammeter to include all its measurement points into this policy.

    As this tutorial does not require normalized data, Real-time Current is put in AI Raw Data.

Step 3: Configure Alert Rule

For this step, we will create a rule stipulating that when a reading for the Real-time Current exceeds 60mA, a Current is above threshold alert of Warning severity will be immedidately triggered.

  1. In Alert Management > Alert Rules, create a rule as follows. To create a rule, the corresponding severity, type, and content are required. For information on how to create these, see Getting Started with Alert Management.

    Alert Rule Configuration

    Field

    Value

    Rule ID

    ammeter_high_alert

    Select Model

    Simulated Ammeter Model

    Measuring Point

    Real-time Current

    Condition

    >

    Value

    60

    Alert Content

    Current is above threshold

    Alert Severity

    Warning Alert

    Alert Triggering Delay

    0

    Alert Masking

    Disabled

    Enabled

    No

Step 4: Launch Device Simulator

  1. In Device Management > Simulators, create a simulator for the Simulated Ammeter Device. For information on how to create a simulator, see Using the Device Simulator.

    ../../../_images/added_simulated_ammeter.png


  2. Upload the data sample for the Simulated Ammeter Device. For information on how to upload data sample, see Using Device the Simulator.


    In the sample below, there are two columns of data. Column timeOfDay indicates the time from 0:00:00 to 23:59:00 with intervals of one minute. Column current, the identifier for Real-time Current, indicates the measurement point value reported by the device in milliampere.


    When we created the alert rule, the alert threshold was set to 60mA. Therefore, in this sample, the column current needs to have at least one value above 60 in order to trigger the Current is above threshold alert.


    It is recommended to set some values above 60 at earlier moments so that the alerts can be triggered early during the simulation. In the example below, abnormal values are set at 0:02:00, 0:07:00, and 0:10:00, so that the alerts will be triggered at the 2nd, 7th, and 10th minute after starting the simulation.

    ../../../_images/simulator_data_sample.png


  3. Start the simulator, setting the end time for 24 hours later.

    You can actually set the end time to a time of your preference, but setting it much later leaves enough time for the TSDB to absorb enough data to generate a report.

Results

Data Insights

Wait for some time and go to Time Series Data Management > Data Insights. Select the device Simulated Ammeter Device and you will be able to view the Real-time Current data report in one minute intervals.

../../../_images/simulated_ammeter_tsdb_data.png

Alert Record

In Alert > Alert Record, click the History Alerts tab, and select the model Simulated Ammeter Model to view its historical alerts. You can see that several alerts have been triggered by the anormal data.

../../../_images/simulated_ammeter_historical_alerts.png