Skip to content

Managing Data Types

The following commands require an active KSDK session

For KSDK login instructions see the Authentication page.

Managing Data Types

Creating a Data Type

Data types can be created from multiple sources. The Kelvin system is compatible with OPC-UA models built from third-party OT software (e.g. Siemens).

In addition, data types can be constructed from Kelvin's simple templates: icds.

Data types are created with the kelvin datatype create command.

  • This command takes the following arguments:
    • name, the name of the data type to be created.
  • And the following options:
    • --output-dir, that directory where the newly created data type will be placed.

If you're in the context of an application directory, the newly created data type will be placed under your_app/datatype/. If not you're not in the context of an application directory, an output directory must be provided.

# kelvin datatype create <name> --output-dir=<output-dir>
kelvin datatype create central.config --output-dir=myfolder

The new data type will then be available:

[kelvin.sdk][2021-01-05 15:03:27][I] Creating spec for datatype "central.config"
[kelvin.sdk][2021-01-05 15:03:27][R] Datatype "central.config" spec successfully created in "/absolute/path/to/project/datatype/central_config__0-0-1.yml"       

And will have the following out-of-the-box content:

name: central.config
version: 0.0.1
class_name: CentralConfig
description: "central config"
fields:
  - name: myfield
    description: A default raw 32 bit floating point value.
    type: float32

The user can then modify the default fields to accommodate his requirements.

For more information on how to include data types in your application:

Check the Integrating data types in your application section.

Uploading Data Types

Once created, data types can be uploaded to the platform

If you're in the context of an application directory, all the data types placed under your_app/datatype/ will be uploaded. If not you're not in the context of an application directory, an input directory must be provided. Additionally, you can filter the data types to be uploaded with the --names option.

The kelvin datatype upload takes the following takes the following options: - --input-dir, the path to the directory where the data type files reside. - --names, by default.

# kelvin datatype upload --input-dir=<data type directory>
kelvin datatype upload

The data type was successfully uploaded:

[kelvin.sdk][2021-01-05 15:40:40][I] Uploading datatypes from directory "datatype"
[kelvin.sdk][2021-01-05 15:40:40][I] Loading all datatype files from directory "datatype"
[kelvin.sdk][2021-01-05 15:40:40][R] 1 datatypes loaded from directory "datatype"
[kelvin.sdk][2021-01-05 15:40:40][I] Retrieving datatypes..
[kelvin.sdk][2021-01-05 15:40:43][I] Processing the datatype dependency tree.
[kelvin.sdk][2021-01-05 15:40:43][I] Initialising the datatype upload operation.
[kelvin.sdk][2021-01-05 15:40:44][I] Uploading datatype "central.config:0.0.1"
[kelvin.sdk][2021-01-05 15:40:45][R] Datatype "central.config" successfully uploaded
[kelvin.sdk][2021-01-05 15:40:45][R] Datatypes successfully processed

Downloading Data Types

Similar to the upload operation, you can download data types that are available in the platform.

Data types can be downloaded with the kelvin datatype download command.

  • This command takes the following arguments:
    • name-with-version, the name and the version of the data type to download divided by :.
  • And the following options:
    • --output-dir, there directory into which the data type will be downloaded.
# kelvin datatype download <data-type-name>:<data-type-version>
kelvin datatype download central.config:0.0.1 --output-dir=datatype/

The data type was successfully downloaded:

[kelvin.sdk][2021-01-05 15:42:28][I] Downloading datatype "central.config:0.0.1"
[kelvin.sdk][2021-01-05 15:42:28][R] Datatype "central.config:0.0.1" successfully downloaded to "datatype/central_config__0-0-1.yml"

Consulting Data Types

Listing Data Types

Once data types are uploaded to the platform, they are available to anyone and downloaded and/or included in apps.

This can be done with the kelvin datatype list command.

kelvin datatype list

The list of all data types in the platform:

[kelvin.sdk][2021-07-06 11:17:23][I] Retrieving data types..
[kelvin.sdk][2021-07-06 11:17:28][I] 
*************************** Data types ***************************
+--------------------+--------+---------------------+----------------------------------+----------------------------------+
| Model              | Type   | Version             | Created                          | Updated                          |
|--------------------+--------+---------------------+----------------------------------+----------------------------------|
| raw.boolean        | icd    | 2.0.0               | 2021-06-17 16:00:21.439391+00:00 | 2021-06-17 16:00:21.439391+00:00 |
| raw.dynacard       | icd    | 2.0.0               | 2021-06-17 16:00:22.887518+00:00 | 2021-06-17 16:00:22.887518+00:00 |
| raw.float32        | icd    | 2.0.0               | 2021-06-17 16:00:14.308440+00:00 | 2021-06-17 16:00:14.308440+00:00 |
| raw.float64        | icd    | 2.0.0               | 2021-06-17 16:00:27.139466+00:00 | 2021-06-17 16:00:27.139466+00:00 |
| raw.int16          | icd    | 2.0.0               | 2021-06-17 16:00:18.544700+00:00 | 2021-06-17 16:00:18.544700+00:00 |
| raw.int32          | icd    | 2.0.0               | 2021-06-17 16:00:12.895026+00:00 | 2021-06-17 16:00:12.895026+00:00 |
| raw.int64          | icd    | 2.0.0               | 2021-06-17 16:00:28.540650+00:00 | 2021-06-17 16:00:28.540650+00:00 |
| raw.int8           | icd    | 2.0.0               | 2021-06-17 16:00:24.290505+00:00 | 2021-06-17 16:00:24.290505+00:00 |
| raw.text           | icd    | 2.0.0               | 2021-06-17 16:00:29.968477+00:00 | 2021-06-17 16:00:29.968477+00:00 |
| raw.uint16         | icd    | 2.0.0               | 2021-06-17 16:00:20.013405+00:00 | 2021-06-17 16:00:20.013405+00:00 |
| raw.uint32         | icd    | 2.0.0               | 2021-06-17 16:00:15.710834+00:00 | 2021-06-17 16:00:15.710834+00:00 |
| raw.uint64         | icd    | 2.0.0               | 2021-06-17 16:00:25.709651+00:00 | 2021-06-17 16:00:25.709651+00:00 |
| raw.uint8          | icd    | 2.0.0               | 2021-06-17 16:00:17.118389+00:00 | 2021-06-17 16:00:17.118389+00:00 |
+--------------------+--------+---------------------+----------------------------------+----------------------------------+ 

Searching Data Types

In addition to listing all Data types, you can search for specific Data types with the kelvin datatype search command:

This can be done with the kelvin datatype search command.

kelvin datatype search "float32"

Success

[kelvin.sdk][2021-07-06 11:17:00][I] Searching datatypes that match "float32"
[kelvin.sdk][2021-07-06 11:17:03][I] 
*************************** Data types ***************************
+-------------+--------+-----------+----------------------------------+----------------------------------+
| Model       | Type   | Version   | Created                          | Updated                          |
|-------------+--------+-----------+----------------------------------+----------------------------------|
| raw.float32 | icd    | 2.0.0     | 2021-06-17 16:00:14.308440+00:00 | 2021-06-17 16:00:14.308440+00:00 |
+-------------+--------+-----------+----------------------------------+----------------------------------+

Details of a Data Type

Detailed information of a Data type can be obtained through the kelvin datatype show command.

  • This command takes the following arguments:
    • name, the name of the data type to be retrieved.
  • And the following options:
    • --version, the specific version corresponding to the provided data type.
# kelvin datatype show <data type name:data type version>
kelvin datatype show raw.float32:2.0.0

Success

[kelvin.sdk][2021-07-06 11:15:51][I] Retrieving data type "raw.float32:2.0.0"
[kelvin.sdk][2021-07-06 11:15:51][I] 
*************************** Data type Info ***************************

  connect: True
  created: 2021-06-17 16:00:14.308440+00:00
  icd:
    class_name: Float32
    description: A raw 32 bit floating point value.
    fields:
      array: None
      description: The raw 32 bit floating point value.
      name: value
      type: float32
    name: raw.float32
    version: 2.0.0
  name: raw.float32
  schema:
  source: 
  type: icd
  updated: 2021-06-17 16:00:14.308440+00:00
  version: 2.0.0