Universal Robots Forum

Extend DataModel

My workmate and me are creating a URCap and we need to store values of a custom class inside of the DataModel. Obviously there is no default method to include this data type. Is there any way to extend the DataModel in order to provide to it one new setter method and one new getter?

Hi @jtorres

This functionality is not available, what you will have to do isntead is come up with a way of storing your vustom object using the existing data types. For instance, I used a JTree in a previous URCap, and wanted to styore it in the data model. This is of course not possible, so instead, I itterated over the nodes in the tree, and saved the name of each node to the data mdoel, whilst iterating the name of the key used to store the node, something like model.set("node1", NAME_OF_NODE_1); etc.

I would suggest seeing if you can do something similar for your custom class.