Development VSCP

#VSCP project autogenerated files with units

Units for all measurements and conversion between them is now included in the autogenerated databases and in autogenerated JSON and XML files. Also ASCII and UTF8 symbols are included for each measurement unit.

The unit definitions and formats relay on the mustche format with JavaScript (pseudo) code for the conversion. Simple tools can be used in a project handle this. For this the default unit always is defined as


That is the value (which is a floating point value) is always substituted on it’s own by mustache. For the other unit’s for a specific measurement there are mathematical expressions added to convert that unit to the default unit. With this schema all units can be converted to every other defined unit by first converting it to the default unit.

As an example, for temperature measurements this looks like this

  • unit = 0 (default) is Kelvin: {{val}}
  • unit = 1 is Celsius: {{val}} + 273.15
  • unit = 2 is Fahrenheit: ({{val}} – 273.15) * 1.8 + 32.0
  • unit = 3 is undefined.

A helper for event display is <b>render</b> which for the moment is only defined for vscpworks but can have formats defined for other presenter software as well. The definitions for measurement renderings as an example looks like this today

    <vscpworks template=" 
       {{lbl-start}}Unit: {{lbl-end}} = {{unitstr}} [{{unit}}]{{newline}} 
       {{lbl-start}}Sensorindex: {{lbl-end}} = {{sensorindex}}{{newline}} 
       {{lbl-start}}Value: {{lbl-end}} = {{val}}{{symbol}}{{newline}} " /> 

Mustache is also used here for variable substitution. More info is here.

You find the auto generated files here

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.