Skip to content

Variables

A variable is the core data unit in inSCADA. A temperature reading, a motor status, an energy counter — each one is a variable.

Variable List

Core metadata:

FieldTypeRequiredDescription
nameString (≤100)YesVariable name — unique within the project
dscString (≤255)NoDescription
codeString (≤20)NoShort technical code (usable in screens)
unitString (≤50)NoEngineering unit (°C, kW, V, A, bar, …)
fractionalDigitCountShortNoDecimal digits shown in rendered value
projectIdStringYesOwning project
frameIdStringYesOwning frame (protocol and device derived from it)
protocolProtocolAutoInherited from the frame
isActiveBooleanYesActive / inactive
isWritableBooleanYesWritable from outside

Scaling:

FieldTypeDescription
rawZeroScaleDoubleRaw low limit
rawFullScaleDoubleRaw high limit
engZeroScaleDoubleEngineering low limit
engFullScaleDoubleEngineering high limit

Logging:

FieldTypeDescription
logTypeVariableLogTypeSee table below
logPeriodInteger (≥1)Periodic logging interval (s)
logThresholdDoubleMinimum delta (noise filter)
logMinValue / logMaxValueDoubleAccepted value band — outside values are dropped
logExpressionCodeStringDecision code (logType = Expression / Custom)
logExpressionIdStringShared Expression reference
keepLastValuesBooleanKeep a bounded list of last values in cache (see ins.getLastVariableValues)

Value expression (computed value):

FieldTypeDescription
valueExpressionTypeExpressionTypeNONE, CUSTOM or EXPRESSION
valueExpressionCodeString (≤32 767)Inline code (type = CUSTOM)
valueExpressionIdStringShared Expression reference (type = EXPRESSION)

Write limits & pulse:

FieldTypeDescription
setMinValue / setMaxValueDoubleAccepted write range
isPulseOn / pulseOnDurationBoolean / IntegerON pulse enabled and length (ms)
isPulseOff / pulseOffDurationBoolean / IntegerOFF pulse enabled and length (ms)

Protocol-specific fields (address, data type, byte/word swap, …) live in the config JSONB map and are flattened into the DTO on the wire.

Each protocol has its own data-type enum; the common conceptual mapping:

ConceptModbusOPC UAOthers
FloatFloat, DoubleFloat, Doubleavailable in most
IntegerInteger, Short, Long, Byte, Unsigned …Int16/32/64, UInt16/32/64, Byte, SBytevaries
BooleanBooleanBoolean
StringStringString
BCD16/32/64-bit BCDModbus-only

Full Modbus list: Float, Double, Integer, Short, Long, Byte, Unsigned Integer, Unsigned Short, Unsigned Byte, 16 BIT BCD, 32 BIT BCD, 64 BIT BCD, Boolean, String. See the protocol pages for the other enums.

Variable JSON (Modbus, Holding Register → Float)

Section titled “Variable JSON (Modbus, Holding Register → Float)”
{
"id": "var-23227",
"name": "ActivePower_kW",
"dsc": "Total active power",
"unit": "kW",
"protocol": "Modbus TCP",
"projectId": "proj-153",
"frameId": "frame-703",
"isActive": true,
"isWritable": false,
"fractionalDigitCount": 2,
"engZeroScale": 0.0,
"engFullScale": 1000.0,
"logType": "Periodically",
"logPeriod": 10,
"keepLastValues": true,
"valueExpressionType": "NONE",
"type": "Float",
"startAddress": 0,
"byteSwapFlag": false,
"wordSwapFlag": true
}

The last four fields (type, startAddress, byteSwapFlag, wordSwapFlag) are Modbus-specific config entries.


Raw is converted to engineering via a linear map.

Eng = engZeroScale + (raw - rawZeroScale) ×
(engFullScale - engZeroScale) / (rawFullScale - rawZeroScale)
ParameterValue
rawZeroScale4 (mA)
rawFullScale20 (mA)
engZeroScale0 (°C)
engFullScale100 (°C)
  • Raw: 4 mA → Eng: 0 °C
  • Raw: 12 mA → Eng: 50 °C
  • Raw: 20 mA → Eng: 100 °C
{
"value": 359.91,
"extras": { "raw_value": 606.56 },
"flags": { "scaled": true }
}

value is the scaled engineering value; extras.raw_value is the raw number.


Variable values are written to InfluxDB according to VariableLogType.

VariableLogType enum — six values:

TypeBehavior
No LogNot logged
When ChangedLog only when the value changes
PeriodicallyLog at a fixed interval (logPeriod seconds)
ThresholdLog when the change exceeds logThreshold
ExpressionEvaluate the shared Expression referenced by logExpressionId — log if truthy
CustomEvaluate inline logExpressionCode — log if truthy
ParameterDescription
logPeriodPeriodic logging interval (seconds). 10 = once every 10 s
logThresholdMinimum delta (threshold mode or extra filter)
logMinValue / logMaxValueAccepted value band — outside values are dropped
keepLastValuesKeep the latest values list in cache (for ins.getLastVariableValues(name, n))

fractionalDigitCount controls how many decimals are rendered:

ValueDisplayed
0350
1350.5
2350.48
3350.483

A variable can carry its own JavaScript formula. On each read cycle the formula runs and its result becomes the variable value.

ExpressionType enum:

TypeMeaning
NONENo expression — the raw (scaled) value is used
CUSTOMRun the inline code in valueExpressionCode
EXPRESSIONResolve the shared Expression via valueExpressionId — pulled from the space-level formula pool
// Sine wave (ActivePower_kW)
var t = new Date().getTime() / 1000;
return (Math.sin(t / 60) * 150 + 450 + Math.random() * 30).toFixed(2) * 1;
// Fahrenheit → Celsius (raw is available as 'value')
return ((value - 32) * 5 / 9).toFixed(1) * 1;
// Efficiency from two variables
var input = ins.getVariableValue("Input_kW").value;
var output = ins.getVariableValue("Output_kW").value;
if (input > 0) {
return ((output / input) * 100).toFixed(1) * 1;
}
return 0;

Boolean variables can use pulse mode:

FieldDescription
isPulseOnON pulse enabled
pulseOnDurationON pulse length (ms)
isPulseOffOFF pulse enabled
pulseOffDurationOFF pulse length (ms)

Pulse mode is used for momentary commands — e.g. a motor-start button: writing ON flips the bit, and after pulseOnDuration the system automatically writes OFF. The operator does not need to clear the bit manually.


FieldDescription
setMinValueMinimum writable value
setMaxValueMaximum writable value

When set, writes outside this range are rejected from both the API and scripts. Use it to prevent operator error.


// Read a live value
var val = ins.getVariableValue("ActivePower_kW");
// → { value: 359.91, extras: { raw_value: 606.56 }, dateInMs: ... }
// Bulk read
var vals = ins.getVariableValues(["ActivePower_kW", "Voltage_V", "Current_A"]);
// Write
ins.setVariableValue("Temperature_C", { value: 55.0 });
// Last N values (for variables with keepLastValues = true)
var last100 = ins.getLastVariableValues("Temperature_C", 100);
// Query logged (historical) values
var start = ins.getDate(ins.now().getTime() - 3600000); // last 1 hour
var history = ins.getLoggedValues("Temperature_C", start, ins.now());

Details: Variable API → | REST API Reference → (Variable Value Controller, Protocol Variable Controller groups)