Expressions

The SDK provides a safe expression parser/evaluator for math style formulas over attribute references.

Syntax

  • Operators: +, -, *, /, %, ^

  • Parentheses

  • Functions: sum, avg, min, max, clamp, round, floor, ceil, abs, sqrt, pow, log

  • Numeric literals

  • Attribute references (quoted or unquoted)

Example

import { parseExpression, evaluateExpression } from "@ska-octopus-widget-sdk/widget-sdk";

const parsed = parseExpression(
  'sum("low-mccs/spsstation/s8-1/ppsDelaySpread"+low-mccs/spsstation/s8-2/ppsDelaySpread+1)',
);

const result = evaluateExpression(parsed, (ref) => valuesByRef[ref]);

result contains value, missing, and optional error.

API Notes

  • No JavaScript eval is used.

  • isSingleRef lets you detect pass-through reference expressions.

  • round(value, decimals) defaults decimals to 0.

  • log(value, base) uses natural log when base is omitted.