Open aedelmann opened 6 years ago
Hi @Ebolon what do you think of this ? I recently stumbled across this missing feature in the DSL when I was creating models.
General a good idea to have such a feature. I am thinking of a boolean logic. This maybe would be easier to understand. JSON-Schema validation e.g. uses parameters of the object for if/else evaluation.
functionblock Oven {
status {
mandatory useFahrenheit as boolean
if(useFahrenheit) {
mandatory temperature as int <MIN 0, MAX 482> with {measurementUnit: Unit.Fahrenheit}
} else {
mandatory temperature as int <MIN 0, 250> with {measurementUnit: Unit.Celcius}
}
}
}
Honestly speaking this looks quite verbose and harder to read :) It's more how an implementation could look like rather than an interface definition to me. Protobuf and json schema for example uses oneOf , XSD uses choice to declare such interface logic. Also, in your example, this would mean that the useFahrenheit property is a value being transmitted by the device which we cannot assume.
The useFahrenheit
property could also be in the configuration section. But programming logic is maybe a bit too much for now. How a system should chose the correct constraints?
Sometimes it might be necessary that you would like to express a choice of possible properties where only one property can be transmitted over the wire at a time. Similiar to XSD's choice element.
Example: