Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important information on the platform change.

cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Key Value Database (KVD) - "Nested" nodes

Key Value Database (KVD) - "Nested" nodes

star_board
Established Member

I am using KVD app to save a JSON object in the DataLayer. My goal is to have a JSON object in a "parent" node and then each pair key/value of the JSON in a "nested" node. Similar to the node: system/resources/memory/available:

  • "Parent" node: memory
  • "Nested" nodes: available, buffer, cache...
star_board_0-1720627345822.png

I have tried to creat nodes of type both Resource as Variable, and I only get the "parent" node (TestResource & TestVariable), and not the "nested" nodes (Var1, Var2 & Var3). 

star_board_1-1720627498718.png

My .fbs file is the following:

 

 

// IDL file for sample schema.

namespace sample.schema;

table TestFlatbuffer {
    Var1:double;
    Var2:string;
	Var3:uint64;
}

root_type TestFlatbuffer;

 

 

And inside the App Data -> kvd Folder, I have modified the file nodes.json file with the following code:

 

 

 "types": [
        {
            "address": "types/test-schema",
            "type": "test-schema.bfbs",
            "metadata": {
                "nodeClass": "Type"
            }
        }
    ],
    "nodes": [
        {
            "address": "Test/TestResource",
            "type": "types/test-schema",
            "value": {
                "Var1": 0,
                "Var2": "string",
                "Var3": 0
            },
            "metadata": {
                "nodeClass": "Resource",
                "description": "This node is of the custom flatbuffers type"
            }
        },
        {
            "address": "Test/TestVariable",
            "type": "types/test-schema",
            "value": {
                "Var1": 0,
                "Var2": "string",
                "Var3": 0
            },
            "metadata": {
                "nodeClass": "Variable",
                "description": "This node is of the custom flatbuffers"
            }
        },

 

 

I looked in the Application Manual and in the following guide, and I cound't find a reference to this topic. Is it possible? How can I get the result I want using KVD? 

Thanks in advance! 😊

4 REPLIES 4

Sgilk
Frequent Contributor

Hi @star_board ,

I tried to replicate this as well and the only method I found is by manually creating the child nodes in the nodes.json. Keep in mind that the data behind these nodes is not linked and therefore updating the child will no update the parent. Example...

        {
            "address": "test/memory",
            "type": "types/system/resources/memory",
            "value": {
                "total": 16772329472,
                "used": 459796480,
                "free": 15236046848,
                "buffer": 41381888,
                "cache": 1035104256,
                "available": 16044298240
            },
            "mode": "read-only",
            "metadata": {
                "nodeClass": "Variable",
                "description": "This variable node is of built-in flatbuffers type 'system-resources-memory'."
            }
        },
                {
            "address": "test/memory/total",
            "type": "int32",
            "value": 12,
            "mode": "read-only",
            "metadata": {
                "nodeClass": "Variable"
            }
        },
        {
            "address": "test/memory/used",
            "type": "int32",
            "value": 123,
            "mode": "read-only",
            "metadata": {
                "nodeClass": "Variable"
            }
        }

I copied the same type as the memory resource example you gave and the child nodes are not created. I believe they are using some recursive logic behind the scenes to create those nodes and it is not a built in feature of the datalayer. I agree this would be a useful function, but to the best of my knowledge, it is not currently available using KVD. Hopefully someone proves me wrong!

Do you absolutely need the top level JSON object representation along with the child nodes for each key-value pair? If not, see the model examples.

star_board
Established Member

Using a .yaml file I did manage to create child nodes:

$schema: ./schemas/datalayer.v1.0.schema.json
name: test
version: 0.0.1
elements:
    var1:
        description: description.
        nodeClass: Variable
        mode: read-write
        value: 23
        typeSchema:
            type: int32
    var2:
        description: description.
        nodeClass: Variable
        mode: read-write
        value: 99
        typeSchema:
            type: int32
    var3:
        description: description.
        nodeClass: Variable
        mode: read-write
        value: 99
        typeSchema:
            type: int32

But now, the "parent" node doesn't show a JSON object:

star_board_0-1720721146408.png

 

Sgilk
Frequent Contributor

Right. This is the behavior I saw as well and is what is shown in the samples. Like I said above, I believe there is logic being executed while providing the memory status nodes that is outside of the scope of the KVD capability.

star_board
Established Member

I manage to get the result I wanted using PLC Engineering DUT objects  and making them available on the Datalayer. This approach could potentially serve as a solution for those pursuing similar results:

star_board_0-1721147583395.png

But it seems that , contrary to Sgilk's initial beliefs, this "nested" nodes might be a built in feature of the datalayer... And might be achievable using KVD app.
One think I noticed is that upon examining the corresponding Type nodes (PLC vs KVD), they seem to be identical.

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