Unit 1: Preparing Simulation Data


In this unit, you will learn to create your model and device, setup the storage policies, and store simulation data for later use.

Step 1. Defining a Model

A model is the abstraction of the features of an object that is connected to the IoT Hub. The device model defines the features of a device, including its attributes, measurement points, services, and events.


  1. In the EnOS Management Console, click Models from the left navigation menu.

  2. Click New Model, enter the following in the New Model window, and click OK.

    • Identifier: SmartBattery_Model

    • Model Name: SmartBattery_Model

    • Category: NA

    • Created From: No

    • Source Model: No

    • Validate Model: On

    • Description: Model for smart battery


    ../_images/model_create.png


  3. From the list of created models, click the Edit icon, and then click the Feature Definition tab on the Model Details page.

  4. There are two ways to create custom features:

    • Manually adding features: click Edit > Add > Create Custom Feature, and create the following custom features in the Add Feature window.


      ../_images/feature_add_new.png


    • Importing from a file: Click Edit > Import Model and upload an Excel or JSON file. You can use model_SmartBattery.json in this lab.

  5. Click Publish to save and publish the features you have added above.


For more information on how to create a model, see Creating a Model.


Step 2. Creating a Product

A smart battery product is a collection of battery devices that have the same features. With the model as a base, a product further defines the communication specifications for the device.


In this step, create a product called SmartBattery_Product. We shall assume that a device of this product model sends data in JSON format and that the CA certificate is not used (only secret-based authentication is enforced).


  1. In the EnOS Management Console, select Device Management > Products.

  2. Click New Product, enter the following in the New Product window, and click OK.

    • Product Name: SmartBattery_Product

    • Asset Type: Device

    • Model: SmartBattery_Model

    • Onboarding Method: Only EnOS IoT

    • Certificate-Based Authentication: Disabled

    • Description: Computer Battery


../_images/product_add.png


For details about the configuration of a product, see Creating a Device Collection (Product).

Step 3. Registering a Device

A device is the instance of a model and belongs to a certain product. It inherits not only the basic features of the product, but also its communication features.


In this step, create a device named SmartBattery_Device, which belongs to the SmartBattery_Product created in the previous step.


  1. In the EnOS Management Console, select Device Management > Device Assets.

  2. Click New Device, enter the following in the New Device window, and click OK.

    • Product: SmartBattery_Product

    • Device Name: SmartBattery_Device

    • Device Key: Enter the device key

    • Timezone/City: UTC+08:00

    • Use DST: No


../_images/device_register.png


Step 4. Configuring TSDB Storage Policy for Storing Device Data

EnOS Time Series Database (TSDB) provides a variety of storage options for you to store important and frequently-accessed business data. Through configuring storage policies, time-series data can be routed to different datastores based on data types and storage time, thus reducing data storage costs and enhancing data access efficiency.

Note

  • By default, the uploaded data will not stored in TSDB. You must configure data storage policy before the data is uploaded to EnOS Cloud.

  • Each model can be associated to only one storage policy group.


In this step, configure a storage policy for the measurement points that are defined in the SmartBattery_Model model.

Create a Storage Policy Group (Optional)

You can store the time-series data for different projects separately by storage policy groups. Before configuring storage policies for measurement points, you need to create a storage policy group or select an existing storage policy group.

Note

Each OU can have up to 5 storage policy groups. If the SmartBattery_Model storage policy group already exists in the OU, skip this step.

You can create a storage policy group by the following steps:

  1. Log in to the EnOS Management Console and select Time Series Data Management > Storage Policies from the left navigation menu.

  2. Click + > Create Group in the upper right corner of the page to create a storage policy group and configure the following fields:

    • Group Name: enter a name for the storage policy group.

    • Group Model: select SmartBattery_Model to link with the storage policy group.

  3. Click OK to save the storage policy group configuration.


Configure Storage Policies

After the storage group is created, you can see all the TSDB storage policy options listed under the storage group tab. Configure storage policies separately for the above listed measurement points. You need to configure the storage policy for each of the above model measurement points in the SmartBattery_Model group.


Using the AI Raw Data storage type as example:

  1. Move the cursor on the AI Raw Data storage type and click the Edit icon to open the Edit Storage Policy page.

  2. From the Storage Time drop down list, select the storage time for the data. For this example, we shall save the data in TSDB for 3 months.

  3. Select the SmartBattery_Model model and the listed measurement points.

  4. Click OK to save the storage policy.


../_images/storage_policy.png


Refer to the above steps to configure the Generic Data storage policy.

Step 5. Adding a Device Simulator

In the EnOS Management Console, click Device Management > Simulators from the left navigation menu.

  1. Click New Simulator, and select the device that you have registered for the simulation.

  2. The device list shows all the devices that have been created in the current OU.

    Note

    You can only simulate a device with an inactive or offline status.

  3. Click OK to create a simulator for the selected device.


    ../_images/simulator_add_new.png


In the list of simulators, you can see the simulator you just created.


Next, you need to define the simulation data sample for it.


../_images/simulator.png


Step 6. Defining and Uploading the Simulation Data Sample

  1. In the list of simulators, click Edit Sample for the simulator you just created.

  2. Click Download in the pop-up window.

  3. Input the simulation data sample in the downloaded template.

    • The first column timeOfDay refers to the relative time stamp: you can enter the relative timestamp within one day (24 hours) using the format HH:MM:SS.

    • The rest of the column headers are for the measurement points that are defined in the device model. You only need to enter the identifier of the measurement points to be simulated rather than entering all of them.

    • The values are simulated measurement point values. If the data type is array, the format is [value1, value2, value3, …]. Leave the cell empty if there is no value at the current time point.

  4. When completed editing the template, in the Define Sample pop-up window, click Upload to upload the simulation data.

  5. Click OK.


See AESC_DEMO_Easy.csv for a ready-to-use template with simulated data.


../_images/upload.png

Step 7. Starting the Device Simulator

After uploading the simulation data sample, you need to start the device simulator by the following steps:

  1. In the list of simulators, locate the smart battery simulator and click the Start icon.

  2. On the Start Simulation pop-up window, select an end date for the simulation. In this lab, set the end time for 24 hours later.

    Note

    You can actually set a preferred end time, but a later end time leaves enough time for TSDB to ingest enough data to generate a report.

  3. Click OK to start the simulator.


../_images/simulator_start.png


Step 8. Checking the Device Data

Go to Time Series Data Management > Data Insights and select the SmartBattery_Device device to view the real-time current data report in minutes. See the following example:


../_images/data_insight.png


Step 9. Tagging the Model

Before DTV can use the data generated by your model, you need to tag the model so that the data can be synchronized to the DTV application.

  1. In the EnOS Management Console, click Models from the left navigation menu.

  2. Find the model that you want to configure and click Edit next to Tags.

  3. Add a new tag, and enter auth_unit for the key and true for the value.

    ../_images/tagging_asset1.png