butt4cak3 / solvethis-js Goto Github PK
View Code? Open in Web Editor NEWParse and execute mathematical expression
Home Page: https://www.npmjs.com/package/solvethis
License: MIT License
Parse and execute mathematical expression
Home Page: https://www.npmjs.com/package/solvethis
License: MIT License
Dear @Butt4cak3
I hope you are well and my best wishes for 2020,
I have an issue too #josdejong/mathjs#1699
And maybe you could help me with your library.
One of the properties is "Formulas" of our datamodel is
• 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:
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:
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).
• 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.
{
"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
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.