Manual Ranging

Description

This object is being used for 'Manual Ranging' of a specific number value.


App Builder Object


Source Code

function valueBetween(value, min, max) { if (min > max) { return value <= min && value >= max; } if (max > min) { return value >= min && value <= max; } 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 (valueBetween(value, oldMin, oldMax)) { const retValue = (((value - oldMin) * (newMax - newMin)) / (oldMax - oldMin) + newMin); if (inPorts[5].value) return [Math.round(retValue)]; return [retValue]; } return []; }

In Ports

Position

Name

Message Type

Description

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.


Out Ports

Position

Name

Message Type

Description

Position

Name

Message Type

Description

1

Value

Number

This port is being used to send out the message containing the value of the 'Manual Ranging' object after it has been converted accordingly.


Properties

Name

Description

Name

Description

Object Name

The name of the object on the canvas.

Show Code View

The switch to turn on code view for the Code Object.

Duplicate code into custom Code Object