...
Source Code
Code Block | ||
---|---|---|
| ||
const value_between = function valueBetween(value, min, max) => { if if(min > max) { return value <= min && value >= max; } }else if (max > min) { return value >= min && value <= max; }else{ return true; } function execute() }{ } const value = inPorts[0].value ? parseFloat(inPorts[0].value) : 0; const newMin = inPorts[3].value ? parseFloat(inPorts[3].value) : 0; const newMax = inPorts[4].value ? parseFloat(inPorts[4].value) : 0; const oldMin = inPorts[1].value ? parseFloat(inPorts[1].value) : 0; const oldMax = inPorts[2].value ? parseFloat(inPorts[2].value) : 0; if (value_betweenvalueBetween(value, oldMin, oldMax)) { const retValue = (((value - oldMin) * (newMax - newMin)) / (oldMax - oldMin) + newMin); if (inPorts[5].value) return [Math.round(retValue)]; else{ return [retValue]; } return []; } |
...
In Ports
Position | Name | Message Type | Description |
---|---|---|---|
1 | Value | Number | This port is being used to receive a message containing the value, which is supposed to the ranged accordingly to the configuration of the 'Manual Ranging' object. |
2 | In Min | Number | This port is being used to define the In Min Range of the incoming value. |
3 | In Max | Number | This port is being used to define the In Max Range of the incoming value. |
4 | Out Min | Number | This port is being used to define the Out Min Range of the outgoing value. |
5 | Out Max | Number | This port is being used to define the Out Max Range of the outgoing value. |
6 | Rounded | Digital | This port is being used to define if the value should be rounded or not. |
...