Azure / opendigitaltwins-dtdl

Digital Twins Definition Language
Creative Commons Attribution 4.0 International
466 stars 160 forks source link

Percentage semantic type #122

Closed samubura closed 1 year ago

samubura commented 2 years ago

I feel that having a percentage semantic type would be beneficial for a lot of implementations. It should be fairly easy to add and can protect integer fields from being misinterpreted when doing computation. (e.g. a percentage should always be >=0 and <=100)

briancr-ms commented 2 years ago

DTDL v2 supports a percent unit (used with the RelativeHumidity semantic type). Our approach for semantic types (more specifically quantitative types for expressing measurements) has been to use the semantic type to express what the element is measuring (temperature, humidity, etc.) and to use the unit to express the units the measurement is in. Is the quantitative type you're measuring not represented in the set in DTDL v2 (certainly possible since there are many things to measure and DTDL only includes some types)?

samubura commented 2 years ago

Yeah I wanted to have a property representing the percentage of the battery charge of a device, I understand your approach though and it makes total sense but some "universal" types like this could be a great addition in the future.

rido-min commented 1 year ago

closing as a dupe of #140