pkra / tools-for-math-on-the-web

Some tools around math on the web, maybe eventually an awesome list.
MIT License
77 stars 10 forks source link

generating formula for RX and Tx exchange between two different equipment not speaking same language #5

Closed yboujraf closed 4 years ago

yboujraf commented 4 years ago

Dear @pkra

I hope you are well and my best wishes for 2020,

I have an issue too #https://github.com/josdejong/mathjs/issues/1699

And maybe you could help me to find the coorect library in javascript and better in typescript library.

Topic - translate from different protocols data by generating mathematic formula.

One of the properties is "Formulas" of our datamodel is

Formulas ( Rx / Tx)

• Formulas provide a way to project values received from an equipment to another value range or representation. • For example, an equipment might send gain values as INTEGERs ranging from 0 to 65535, while the actual gain range in is -64db to 12db. Obviously, the user of a front-end application prefers to deal with the gain values in db instead of the technical INTEGER range. • To accommodate for this need, I am looking to provides the concept of formulas.

• This will create a basic formula which does not alter the input value – meaning it returns the identity of the input value:

image

Picture from ww.lawo.de

• The input value of the formula is denoted with the symbol $. You can use this symbol in an arithmetic expression which yields the desired output range. • The line “$ =“ defines the input value (as sent by the device) of the formula. • The following line “RX($) =“ defines the expression used to convert values that have been received from the device. • The following line “TX($) =” defines the expression used to convert values that are about to get sent to the device. This expression has to reverse the projection made in the RX expression.

• To follow the ifSpeed example, let’s display the speed of the interface in megabytes per second instead of bits per second: o Enter a test input value in the “$ =” field, e.g. “10000000” (10 megabit) o Enter the expression $ / 8000000.0 into the “RX” field. 8000000 is the factor used to turn unit bits into unit megabyte. o To reverse the RX expression, enter the expression $ * 8000000.0 into the “TX” field. o You will now see the following:

image

Picture from www.lawo.de

o You can see that the result of the RX expression is 1.25 (megabytes) and the result of the TX expression, which uses 1.25 as input value, is 10000000 (bits per second, which is equal to the input value of the RX expression).

INPUT RANGE

• I have an Analog to Digital convert 12 bits (4096 positions) • The manufacturer of the A/D converter infor you for 0 = -128dB and for 4095 = +15 dB

I am looking to create as above "Formula" with possibility to select linear or log the Rx and Tx formula.

Data model of my paramater

{
                    "identifier": "ParameTypeStream",
                    "description": "Stream PPM MAIN",
                    "value": 0,
                    "minimum": -4096,
                    "maximum": 480,
                    "access": "read",
                    "format": "%8.2f°",
                    "enumeration": "",
                    "factor": 32,
                    "isOnline": true,
                    "default": -1024,
                    "type": "integer",
                     "formula": "1000*\n1000/"
                }

The properties : formula

The Minimum & Maximum are :

"minimum": -4096,
"maximum": 480,

Then I need to generate the correct formula for Rx & Tx.

Regarding *formula "1000\n1000/"**

That means when the client receives this properties the "/n" is the separation from RX formula then TX formula then no needs two properties

Here :

RX = value *1000 TX = value /1000

Use case - write the formula - RX

  1. the client introduces the formula in an editbox. Just the '$' indicates the value I need to passing into the math expression and get the result.

Use case - write the formula - TX

If the RX formula is already written in the editbox , I need and expect with Mathjs library to generate the invert formula for TX and vice-versa if Tx is filled, then I got RX.

If RX = $/1000
then I need to get for TX = $*1000

The formula could be complex (log, square, ^, (expression)*log) I attached a document from my friend written for F# (Microsoft) long time ago and now we are using nodejs and javascript.

Ember+ Formulas.pdf

I hope you could make a simple example of code how to use it and then I will try it ;-)

Best Wishes for 2020 Youssef