dp_fct_expressions
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| dp_fct_expressions [2020/01/02 17:25] – toddmalone | dp_fct_expressions [2023/04/19 18:52] (current) – toddmalone | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | The dp_fct config for a data point element is a slick way to make new tags without scripting. | + | The dp_fct config for a data point element is a slick way to create calculated |
| The most common use case for this is to average some sensor values to get an overall value. | The most common use case for this is to average some sensor values to get an overall value. | ||
| Line 5: | Line 5: | ||
| when using the dp_fct: | when using the dp_fct: | ||
| {{: | {{: | ||
| + | |||
| + | Here is another real-world example where I had to take two 16bit words and combine them into a new 32bit word. This is an old school technique where you want to bit shift the upper word and OR them together. | ||
| + | <code cpp> | ||
| + | (p1 << 16) | p2 | ||
| + | </ | ||
| These are simple expressions using mathematical equations. | These are simple expressions using mathematical equations. | ||
| - | < | + | < |
| if(Sensor1 > 60) | if(Sensor1 > 60) | ||
| TankTemp = (sensor2 + sensor3) / 2.0; | TankTemp = (sensor2 + sensor3) / 2.0; | ||
| Line 25: | Line 30: | ||
| + | Another feature of the dp_fct is to call a library function. | ||
| + | |||
| + | To use a function, you will still need to setup the p1, p2, etc. as these become the library variables passed into the function. | ||
| + | |||
| + | The trick to all this is to setup the system to recognize your functions in the library. | ||
| + | < | ||
| + | [event] | ||
| + | loadCtrlLibs = " | ||
| + | </ | ||
| + | |||
| + | A function might look like this: | ||
| + | < | ||
| + | float tableLookup(anytype p1, anytype p2) | ||
| + | { | ||
| + | float fRet; | ||
| + | // table lookup with arrays, mapping, etc. where fRet = something | ||
| + | return(fRet); | ||
| + | } | ||
| + | </ | ||
dp_fct_expressions.1577985934.txt.gz · Last modified: by toddmalone
