Skip to main content

iRidi Server

An iRidi Server project is a program that runs on a server and connects it to automation equipment. Documentation updated 01.01.2024

To get started with iRidi Server, you must:

  1. Create a new server project;

iRidi Studio > File > New > **New server project**

Server1.png

  1. Create a Panel Project and link it to the server project;

  2. Upload the server project to the server;

  3. Upload the Panel Project to the control panel;

Creating a server project consists of these steps:

  1. Create a list of equipment to control on the server: configure drivers and create commands and feedback channels;

  2. Configure scripts: create modifier functions to transform information in server variables, and so on;

  3. If needed, configure server variable value forwarding;

  4. During project synchronization, all commands and feedback channels are automatically mapped to server variables (in the iRidi Server driver). These variables can be accessed by the iRidi control panel).

Project for iRidi Server​

This section describes creating an iRidi Server project in iRidi Studio. iRidi Server processes data from automation equipment, saves it to a database and passes information to control panels. A server project has no graphic part; it consists of scripts and a list of equipment to communicate with.

Server and control panel interaction

ServerPrincipalSceemDriverLayer.png

Server components:

  • Drivers - connect to equipment and store the variables that can be controlled. They are linked to server channels;
  • Server channels - intermediate variables between control panels and driver channels. Server channels combine variables from all drivers into a single namespace;
  • Virtual variables - store server data and JavaScript results that are not linked to actual driver variables;
  • Database - records the history of server variable changes;
  • JavaScript - describes routines, logic and schedules (the server's intelligent functions), and modifies data as it passes through the server;
  • Web server - lets you connect to iRidi Server through a web interface to view its state and configure it. Provides REST API , through which third-party applications and systems can control server functions over HTTP.

Controlling the server

  • i3 pro - the iRidi client application that runs the server control visualization. It includes:
    • the iRidi Server driver in i3 pro - establishes a TCP connection to the server;
    • JavaScript in i3 pro - creates routines that run on the control panel (for example, to control the graphic interface);
    • the graphic interface in i3 pro - a visual interface for controlling automation equipment;
  • Web interface - a server settings interface that opens in a browser. It does not display the user visualization;
  • Third-party applications - applications and devices that can control the server by sending HTTP commands configured according to the REST API of the server.

Server project workspace​

After starting iRidi Studio and creating a new server project, you see a workspace containing:

Server2.png

  1. Devices - a list of devices and services that i3 pro or iRidi Server connects to for control and data acquisition (not all devices may be shown here, since devices can also be created through JavaScript).
  2. System tokens - variables that provide information about the device running i3 pro or iRidi Server (time, OS type, network and screen settings, and so on).
  3. Project tokens - variables that can store user data between launches of i3 pro or iRidi Server.
  4. Schemes - program iRidi Server logic using function blocks.
  5. Script editor - the JavaScript editor, available for i3 pro or iRidi Server. When developing scripts, consider the environment - server or visualization interface - since it determines the available methods and ways to access data.
  6. Routines - routines (command sequences and their triggering conditions) that can run on a schedule or event.
  7. Schedule - an event schedule with configurable execution times and repetition intervals.
  8. ETS import - import group addresses from an ETS5 project (*.knxproj).
  9. GC cloud - an online database of infrared commands for controlling audio/video equipment via IR. Commands are stored in the format used by Global Cache equipment.

Server project settings​

Opening the settings window​

Open settings using either method:

Studio2019_ServerSettings_Open_1.png

  1. Right-click the project name tab in iRidi Studio and select Settings.

Settings5.png

  1. Click the gear icon on the iRidi Studio control toolbar.

Settings categories​

In the iRidi Server project settings window, you can specify settings and the server connection method, specify coordinates for the astronomical timer, configure the log verbosity , or enter information about the customer and project.

Setting​

Ss_Setting.png

  1. Settings - how i3 pro connects to iRidi Server: by IP address, or through an intermediate server (Cloud Gate) when remote server access is required:
  • Type: Direct connection - i3 pro connects directly to the server by its IP address. In the server settings, specify the server's OWN IP address, connection port (30464), and, if required, the connection username and password that must be entered in i3 pro to connect to the server. Debug level determines log detail; "Debug" provides the most detailed information.
  • Type: Remote cloud control - i3 pro connects to iRidi Server through the intermediate Cloud Gate server, which provides Internet connectivity without configuring the automation site's router. How do I configure Cloud Gate?
  1. Location - latitude and longitude of the server location, for configuring the schedule astronomical timer.
Debug​

Ss_Debug.png

  1. When the server runs on a hardware platform, its log cannot be viewed as in the PC console. You can forward it to a PC over SMTP. Install a suitable SMTP server on the PC and specify its address in the interface settings.
  2. Set the required log verbosity. It determines the amount and type of information logged, from EMERGENCY (emergencies) to DEBUG (detailed information). Further information on project debugging is described here.
  3. You can also set different log verbosity levels for individual server project components (core, database, script and web server). If a component's level exceeds the general level (step 2), the general level takes the highest individual component level.
Information​

Ss_Information.png

Enter the customer's address and phone number, order number and content description in the project information. They may be useful later!

Communication with equipment​

A basic server use case is connecting to equipment from several control panels. Configure data transfer through the server so that multiple control panels can operate.

To do this, we will:

  1. Create a server project;

  2. Add the drivers for the equipment to control;

  3. Configure commands and feedback channels for these drivers;

  4. Create an i3 pro project based on the server project.

Adding the driver​

You can add a driver to the iRidi Server interface in several ways:

  • by importing a file containing your equipment configuration, or by scanning the local network. The following are supported (see iRidi Studio for the current list):
    • DuoTecno - network scanning;
    • HDL-BUS Pro - network scanning;
    • KNX (ETS, *.knxproj) - file import; creates a list of IP interfaces and group addresses;
    • Modbus (*.csv) - imports a file in the internal iRidi format; see the Modbus documentation. Creates a list of registers;
    • Crestron (Simpl, *.smw) - file import; creates a list of joins;
    • iRidi JavaScript (iRidi Studio, *.js) - file import; adds scripts from one project to another;
    • iRidi project (iRidi Studio, *.irpz, *.sirpz) - file import; adds drivers from one project to another;
    • Domintell - network scanning;
    • Velbus - network scanning;
    • AMX (TPDesign, *.TP4, *.TP5) - not shown in driver import, but a TP4 project can be opened in Studio just like *.irpz; the *.TP4 file is automatically converted to the i3 pro format;
  • from the database , which contains drivers of different types that you can use in your project. Commands and feedbacks must be created manually;
  • by creating it through JavaScript . It is not shown in the device tree, but works when i3 pro runs, in the way defined by the developer. See JS API.

Studio2019_SidePanel_Drivers_onServer.png

add a driver to the iRidi Server configuration

Note

Variables in iRidi Server​

iRidi Server variables are divided into driver variables and virtual variables.

Driver variables consist of command addresses where values can be written for sending to equipment, and feedback addresses where the driver stores values received from equipment. Driver addressing systems depend on the protocol. Configured commands and feedbacks provide convenient access to equipment addresses:

Driver2.png

  1. Commands - device variables to which commands must be sent. For example, to control a KNX relay at "1/0/1", write 0 or 1 to the KNX driver command with this address.
  2. Feedbacks - variables for sorting and storing data received from equipment. For example, a KNX relay returns 0 or 1 when switched; the driver exposes this value as feedback at "1/0/1". The value can be displayed in the interface.
  3. Tokens (driver tokens) - feedbacks reporting the driver's connection status and important connection information (address, connection port and so on)

Virtual variables are controllable virtual server variables, not directly linked to controlled equipment. Create them manually to store application results (numbers or strings) or obtain status feedback. Data to write is formed in JavaScript on the server or from the control panel.

Use Forward Value to to link a virtual command to virtual feedback, as though equipment were present.

To do this:

  1. Create a virtual command and feedback.
  2. In the virtual feedback's Forward Value to setting, specify the virtual command to link to it

You can also bulk-create virtual feedbacks from virtual commands, using the same names as the commands.

When the required commands are selected in Virtual (use shift/ctrl for multiple selection), the context menu provides the operation "Добавить фидбэк(и) (add feedbacks)" with several options:

Driver03.png

  • с Forward Value to (with Forward Value to) - after the feedback is created, it is entered in Forward Value to of the command from which it was created
  • без Forward Value to (without Forward Value to) - no link is created automatically

Where new feedbacks are created depends on the original commands' folder:

  • If the original commands are in Commands, the feedbacks are created in the system Feedbacks folder
  • If the original commands are in a user-created folder, the feedbacks are created in that same folder.
Note
  • If the destination folder already contains feedback with the same name, a warning appears:

Driver04.png

  • Заменить (replace) - the old feedback in the destination folder is deleted and new feedback creation continues.

  • Добавить (add) - new feedback is created with the next available sequence number, and the process continues with the new feedback.

  • Отмена (cancel) - the operation stops and all changes already made are rolled back.

Note
  • If the parent command already has a Forward Value to value, a warning appears

Driver05.png

  • Да (yes) - the parent command's FVt is cleared and replaced with the new feedback.
  • Нет (no) - the parent command's FVt is not changed.
  • Отмена (cancel) - the operation stops and all changes already made are rolled back.

Working with Virtual is identical to working with Project Tokens , using the same rules and API functions.

Virtual variables created in a server project can be copied to another server project. Select the Virtual driver in the device tree, copy it using Ctrl+C or Copy in the right-click menu, then paste the virtual variables into the other server project's device tree (Ctrl+V or the right-click paste action).

Note

If the destination project contains matching variable names, an import options dialog appears:

  • "Add only new channels and tags (by default)" - add only virtual variables with no duplicate names.
  • "Add all channels and tags and change parameters of identical ones." - add all virtual variables, replacing settings. Exceptions may include Forward value to (if a driver or command/feedback of the same name is missing) and Script Modifier (if the specified function is missing in the new project). These settings are cleared during transfer.

Virtual3.png

Commands / Virtual Commands​

Server3.png

Main command settings:

  • Name - channel name;
  • Path to server tag - channel path for script access;
  • Script Modifier - a script modifier function that transforms values before sending them to the driver channel or after receiving them from the control panel and script;
  • Description - optional variable description;
  • Forward value to - forward the value from one tag to another (for details, see here);
  • On Server - enable/disable the command's link to the Panel Project (when disabled, the command is not shown in the Panel Project).

Feedbacks / Virtual Feedbacks​

Server4.png

  • Name - tag name;

  • Path to server tag - tag path for script access;

  • Script Modifier - run a JavaScript function every time the tag is activated, modifying received data before passing it to the control panel;

  • Access - variable type:

    • Public - can be changed from the control panel;
    • Private - can be changed only from the server;
  • Persist - restore the variable's last value after a server restart;

  • Description - optional description;

  • Store In DB - enable saving the variable to the database and select its data format

    • None - database recording is disabled
    • Signed 32bit - record as a signed integer
    • Float 64bit - record as a floating-point number
    • String UTF8 - record as a string
  • Load On Start - write the variable's last database value to the feedback when the server starts;

  • DB Save Strategy - data recording strategy: select the event that creates a database record:

    • Deadband - record when the variable differs from its previous value by the specified amount or more.
      • Deadband (value) - the minimum variable change that triggers database recording. With Deadband: 0, a new record is created for any change in received values, but not if the same number is received again.
    • Interval - periodic recording. A record is created at the specified time interval;
      • Interval (value) - select a recording interval from 5 seconds to 1 hour, or specify it manually (Custom) in ms. If Store In DB is a string (String UTF8), a record is created 1 time per minute; more frequent recording cannot be configured (use Deadband);
      • Interval Value - interval value (minimum 1);
      • Interval Units - units of measurement;
  • Forward value to - forward the value from one tag to another (for details, see here);

  • On Server - enable/disable the tag's link to the Panel Project (when disabled, the tag is not shown in the Panel Project or counted in the license).

Important

Do not change Store In DB format for a variable whose values have already been recorded in the system database. After changing the format (Signed 32bit, Float 64bit or String UTF8), the server stops recording new values of that variable. No error is shown in the log.

To restore recording, you must clear or recreate the system database. Clearing it deletes the history of all tags.

To preserve history, create a new variable with the required Store In DB format. The old variable can be deleted from the project when its saved history is no longer needed.

Note

With Deadband = 0, every tag change is recorded, regardless of the amount of change. In this mode, the database grows very quickly.

Interval recording is useful for variables that change smoothly and relatively slowly, such as air temperature and humidity.

Recording on change is suitable for variables whose changes must not be missed, such as switching lights on/off or changes in fan speed.

Device Tokens​

Server5.png

Tokens show the equipment connection status:

  • Online - connection state of the controlled system (Online/Offline = 1/0);
  • Status - connection status (Offline/Connecting/Online/Waiting = 0...3);
  • Host - remote system domain name;
  • HostPort - remote system port to which i3 pro connects;
  • IP - control panel IP address;
  • HostIP - IP address of the remote system to which i3 pro is connected;
  • Port - the client's local port used to communicate with the remote device.
  • CPU - server CPU usage, %;
  • RAM - server RAM usage, %;
  • Storage - server disk space usage, %;
  • GCrate (Garbage Collector Rate) - garbage collector operation: the number of runs in the last 24 hours. If the garbage collector does not run, this is updated every hour;
  • GCtime (Garbage Collector Time) - garbage collector operation: duration of the most recent GC run in seconds;
  • ClientCount - number of connected panels (how many are online);
  • License - license status (0 - No License Found / 1 - Commercial / 2 - Trial / 3 - Test mode / 4 - Offline / 5 - License is expired).

Driver tokens store information about the server's connection to controlled equipment. They can be saved to the database and used for charts or log output.

Modifying data on the server​

Modification changes received data before sending it to its destination: equipment or control panels.

A script modifier function configured in the server channel or tag settings modifies the data (virtual variables follow the same principles):

  • If the function modifies a server channel, the value received from the control panel is recalculated in the script before being sent to the driver;
  • If the function modifies a server tag, the value received from the driver is recalculated in the script before being sent to the control panel.

Example: graphic items on the control panel adjust a variable from 0 to 100. The server converts these values to 0...255 using modifiers before sending them to the driver (automation equipment):

ModifyJS.png

Create the modifier function in the script editor and select it in the variable's Script Modifier:

function modify_send (in_Type, in_Name, in_Value)
{
in_Value *= 255/100;
return in_Value;
}
function modify_receive (in_Type, in_Name, in_Value)
{
in_Value *= 100/255;
return in_Value;
}

Server12.png

The channel or tag calling the function passes these arguments:

  • in_Type - variable type: 0 - channel, 1 - feedback tag;
  • in_Name - full command or tag name;
  • in_Value - command or tag value.

Data is thus processed as it passes through the server in both directions, from the control panel to equipment and back.

Note
  • Return the modified value (in_Value) to the variable using return in_Value;
  • Returning the modified value is optional; the function can simply perform a one-time action. In that case, the initial value received by the function does not reach its destination, but only causes the function to run.
  • The server web interface displays modified tag and channel values:
    • Tag values in the web interface result from the Script Modifier function;
    • Values entered using Set in the web interface are passed to Script Modifier before being sent to the channel on the physical device.

Modifier examples​

**Modifying Driver Tokens

Driver Tokens show the connection status of automation equipment and are read-only.

/*    Токен Online любого драйвера может вернуть только значение 1 = Online и 0 = Offline.
Заменим 1 на текущее время и фразу " Connection established"; 0 на время и " Connection closed"
Вернем результат преобразования тому, кто вызвал функцию
*/
function onlineModify (in_Type, in_Name, in_Value)
{
if (in_Value == 1)
{
in_Value = IR.GetVariable("System.Time.24")+" Connection established";
return in_Value;
} else
{
in_Value = IR.GetVariable("System.Time.24")+" Connection closed";
return in_Value;
}
}

Modifying Driver Channels & Tags

Driver channels and tags are linked to server variables that can be modified. A modifier cannot be linked to a driver command, only to its corresponding server channel.

A command must receive a value when executed (if no value is needed, an empty string is passed). The value is modified before being sent to equipment:

/*    В канал приходит значение в диапазоне 0-100
Приведем это значение к диапазону 0-255, округлим и отправим оборудованию
*/
function rangeModify (in_Type, in_Name, in_Value)
{
in_Value *= 255/100;
return in_Value.toFixed(0);

Driver Tags

/*    Канал принимает значения в диапазоне 0-255
Приведем значение к диапазону 0-100, округлим и вернем в канал обратной связи
*/
function rangeModifyBack (in_Type, in_Name, in_Value)
{
in_Value *= 100/255;
return in_Value.toFixed(0);
}

Modifying Virtual Channels & Tags

On the control panel, virtual server variables appear as server channels and tags. You can send a value to a variable, use it to form a command, and send that command to automation equipment:

/*    команда DVD плейеру имеет вид: "VOLUME XX", ХХ - это громкость от 00 до 100
Громкость может состоять из двух или трех симовлов, т.е. 00, 01, 02, ... 100 (ASCII)
Получим значение 0-100 с панели управления (с обычного Level Item), сформируем и отправим команду
*/
var driver = IR.GetDevice("AV & Custom Systems (TCP)");
function volume (in_Type, in_Name, in_Value)
{
if (in_Value < 10)
{
in_Value = "0"+in_Value;
driver.Send(["VOLUME "+in_Value+"\r\n"]);
} else
{
driver.Send(["VOLUME "+in_Value+"\r\n"]);
}
}

Virtual Tags

Virtual server tags appear on the control panel as feedback channels. A script can write a value to them and process it with a modifier function. The final value is available for the control panel to read.

/*    Виртуальный тег не получает значений напрямую от оборудования
Поэтому мы запишем значение в тег из скрипта, когда это необходимо
*/
IR.SetVariable("Server.Tags.Virtual 1", 100)
/* обработаем значение с помощью функции модификатора
*/
function value (in_Type, in_Name, in_Value)
{
in_Value = "brightness: "+in_Value+"%";
return in_Value; // brightness: 100%
}

Writing and reading variables​

Server variables include Tokens, Commands, Feedbacks, Virtual Commands and Virtual Feedbacks. Their state can be changed and queried from control panels and scripts running on the server.

Use these JavaScript commands to write and read:

  • IR.GetVariable(name) * IR.SetVariable(name, value)

Server variables appear to the control panel as driver commands and channels, so you can use the methods in iRidi driver API.

Writing a value to a variable

  1. Copy the variable's full name from Devices;
  2. Use IR.SetVariable to write a value to the variable:

Syntax

IR.SetVariable("Server.Path.Name", value)

InputValueDescription
Server.Path.NameServer.Channels.Command 1type: string
full server variable name.
value100type: string
value to write to the server variable., number, boolean
Output
successtruetype: boolean
whether the write succeeded.

Example

Server13.png

IR.AddListener(IR.EVENT_START, 0, function()
{
IR.SetVariable("Server.Channels.Command 1", 100);
});
Tip
  • The method applies to server channels and tags.

Reading a variable value

  1. Copy the variable's full name from Devices;
  2. Use IR.GetVariable to read the variable's value:

Syntax

IR.GetVariable("Server.Path.Name")

InputValueDescription
Server.Path.NameServer.Channels.Command 1type: string
full server variable name.
Output
value100type: string, number, boolean
value in the server variable.

Example

Server13.png

IR.AddListener(IR.EVENT_START, 0, function()
{
IR.GetVariable("Server.Channels.Command 1");
});
Tip

The method applies to server channels and tags.

Passing data between a virtual channel and tag​

A virtual command, Virtual Channel (Server.Channels.Virtual 1), is not initially linked to virtual feedback, Virtual Tag (Server.Tags.Virtual 1). You can therefore change the virtual variable's value on the server, but it will not return to the panel as a feedback value.

To return to i3 pro the value sent from i3 pro to the server, create a Script Modifier function. It takes the value sent from i3 pro and writes it to the server's virtual feedback tag. This is the change the control panel sees.

ModifyFunc_Scheme_server.png

**To configure data transfer from a virtual command to a tag:

  1. Create a new iRidi Server project.
  2. Create a virtual channel (command) and tag (feedback channel) with the same name, for example "Virtual 1".
  3. Open the script editor (JS on the toolbar), create a new script file and add the modifier function:
function virtual_to_virtual (in_Type, in_Name, in_Value) 
{
var namepart = in_Name.split(".");
IR.SetVariable("Server.Tags." + in_Name, in_Value);
return in_Value;
}
  1. Return to the virtual command "Virtual 1" (Server.Channels.Virtual 1) and in Script Modifier, select the function virtual_to_virtual .

Server14.png

  1. The setup is complete: writing a value to Server.Channels.Virtual 1 automatically passes it to Server.Tags.Virtual 1, which the control panel can display as feedback.

Passing data between drivers​

End-to-end data forwarding transfers information between otherwise unrelated automation systems. Modifier functions provide this forwarding.

Example: when a register changes in a Modbus controller, pass its new value to a KNX group address. The value can be modified before sending, for example, multiplied by 100:

function gate_to_modbus (in_Type, in_Name, in_Value) 
{
IR.SetVariable("Server.Channels.Modbus TCP 2.Channel 12", in_Value*100);
return in_Value;
}

The function address_1 monitors changes in the Modbus driver's feedback channel. Select it in Script of the Modbus server tag.

If variables in the linked drivers have the same names, one modifier function is sufficient. Link it to the channels of the driver whose data must be passed to the other driver:

function gate_to_modbus (in_Type, in_Name, in_Value) 
{
var namepart = in_Name.split(".");
IR.SetVariable("Server.Channels.Modbus TCP 2." + namepart[1], in_Value);
return in_Value;
}

Activating a routine from the control panel​

A routine is a set of periodically performed actions triggered by the required event.

Note

As the primary way to perform periodic actions, use Schedules and Routines . If their functionality is insufficient, scripts can be used.

Activate a scripted routine by sending a value from the control panel to a virtual server channel. To do this, subscribe to channel changes in the server scripts:

Example routine:

IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function (name, value)
{
if (name == "Server.Channels.Scene 1" && value ==1)
{
IR.SetVariable("Server.Channels.KNX Router (KNXnet/IP).Address 1", 100);
IR.SetVariable("Server.Channels.KNX Router (KNXnet/IP).Address 2", 75);
IR.SetVariable("Server.Channels.KNX Router (KNXnet/IP).Address 3", 0);
}
});
IR.SubscribeTagChange("Server.Channels.Scene 1");

To execute this routine, send 1 from the control panel to the server channel "Server.Channels.Scene 1".

Important
  • Only one global listener can be created in a project.(IR.SetGlobalListener()). All operations must be performed within that listener. The number of subscriptions is practically unlimited.

Periodic actions​

Note
  • As the primary way to perform periodic actions, use Schedules and Routines . If their functionality is insufficient, scripts can be used.

Example 1: the simplest option - periodic actions without configurable settings. Create timers on the server; they cannot be viewed in the client, and their trigger times cannot be changed:

// if your another JS files includes  "IR.SetGlobalListener()"  
// you have to add the code inside of previous IR.SetGlobalListener() and delete the listener from this file!
// if you are not sure that you are able to do it yourself please contact to support@iridiummobile.ru
IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function (name, value)
{
if (name == "System.Time.Minutes")
{
// SET UP PERIODICAL ACTIONS:
// start hour, start minute, duration of process (ms), channel full name, start value, stop value
// if you don't want to stop process, add "no" instead of stop value
check_timer (10, 45, 60000, "Server.Channels.KNX Router (KNXnet/IP).Pump 1", 1, 0); // timer 1
check_timer (14, 30, 480000, "Server.Channels.KNX Router (KNXnet/IP).Pump 2", 1, "no"); // timer 2
// you can add more
}

// do not edit the other part, you need only to add the needed timers in above
function check_timer (hours, minutes, duration, channel, start_value, stop_value)
{
if (IR.GetVariable("System.Time.Hour") == hours && IR.GetVariable("System.Time.Minutes") == minutes)
{
function stop ()
{
IR.GetServer().Set(channel, stop_value);
IR.Log("process at "+hours+":"+minutes+" stopped");
}
IR.GetServer().Set(channel, start_value);
IR.Log("process at "+hours+":"+minutes+" started");
if (stop_value != "no")
{
IR.SetTimeout(duration, stop);
}
}
}
});

IR.SubscribeTagChange("System.Time.Minutes");

Example 2: the server script checks the time every minute. If it matches the alarm time set to a specific hour and minute in the client application, and the alarm is active, the script performs actions in the automation system, such as turning on lights and starting music in a room.

To set the trigger time, send values from the control panel to server variables.

To let all control panels obtain the alarm time and state, write the alarm settings to virtual server tags.

Example 3: uses IR.SetInterval() and IR.ClearInterval(): display a reminder every 5 seconds until the event ends:

Important
  • Do not treat these projects as ready-made solutions. They demonstrate interaction between the server and client application.

Database queries​

An SQL database is created on iRidi Server when a server project is created.

If you work with several projects and replace them on the server, a system database file is created for each project. You can also create your own user database:

  • System database .

    • database writes are configured only through server variable settings in iRidi Studio;
    • can be read using specialized SQL queries;
  • cannot be edited or deleted.

  • User database

    • database writes are performed only through JavaScript;
    • can be read using specialized SQL queries;
    • can be edited and deleted through JavaScript.

Where to find the system database:

Find the database file path through the web interface of the server, on System > Database.

How to save data to the system database:

Driver Channel, Driver Tags, Virtual Channel and Virtual Tag server variables can be recorded in the database. Recording settings are therefore available only for server variables. To record a driver channel, select its server variable mapping to see the database recording settings:

Server15.png

  • Name - server variable name;
  • Path to server tag - full variable name, usable for script access and type identification;
  • Script Modifier - JavaScript modifier function that processes the variable before passing it to control panels;
  • Access - control panel access to the variable:
    • Public - allowed,
    • Private - denied;
  • Persist - restore the variable's last value after a server restart;
  • Description - optional description to help identify the variable;
  • Store In DB - variable recording format in the database:
    • None - do not record,
    • Signed 32bit - record as an integer,
    • Float 64bit - record as a floating-point number,
    • String UTF8 - record as a string;
  • Load On Start - restore the variable's value from the database after a server restart (unlike Persist = Yes , this restores the last value saved to the database, rather than the most recent value);
  • DB Save Strategy - the event that creates a database record:
    • Deadband - minimum change. A record is created if the variable changes by more than the specified value,
    • Interval - periodic recording. A record is created at the specified interval;
      • Interval Value - interval duration,
      • Interval Units - interval time unit (Ms, Sec and so on);
  • Forward value to - forward the value from one tag to another (for details, see here).

Recording can be configured in two ways:

  • at a specified time interval;
  • when the variable changes by more than a specified integer or fractional value.

The first method is useful for variables that change smoothly and relatively slowly, such as air temperature and humidity. The second is ideal for variables that change infrequently but significantly, such as lights switching on and off. Recording on change creates far fewer database records and avoids missing an event.

Server databases are accessed using specialized SQL queries that retrieve data matching specified conditions.

User database:

An editable database can be created using JavaScript. SQL queries write, read and edit data in the user database.

Accessing the user database through JavaScript:

Guide provides instructions for working with system and user databases.

Reference lists all database methods.

Plotting charts​

To display charts of variable changes, iRidi saves the variable values to an SQL database stored on iRidi Server.

To plot a variable's changes, i3 pro queries the database for a specified period and displays the results on a chart.

Once database recording is configured, you can display the variable in i3 pro as a chart.

Synchronizing the control panel and server​

It is best to create the visualization interface after the server project is ready: communication with automation equipment is configured, and virtual tags and their scripts are created on the server. Importing the server project quickly provides the full set of controllable variables for the visualization project. You then only need to link them to graphic items.

The server can work with multiple iRidi control panels running different projects or the same project. The visualization - a graphic interface for controlling automation equipment - runs only in i3 pro on a control panel (for details on creating a visualization project, see Visualization tools).

Connection​

Configure the server project: create the list of controlled devices and variables. Import the server project into an iRidi visualization project and configure graphic items to control server variables.

iRidi panels connect to iRidi Server and send commands. The server executes them by changing variable states in the automation equipment to which it is connected:

ServerSceem.png

Importing variables from Server Project​

There are several ways to add an iRidi Server driver to a Panel Project.

Quick project creation

Right-click the server project and select "Create panel project":

Server8.png

A Panel Project is created with an empty page and an iRidi Server driver containing all server tags. You can use them as commands and feedback channels, link them to items for control and display, and process them using iRidi Script.

Server9.png

After changing the server project, you can quickly synchronize it with the Panel Project. Select the iRidi Server driver and click Synchronize .

You can change the server project file used for driver synchronization in Source Project.

Adding iRidi Server to an existing visualization project

If you already have a visualization project and want to add a connection to the server:

Server10.png

  1. Add an iRidi Server driver from the database;
  2. Specify the *.sirpz project path to synchronize with the visualization project;
  3. The iRidi Server driver is populated with the current commands and feedback channels.
Note
  • To open an existing server project, right-click the Panel Project and select Open Server Project .

OpenServerProject.png

  • If the required server project is not specified in the iRidi Server driver settings, a dialog prompts you to open it in iRidi Studio through the file browser.

OpenServerProject2.png

Commands & Feedbacks​

Import provides two levels of settings:

  • iRidi Server - a driver containing the server variable list. Configure the IP address and other server connection settings here;
  • Commands and Feedbacks - commands and feedback channels for controlling variables. Commands are writable variables, and feedback channels are readable variables.

Commands and feedback channels must be linked to the project's graphic items to control equipment:

  • Link a command to a graphic item, specifying the value to send to the bus address when the item is pressed;
  • Link a feedback channel to a graphic item to display the group address state.

To link a command or channel to a graphic item, use drag&drop - dragging an object onto another.

Server6.png

Configuring the server connection​

Server7.png

iRidi Server connection settings:

  • Source Project - linked server project;
  • Log Level - log verbosity, from EMERGENCY (errors only) to DEBUG (detailed information);
  • Host - server IP address or domain name. You can use Local host 127.0.0.1 if the server and visualization run on the same device;
  • Port - TCP server connection port, default: 30464 ;
  • Wait for Connect (ms) - connection timeout, after which another connection attempt is made;
  • Wait for Data (ms) - response timeout, after which the request is repeated and the connection checked. Set 0 if the driver should not disconnect from equipment when no data is exchanged;
  • Keep Alive - connection keep-alive time in seconds;
  • Mode - local/remote control (for details, see here).

Changing connection settings​

You need to change connection parameters when you disconnect from the automation site's Wi-Fi network and start using 3G or another Wi-Fi network. For control to continue working, switch from the local IP address to the Internet router's public IP address.

Switching is not automatic; you need to press the connection mode selection button. For remote access, the automation system's control ports must be made public. To do this, configure Port Forwarding on the Internet router. A VPN can provide a secure connection.

  1. Download template (*.js) (right-click and save the linked file), then add it to the script editor using (+) Add script from file .

  2. Configure the script parameters as shown in the example:

function Internal_1() {
IR.GetDevice(Driver).SetParameters(Parameters1);
}
function External_1() {
IR.GetDevice(Driver).SetParameters(Parameters2);
}

Copy the driver name (Devices > Name ). Copy the parameter list exactly from the example.

  1. Select the button that switches between Internal and External parameters. Open Macros Editor for the Release event (Programming > Release (+) ), select Script Call and add it by double-clicking. Select the function the button calls:

Server11.png

Each button press now applies the corresponding connection settings.

Uploading the project to the server​

Upload a server project (*.sirpz) to the server in the same way as a project to the i3 pro client: using iRidi Transfer on your PC.

Transfer discovers and displays all running servers in the IP subnet. Use it to send a configuration project and license to iRidi Server.

See How to run a project on iRidi Server.