Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Customizing the solution

Devis Lucato edited this page Jun 27, 2017 · 5 revisions

Note: only one simulation can be created, and cannot be modified. See the simulation API specs.

Step 1: Get the list of device types

Request

GET {Device Simulation endpoint}/devicetypes

Response

Content-Type: application/json; charset=utf-8

{
    Count: ...
    "Items": [
        {
            "Id": "11110000-1111-0000-0000-000011110000",
            "Name": "Elevator",
            "Description": "Simulated Elevator with floor number sensor"
            $metadata
        },
        {
            "Id": "22220000-2222-0000-0000-000022220000",
            "Name": "Chiller",
            "Description": "Simulated Chiller with temperature and humidity sensors",
            $metadata
        }
    ]
    "$metadata": {
        $type: DeviceTypesList;1
        $uri: {Device Simulation endpoint}/devicetypes
    }
}

Step 2: Render UI form

Use the above response to prepare a form for the user, e.g. the list of device types that can be simulated.

Allow the user to fill the form, entering name, description and logo, then proceed with creating the simulation and customizing the solution (in this order).

Step 3: Create simulation

Request

To create a standard simulation:

POST {Device Simulation endpoint}/simulations?template=default
Content-Type: application/json; charset=utf-8

{
    "Enabled": true
}

To create a customized simulation:

POST {Device Simulation endpoint}/simulations
Content-Type: application/json; charset=utf-8

{
    "Enabled": true,
    "DeviceTypes": [
        {
            "Id": "11110000-1111-0000-0000-000011110000",
            "Count": 3
        },
        {
            "Id": "22220000-2222-0000-0000-000022220000",
            "Count": 1
        }
    ]
}

Response

The simulation API returns the entire simulation object, that the UI doesn't need. In case of error, the UI should retry, before proceeding with the next step, or prompt the user.

Step 4: Customize the solution style

Request

PUT {UI Config endpoint}/styles/1
Content-Type: application/json; charset=utf-8

{
    name
    description
    logo as base64
}

Notes:

  • "styles" is the collection name, and "1" is the resource ID, so the API is consistent with other endpoints (e.g. the simulation API, which allows only 1 simulation). This design allows future extensions, e.g. allowing multiple styles.
  • The payload should include all the styling details.
  • The icon should be saved to a public folder, and the response should include the URL to the logo.

Response

Content-Type: application/json; charset=utf-8

{
    name
    description
    logo URL
    etc.
}

Step 5: Load the customization settings when the SPA starts

Request

GET {UI Config endpoint}/styles/1

Response

Content-Type: application/json; charset=utf-8

{
    name
    description
    logo URL
    etc.
}