rsmp-nordic / rsmp_core

RSMP core specification
MIT License
6 stars 1 forks source link

Info "Unit" shoud be separated from the comment on numerical datas #170

Open marcgarba opened 4 months ago

marcgarba commented 4 months ago

A remark that was made during a presentation and that seems interesting: for some information, it would be preferable for the unit value to be separated from the comment section: for example, for an integer, there could be units in: seconds, milli-secs, minutes, km/h, percentage, meter, decimeters, deciTons, degrees Celcius, ... etc ...

otterdahl commented 4 months ago

Thank you for the suggestion. I think we considered something similar about 10 years ago but it was never implemented in the specification.

I think it can make sense to provide this information to the supervision system sometimes. The equipment can clever and send the data using the most suitable unit given the circumstances. It provides flexibility to what the equipment actually sends, but it might make validation harder.

emiltin commented 4 months ago

I'm a bit concerned it would add too many complicatations.

I think you would always have to document how data is send and you then can specify a suitable unit, like km/h or seconds.

Having to parse arbitrary units like km/day, cm/h, etc. can be very complicated for the receiver. Would cm/h or mm/s be acceptable?

It also increase the number of bytes that has to be send. And as David mentioned, it makes validatating attributes using a schema harder.

It's probably easier for the receiver to always receive using a fixed (implicit) unit and then convert to a different unit afterwards if needed.

Something we could do is allow higher precision anywhere by allowing floats. For example, if the unit is seconds, you can send 0.001 to specify a millisecond.

marcgarba commented 4 months ago

Oh no it really didn't go that far !

It was just the idea to have for the description of a field, a separated "unit" part more easier to identify in the YAML / Excel.

Absolutely no change to the protocol exchanged !!!

Example in YAML:

   arguments:
      speed:
       type: integer
       description: Average speed
       unit: km/h
       min: 0
       max: 65535

Unit information which can then be used for graphical input/visualization interfaces... We don't necessarily have to use it to validate anything...

emiltin commented 1 week ago

Ok I see. Yes it makes sense to include the unit in the SXL source in a machine-readable format.