Variable Functions

Variable functions are used to read/write variables defined in the inSCADA Platform with script expression.

Variable Object: A JSON object returned by variable functions. It contains the time stamp and value.

{"@class":"com.inscada.mono.communication.model.values.NumberVariableValue","value":60,"date":1564649882811}

Get Variable Value

object ins.getVariableValue(var variablename)

Reads the value of a variable defined in inSCADA.

variablename : String

Return Value: Returns the Variable object. If the value returned is "null", it means the operation failed. Variable could not be read.

Syntax

var variable=ins.getVariableValue("UNIT01_Active_Power");
if (variable!==null) {
    if (variable.value>0) {
        ins.notify("info","Unit 01","Unit 1 is working");
    }
    return variable.value;
}
return -1;

Get Variable Previous Values

object ins.getVariableValue(var variablename,var index)

Reads the value of a variable defined in inSCADA from previous scans. inSCADA stores the last 10 readings of the variables. You can reach these 10 values with index.

variablename : String

Return Value: Returns the Variable object. If the value returned is "null", it means the operation failed. Variable could not be read.

Syntax

Get Variables Values

Array[] ins.getVariableValues(var variablenames[])

Reads the values of the requested variable list defined in inSCADA.

variablenames[] : String array

Return Value: Returns an array of objects of the requested variables.

Syntax

Get Project Variables

object ins.getProjectVariableValues()

Reads the value of all variables connected to the project in inSCADA .

Return Value: Returns a JSON object with all variables and values for the project.

Syntax

Set Variable Value

ins.setVariableValue(String variablename, object value)

Writes a value to a variable defined in inSCADA.

variablename: The name of the variable to write the value to.

Syntax

Set Variables Values

ins.setVariableValues(object variables)

Writes values to variables defined in inSCADA at once.

variables: A JSON object containing variables and the values to be written.

ins.setVariableValues, unlike ins.setVariableValue, allows values to be written to more than one variable at a time. When doing this, it optimizes the writing process in accordance with the protocol and sends the values in the same data block to the connected device at one time. A function that can be used to transfer multiple data.

Syntax

Map Variable Value

ins.mapVariableValue(String source, String destination)

Writes a variable value to another variable.

Source: The variable name of the value to be read. A source variable.

Destination: Name of the variable to be write the value. A target variable.

Syntax

ins.mapVariableValue(String source, String destination, var defaultvalue)

If the source variable cannot be read, it writes a default value to the target variable.

Last updated