Skip to content

Generics

Michiel TJampens edited this page Mar 1, 2023 · 3 revisions

Purpose

Allow storing data without writing java code or to be able to add a sensor at runtime.

Usage

Everything is defined in the settings.xml and needs to be in the 'generics' tag. An example of the minimum

<generics>
  <generic id="sbe38" table="sbe38">
    <real index="0">temperature</real>
   <generic> 
</generics>

This tells Dcafs to process data with the label generic:sbe38 by converting the received data to a real/double and store it in a table called sbe38. How to setup this sqlite and the stream can be found in their respective part of the wiki. The above is the minimum...

Possible attributes for the generic node

  • id -> the reference to this generic, used as the label eg. label="generic:id" or multiple label="generic:id1,id2"
  • db -> one or more id's from databases (except InfluxDB) , multiple are allowed if the table is identical
  • group -> the group the defined rtvals belong to unless specified otherwise
  • influx -> id of the influx db to write to
  • delimiter -> the characters used to split the received data

For example, a meteo sensor outputs temperature,humidity and pressure in the wixdr nmea string.

<generics>	
  <generic id="meteo" delimiter="," group="aws" db="sensors:aws">			
    <real index="2">temperature</real>
    <integer index="6">humidity</integer> <!-- low accuracy humidity in percentage -->
    <real group="pressures" index="10">pressure</real>
  </generic>
</generics>

To use it, the label needs to be generic:meteo

This tells Dcafs:

  • Create rtvals according to the given items, with default group id being 'aws'
    • The real 'pressure' uses the 'pressures' group instead of the default 'aws'
  • Where to find the values after splitting on ',' and store these in the given rtvals
  • Write to the table 'aws' in the database with id 'sensors'

Other tags

Macro

This is added for the use case that multiple of the same devices are connected and part of the data contains an unique identifier.

<macro index="0"/>  <!-- This means that the first element of the array contains the unique identifier -->
<real index="1">@macro_temperature</real> <!-- When this value is written to rtvals, @macro will be replaced with the content of value found with index="0" -->

When this generic is used to fill in a database table, this needs to be defined during table creation

<real alias="@macro_temperature">temperature</real> <!-- this is how it should be used, see the SqliteDB/SQliteTable section for the rest of th -->
Clone this wiki locally