Azure-Samples / digital-twins-explorer

A code sample for visualizing Azure Digital Twins graphs as a web application to create, edit, view, and diagnose digital twins, models, and relationships.
MIT License
188 stars 118 forks source link

Default initialization of properties #92

Closed SteveOss closed 2 years ago

SteveOss commented 3 years ago

Currently when you create a new instance of a Twin, you have to manually set values for all properties or they are not generated. This means that a function populating the Twin using "replace" operations will fail. Would be nice to have a mode where are created instances have default values set for all properties. To do the equivalent of:

az dt twin create --dt-name IOTechTwins -m "dtmi:com:iotechsys:devicevirtual;1" -t device-virtual --properties '{ "OutputBool": false, "OutputUint8": 0, "OutputUint16": 0, "OutputUint32": 0, "OutputUint64": 0, "OutputInt8": 0, "OutputInt16": 0, "OutputInt32": 0, "OutputInt64": 0, "OutputFloat32": 0.0, "OutputFloat64": 0, "InputBool": false }'

jamescarpinter commented 3 years ago

@cschormann this looks like a CLI suggestion. Is there a better repo to file this in to get the team's attention? Thanks!

cschormann commented 3 years ago

@jamescarpinter I think the suggestion is to have equivalent functionality to what CLI has, to set default properties.

@SteveOss The reason we are not initializing the properties is that good defaults are hard to choose, at least in production. But I see your point that when working with ADT explorer it can be quite useful. We are planning a feature in DTDL that allows to define default values as part of the models. These would automatically be set on twin creation, but that is not imminent.

One relatively simple approach we could take is to add a checkbox "generate property defaults" to the "new twin" naming dialog. When checked, we would create defaults - perhaps not very good ones, but defaults nevertheless.