Skip to content

Connection API

Connection API manages communication connections (Modbus, OPC-UA, IEC-104, S7, MQTT, BACnet, etc.) from scripts and reads/updates the Connection → Device → Frame hierarchy.

ins.startConnection(name) / ins.startConnection(projectName, name)

Section titled “ins.startConnection(name) / ins.startConnection(projectName, name)”

Starts the connection. projectName defaults to the current project if omitted.

ins.startConnection("MODBUS-PLC");
ins.startConnection("otherProject", "MODBUS-PLC");

ins.stopConnection(name) / ins.stopConnection(projectName, name)

Section titled “ins.stopConnection(name) / ins.stopConnection(projectName, name)”

Stops the connection.

ins.stopConnection("MODBUS-PLC");

ins.getConnectionStatus(name) / ins.getConnectionStatus(projectName, name)

Section titled “ins.getConnectionStatus(name) / ins.getConnectionStatus(projectName, name)”

Returns a ConnectionStatus enum — only two values exist:

ValueMeaning
"Connected"Connection is active
"Disconnected"Connection is closed or lost
var status = ins.getConnectionStatus("MODBUS-PLC");
if (status == "Disconnected") {
ins.notify("warning", "Connection", "MODBUS-PLC is not connected");
}

ins.getConnection(name) / ins.getConnection(projectName, name)

Section titled “ins.getConnection(name) / ins.getConnection(projectName, name)”

Returns a ConnectionResponseDto.

Fields:

MethodTypeDescription
getName()StringConnection name
getDsc()StringDescription
getProjectId()StringProject ID
getProtocol()ProtocolProtocol (MODBUS, OPC_UA, S7, …)
getIp()StringIP address
getPort()IntegerPort
getConfig()Map<String, Object>Protocol-specific extra settings
var c = ins.getConnection("MODBUS-PLC");
ins.consoleLog(c.getProtocol() + " " + c.getIp() + ":" + c.getPort());

Returns a DeviceResponseDto.

MethodTypeDescription
getName()StringDevice name
getDsc()StringDescription
getConnectionId()StringParent connection ID
getProtocol()ProtocolProtocol
getConfig()Map<String, Object>Device-specific settings (slave ID, node ID, …)
var d = ins.getDevice("MODBUS-PLC", "Device1");
ins.consoleLog("Slave: " + d.getConfig().slaveId);

ins.getFrame(connectionName, deviceName, frameName)

Section titled “ins.getFrame(connectionName, deviceName, frameName)”

Returns a FrameResponseDto.

MethodTypeDescription
getName()StringFrame name
getDsc()StringDescription
getDeviceId()StringParent device ID
getProtocol()ProtocolProtocol
getMinutesOffset()IntegerMinute offset (for scan windows)
getScanTimeFactor()IntegerScan time multiplier
getIsReadable()BooleanRead enabled
getIsWritable()BooleanWrite enabled
getConfig()Map<String, Object>Frame-specific (e.g. Modbus address range)
var f = ins.getFrame("MODBUS-PLC", "Device1", "HoldingRegs_0_100");
ins.consoleLog("Scan x" + f.getScanTimeFactor() + " — offset " + f.getMinutesOffset() + "m");

Update methods require a complete DTO — the typical pattern is: read with getConnection / getDevice / getFrame, mutate the field, write back with updateX.

var c = ins.getConnection("MODBUS-PLC");
c.setIp("192.168.1.100");
c.setPort(502);
ins.updateConnection("MODBUS-PLC", c);

ins.updateDevice(connectionName, deviceName, dto)

Section titled “ins.updateDevice(connectionName, deviceName, dto)”
var d = ins.getDevice("MODBUS-PLC", "Device1");
d.setDsc("Main switchgear — updated");
ins.updateDevice("MODBUS-PLC", "Device1", d);

ins.updateFrame(connectionName, deviceName, frameName, dto)

Section titled “ins.updateFrame(connectionName, deviceName, frameName, dto)”
var f = ins.getFrame("MODBUS-PLC", "Device1", "HoldingRegs_0_100");
f.setScanTimeFactor(5); // sparser scan interval
f.setIsWritable(false); // make read-only
ins.updateFrame("MODBUS-PLC", "Device1", "HoldingRegs_0_100", f);
function main() {
var c = ins.getConnection("MODBUS-PLC");
if (c.getIp() == "192.168.1.100") {
ins.consoleLog("IP already up to date");
return;
}
ins.stopConnection("MODBUS-PLC");
c.setIp("192.168.1.100");
ins.updateConnection("MODBUS-PLC", c);
ins.startConnection("MODBUS-PLC");
ins.writeLog("INFO", "Connection", "MODBUS-PLC → 192.168.1.100");
}
main();