KVD flatbuffer teaser

Custom data structures in Key Value Database (KVD) app

CodeShepherd
Community Moderator
Community Moderator
Content

This article shows how to generate and register custom data structures via a flatbuffer schema file (FBS) for the ctrlX OS - Key Value Database (KVD) app.

Requirements
  • flatc (part of SDK for ctrlX AUTOMATION)
  • ctrlX CORE or ctrlX OS
  • ctrlX OS - Key Value Database app
Create flatbuffer schema file

Any text editor or development tool can be used to create an flatbuffer schema file (.fbs). See an example in the datalayer.provider.alldata example in the SDK for ctrlX AUTOMATION.

Compile flatbuffer schema file

Compile your flatbuffers schema file (.fbs) to a binary flatbuffers file (.bfbs) using the flatc compiler.

  1. Download the flatc compiler directly from GitHub or download the latest release of the ctrlX Automation SDK. Inside the SDK the flatc compiler can be found here:
    1. WINDOWS
       .\bin\oss.flatbuffers\win-msvc-x64\release\flatc.exe
    2. LINUX
       ./bin/oss.flatbuffers/ubuntu22-gcc-x64/release/flatc
  2. Add flatbuffers schema file (.fbs) to the folder including flatc
  3. Compile your flatbuffers schema file (*.fbs):

Example:

flatc --schema --binary --bfbs-comments --bfbs-builtins --no-warnings -o . sampleSchema.fbs

This generates a binary flatbuffers file sampleSchema.bfbs in the current working directory.

Hint: This process can be automated, that user gets some feedback what is missing. See create_fbs_for_kvd.txt attached. Simply rename file to .bat or copy and past the text in to a executable file.

Register your flatbuffers

To register your own flatbuffers type upload your generated file and adapt the KVD configuration file nodes.json.

  • Upload the generate *.bfbs file to app data (active configuration) directory kvd/bfbs.
    ctrlX OS - Web UI - KVD app data - bfbsctrlX OS - Web UI - KVD app data - bfbs
  • Configure a node of nodeClass Type and add it to the types section in the file kvd/nodes.json in app data (active configuration)
    • Set the type to the name of the generated binary flatbuffers file (*.bfbs).
    • Set the address of the type to the address on which instance nodes should refer to it
      Example:
      types/inertial-value
    • Each change will be effective immediately. Wrong settings will lead to the unavailability of the whole kvd node in the data layer

Example: Custom flatbuffers

Type node of a custom flatbuffers type:

types: [
    {
        "address": "types/inertial-value",
        "type": "inertial-value.bfbs",
        "metadata": {
            "nodeClass": "Type"  
        }
    },
    ...
]


A variable node this type can be specified (value optional):

nodes: [
    {
        "address": "kvd/samples/variables/flatbuffers/inertial-value",
        "type": "types/inertial-value",
        "value": {
            "x": 1,
            "y": 2,
            "z": 3
        },
        "metadata": {
            "nodeClass": "Variable",
            "description": "This node is of the custom flatbuffers type 'types/inertial-value."
        }
    },
    ...
]

Related information
CodeShepherd
CodeShepherd
Technical sales support from Bosch Rexroth
Must Read
Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist