Operation


The Operation node parses the measurment point or attribute from the input msg according to the selected message type, performs low-code logic and math operations, and passes it to the downstream node as output msg.

Node Type

Transformation.

Input and Output Ability

This node has multiple entry points and 1 exit point. Both the input and output are JSON.

Node Properties

../../../_images/operation.png


Name

The name for this node.


Message Type

The message type, either Post Measurement Point or Post Attribute, to perform the operation on.


Model

The model of the message type. You can select only 1 model.


Input Point

The measurement points or attributes (in), depending on the Message Type selected, of the model selected above which are used together with the Operator under Expression below for calculation (out). You can select multiple input points.


Output Point

The measurement point or attribute, depending on the Message Type selected, of the model selected above which is used to store the calculated result in Expression. The result will overwrite its existing value. You can only select 1 output point.


Expression

The calculation expression for the output. Click the operator and input points to build the expression.

  • out refers to the calculated result that will be stored in Output Point.

  • in referes to the input point.

Operators

Operator

Formula

Example

Remarks

Abs

out = abs(in1)

in1 = -9

out = 9

Returns the absolute value of the number.

  • in1 = Numeric

  • out = Numeric

Avg

out = (in1 + in2) / 2

in1 = 7, in2 = 8.7

out = 7.85

Returns the average of 2 numbers.

  • in1 and in2 = Numeric

  • out = Numeric

Max

out = max(in1, in2)

in1 = 3, in2 = 6

out = 6

Returns the higher value of the two.

  • in1 and in2 = Numeric

  • out = Numeric

Min

out = min(in1, in2)

in1 = 3, in2 = 6

out = 3

Returns the lower value of the two.

  • in1 and in2 = Numeric

  • out = Numeric

Exp

out = exp(in1)

in1 = 6

out = 403.4287934927351

Returns the exponential function with base e.

  • in1 = Numeric

  • out = Numeric

Modulus

out = (in1 % in2)

in1 = 22, in2 = 3

out = 1

Returns the remainder after dividing.

  • in1 and in2 = Numeric

  • out = Numeric

Power

out = pow(in1, in2)

in1 = 3, in2 = 5

out = 243

Returns the power (in2) of a number (in1).

  • in1 and in2 = Numeric

  • out = Numeric

SquareRoot

out = sqrt(in1)

in1 = 64

out = 8

Returns the squareroot of the number.

  • in1 = Numeric

  • out = Numeric

And

out = (in1 && in2)

  • in1 = 0, in2 = 0

    out = 0

  • in1 = 0, in2 = 1

    out = 0

  • in1 = 1, in2 = 1

    out = 1

  • in1 = 1, in2 = 0

    out = 0

Returns true only if both values are true.

  • in1 and in2 = Boolean

  • out = Boolean

Or

out = (in1 || in2)

  • in1 = 0, in2 = 0

    out = 0

  • in1 = 0, in2 = 1

    out = 1

  • in1 = 1, in2 = 1

    out = 1

  • in1 = 1, in2 = 0

    out = 1

Returns true if one of the values is true.

  • in1 and in2 = Boolean

  • out = Boolean

Not

out = (!in1)

  • in1 = 0

    out = 1

  • in1 = 1

    out = 0

Returns the reverse value.

  • in1 = Boolean

  • out = Boolean

Equal

out = (in1 == in2)

  • in1 = 0, in2 = 0

    out = 1

  • in1 = 0, in2 = 1.1

    out = 0

  • in1 = 1.1, in2 = 1.1000008

    out = 0

Returns true if both values are the same.

  • in1 and in2 = Numeric

  • out = Boolean

Greater Than

out = (in1 > in2)

  • in1 = 1, in2 = 0

    out = 1

  • in1 = 1, in2 = 1

    out = 0

  • in1 = 0, in2 = 1

    out = 0

Returns true if in1 is greater than in2.

  • in1 and in2 = Numeric

  • out = Boolean

Greater Than Equal

out = (in1 >= in2)

  • in1 = 1, in2 = 0

    out = 1

  • in1 = 1, in2 = 1

    out = 1

  • in1 = 0, in2 = 1

    out = 0

Returns true if in1 is greater than or equals to in2.

  • in1 and in2 = Numeric

  • out = Boolean

Less Than

out = (in1 < in2)

  • in1 = 0, in2 = 1

    out = 1

  • in1 = 1, in2 = 0

    out = 0

  • in1 = 1, in2 = 1

    out = 0

Returns true if in1 is less than in2.

  • in1 and in2 = Numeric

  • out = Boolean

Less Than Equal

out = (in1 <= in2)

  • in1 = 0, in2 = 1

    out = 1

  • in1 = 1, in2 = 0

    out = 0

  • in1 = 1, in2 = 1

    out = 1

Returns true if in1 is less than or equals to in2.

  • in1 and in2 = Numeric

  • out = Boolean

Log10

out = lg(in1)

in1 = 35

out = 1.5440680443502757

Returns the base 10 logarithm of the number.

  • in1 = Numeric

  • out = Numeric

LogE

out = ln(in1)

in1 = 22

out = 3.091042453358316

Returns the natural logarithm of the number.

  • in1 = Numeric

  • out = Numeric


Click the Test button to test your expression by entering the expression to see if it works as designed.


Description

The description for this node.

Limitations

Only supports numeric and boolean values.

Samples

The samples below are based on the following data.

  • Input Point: attribute1, attribute2

  • Output Point: attr_int

  • Expression: pow(msg.attribute1, msg.attribute2)

Input Sample

{
  "MetaData": {
    "messageType": "PostAttribute",
    "assetId": "assetId",
    "deviceKey": "deviceKey",
    "productKey": "productKey",
    "orgId": "yourOrgId"
  },
  "Body": {
    "attribute1": 3,
    "attribute2": 5,
    "attr_int": 3
  }
}

Output Sample

{
  "MetaData": {
    "messageType": "PostAttribute",
    "assetId": "assetId",
    "deviceKey": "deviceKey",
    "productKey": "productKey",
    "orgId": "yourOrgId"
  },
  "Body": {
    "attribute1": 3,
    "attribute2": 5,
    "attr_int": 243
  }
}