Guide for user to create customized formula for processing data from different sensor. - mercury-telemetry/mercury-telemetry GitHub Wiki

This document includes the context of whole topic related to the formula used to process sensor data and the instructive guide for user to create customized formula by their own in the future.

Context

The user is expected to see mainingful data in UI, but sometimes the data passed from hardware is raw data which is meaningless, so we can not just show this sort of data directly on frontend. For instance, the data for fuel is a number which means nothing when user wants to see what percentage of gas is remaining in the tank. So the system need a formula to process it before store into the database.

Current design

  1. The path of formula related files is :

    ../ag_data/formulas

  2. We currently have some pre-defined formula for existing sensorType in

    ../ag_data/formulas/library/system/mercury_formula.py

  3. Current workflow for process and store the data received from radioreceiver API.

    a. When hardware send Get request to radioreceiver API for the first time, API will send configuration parameters for Radio Module back and automatically call radioport.py script

    b. When radioport script is called, our radioport will be open and constantly listening to that port.

    c. When we receive a set of valid data from radio port, we will send a post_request with this set of valid data to our radioreceiver API, in radioreceiver API, we import ingestion_engine.py file under ../ag_data/formulas/system directory and do corresponding process for data, then store the result into the database.

How to customize formula :

  1. Create new or use existing python file for formula under ../ag_data/formulas/user directory.

  2. Import the corresponding model and write business logic in that file.

  3. Currently, follow the workflow created in issue #271 - Reroute the radioreceiver API to call the formula engine.

  4. Import the corresponding formula file into ingestion_engine.py file and use it to process data.

⚠️ **GitHub.com Fallback** ⚠️