Skip to main content

iRidi Studio

iRidi Studio includes tools for configuring commands and receiving feedback data from controlled equipment. Equipment connections are configured on the I/O tab and in the script editor.

iRidi Server project

An iRidi Server project is a program that runs on the Server and connects it to automation equipment.

Server and control panel interaction

ServerPrincipalSceemDriverLayer.png

Server components

  • Drivers - connect to equipment and store the list of controllable variables. They are linked to server channels
  • Server channels - intermediate variables between control panels and driver channels. Server channels combine the variables of all drivers into a single namespace
  • Virtual variables - store server data and JavaScript results that are not linked to physical driver variables
  • Database - records the history of changes to server variables
  • JavaScript - defines scenarios, logic, and schedules (the server's intelligent functions), and lets you modify 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 , which lets third-party applications and systems 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 - this driver establishes a TCP connection to the server
    • JavaScript in i3 pro - lets you create scenarios that run on the control panel (for example, to control the graphical interface)
    • the graphical interface in i3 pro - a visual interface for controlling automation equipment
  • Web interface - a server settings interface that can be opened in a browser. It does not display the user's Panel Project interface
  • Third-party applications - applications and devices that can control the server by sending HTTP commands configured according to the REST API of the server

Configuration steps for a server project depend on the automation requirements and may therefore differ (some steps can be skipped).

The common requirement is that the server connects to specific automation equipment, so we will configure the equipment connection first.


I/O. Equipment connection​

The simplest server application requires connecting several control panels to the equipment. We will configure data transfer through the server to support several control panels

To do this, we will:

  1. create a server project
  2. add a list of drivers to control
  3. configure commands and feedback channels for these drivers
  4. create an i3 pro project based on the server project

Adding a driver​

Create a new server project: File > New > New Server Project.... Open the tab I/O

Create a server project:

From the database

Drag the driver from Device Panel to the I/O > DRIVERS window: Editor_add_custom_driver_toServer.png

Configure the driver: specify Host, Port, and other connection parameters

Importing from a configuration file

Editor_project_device_panel_import_add_drivers.png

iRidi supports importing from the following files:

ETS Project (.pr3, *.pr4, *.pr5, *.knxproj) - import group addresses from ETS (KNX) Simpl project (.smw) - import Crestron joins Clipsal project (.xml) - import Clipsal groups iRidi Archive Project (.irpz) - import drivers from iRidi projects iRidi Server Project (.sirpz) - import an iRidi Server driver from an iRidi project Modbus CSV Files (.csv) - import Modbus registers from a csv table

Finding devices on the local network

Editor_project_device_panel_scan_add_drivers.png

iRidi supports scanning the local network to discover specific types of equipment. Scanning lets you quickly create a list of devices and their commands:

*HDL-BUS Pro Net (UDP) - equipment in an HDL-BUS Pro system *Lutron Net (UDP) - equipment in a Lutron system *DuoTecno (TCP) - equipment in a DuoTecno system *Domintell (UDP) - equipment in a Domintell system


Based on a Panel Project

If you already have a control panel project (.irpz) created in iRidi V2 or V3, you can generate a server project automatically. This produces a Panel Project that connects to the server and a server project that connects to the equipment previously configured in the Panel Project. This conversion is the fastest way to obtain a server-based solution.

Editor_Convert_PanelProject_toServer.png

  • Note that, unlike i3 pro, iRidi server does not support:
  • a graphical interface,
  • project tokens, or
  • most system tokens.

References to graphical items and tokens will therefore cause the script to fail. Correct the script manually by removing invalid references; references to project tokens can be replaced with references to virtual channels and tags.

Driver and server variables​

The I/O tab of the server project is visually divided into two parts: DRIVERS and IRIDIUM SERVER:

  • the DRIVERS tab shows connection settings for automation equipment.
  • the IRIDIUM SERVER tab shows automation equipment variables mapped to server variables. Server variables combine all equipment channels into a single namespace. The control panel accesses the server variables, which in turn pass data to the equipment.

The driver mapping to IRIDIUM SERVER variables consists of the following tabs:

  • Driver Tokens - driver variables. Show the equipment connection status
  • Channels - controllable variables
  • Tags - variables from which feedback can be received

Writing a value to a Server channel activates an equipment command. Feedback works similarly: it is passed from the driver's Feedback to the corresponding Server tag.

  • Server variables can be written, read, and modified using JavaScript. Modification means an intermediate conversion of data on the server before a command is sent to equipment or feedback is passed to the control panel.

Driver variables. Show the equipment connection status

Server_Token_Relations.png

  • Online - connection state to the controlled system (Online/Offline = 1/0)
  • Status - system connection status (Offline/Connecting/Online/Waiting = 0...3)
  • Host - the remote system's domain name
  • HostPort - the port on the remote system to which i3 pro connects
  • IP - the control panel's IP address
  • HostIP - the 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

Driver tokens store information about the server's connection to controlled equipment. They can be stored in the database and used to plot charts or display a log.

Commands / Channels - variables used to control equipment.

Virtual Channels - controllable virtual server variables. They are not directly linked to controlled equipment. You can create these variables manually and write application results to them: numbers, strings, and arrays. Data to write is generated by JavaScript on the server or from the control panel.

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

Commands / Channels
Server_Tag_Relations.png
Virtual Channels
Virtual_tags_On_Server.png

  • Name - short channel name
  • Full Name - full server channel name; use it to access the variable from JS on the server. It is displayed in the Panel Project.
  • Description - optional variable description
  • Script Modifier - a script modifier function that performs an intermediate conversion of values before they are sent to a driver channel or after they are received from the control panel and script.

Feedbacks / Tags - variables from which feedback is required.

Virtual Tags - virtual server variables from which feedback can be received. They are not directly linked to controlled equipment.

Feedback / Tags
Server_Fb_Relations1.png
Virtual Tags
Virtual_tags_1_On_Server.png

  • Name - short name
  • Full Tag Name - full name for access from scripts
  • Description - optional description
  • Access - variable type:
    • Public - can be changed from the control panel,
    • Private - can only be changed from the server
  • Script Modifier - execute a JavaScript function whenever the tag is activated; this lets you modify received data before passing it to the control panel
  • Persist - restore the variable's last value if the server restarts
  • Store In DB - store all changed values in the database
  • Load on Start - retrieve this tag's last value from the database when the server starts (the setting appears if the value is stored in the database).

Creating a Panel Project​

Once the drivers in the server project are configured, you can create a project for the control panel: a visual interface for controlling the server.

The project is generated from the server project because it must contain information about server variables.

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 FastCreateUIbasedOnServer.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.

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

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

Adding iRidi Server to an existing Panel Project

If you already have a Panel Project and want to add a connection to the server:

FromDBSincWithSource.png

  1. add the iRidi Server driver from the database
  2. specify the path to the *.sirpz project with which to synchronize the Panel Project
  3. the resulting iRidi Server driver will contain the current list of commands and feedback channels.

If your server must not only pass data to control panels but also modify it, run scenarios, store a database, etc., study the remaining sections of this guide:


Schedule. Schedules​

The Schedule section in a server project is a scheduler implemented as a schedule of events. Events can occur once or recur at a specified interval.

Scheduler events initiate commands created in the Routine section (the list of routines). A scheduled event can recur at intervals ranging from 1 day to 1 occurrence every several years.

Click the Schedule tab in the iRidi Server project to open the scheduled event settings window. You can create any number of events in the schedule:

scheduler_setup1.png

  • add an event
  • delete an event. Routines that use this event as their trigger condition will stop working
  • edit event settings

Settings​

scheduler_setup2.png

  • Name - event name

  • Description - optional short description

  • Start - event start date and time

  • Finish - event finish date and time. Specify the date is unchecked by default, so the event finishes on the day it starts. Select the checkbox to specify a finish date.

  • Repeat - whether to repeat the event. If enabled, specify the recurrence interval. Examples and descriptions of recurrence settings follow below

  • End - when to stop event recurrence (if recurrence is enabled)

    • Never - never
    • Date - on the specified date

Astronomical timer​

The astronomical timer creates schedules and rules linked to sunrise and sunset. For example, you may need a schedule that turns outdoor lighting on at sunset and off at sunrise.


A simple photocell switch could be used, but it has several drawbacks:

  • the light sensor's condition must be monitored (if it becomes dirty, the light stays on during the day)
  • stray light on the sensor can prevent the lighting from turning on when required
  • the light cannot be turned on earlier\later relative to the light level

The astronomical timer has none of these drawbacks.


The following example shows how to configure it.

  • The astronomical timer does not require an Internet connection.

Configuring the astronomical timer​

  1. Create a server project or open an existing one.
  2. In the Config section, enter your coordinates in the Latitude and Longitude fields as decimal fractions and click Save .

Astrotimer_1.png


  1. Add and configure the equipment you will use.
  2. In the Schedule section, create a schedule for the lighting devices. Set the event start to Sunset and its finish to Sunrise on the following day.

Astrotimer_2_1.png


  1. In the Routine section, create rules:
    Rule 1:
    WHEN → Event start

Astrotimer_3.png


THEN → send a value to the device channel to turn it on

Astrotimer_4.png


Astrotimer_5.png


Rule 2:
WHEN → Event finish

Astrotimer_6.png


THEN → send a value to the device channel to turn it off

Astrotimer_7.png


BUT ONLY IF → the device is currently on (Feedback == 1)

Astrotimer_8.png


Astrotimer_9.png


Configuration is complete. The server automatically calculates sunrise and sunset times based on your location.

Recurrence settings (Repeat)​

Repeat - recurrence interval for the event. Configuration options:

scheduler_setup3.png

  • Never - do not repeat the event

scheduler_setup4.png

  • Every Day - every day at the specified time
  • Every Week - every week on the same weekday as the start date. For example, every Monday
  • Every 2 Weeks - every 2 weeks on the same weekday as the start date. For example, every second Sunday
  • Every Month - every month on the same day of the month as the start date. For example, on the 23rd of each month
  • Every Year - every year on the same day and month as the start date. For example, every January 1

scheduler_setup7.png scheduler_setup6.png scheduler_setup8.png

  • Custom - configure repetition by days, weeks, months, or years, but at a longer interval. For example, every 3 days, or every 2nd Monday of the specified month.
    • Repeat Settings: (only for Repeat: Custom)
    • Periodicity - recurrence interval
      • By Days - repeat every Nth day, starting from the event start date. For example, every 2nd day
        • Every: Days - recurrence interval in days, from 1 to 365
      • By Weeks - repeat every Nth week on the specified weekdays, starting from the event start date. For example, Thursday of every 2nd week
        • Every: Weeks - recurrence interval in weeks, from 1 to 52
        • On specified days of week - specify the weekdays on which the event should recur
      • By Months - repeat every Nth month. Select recurrence by specified dates or specified weekdays of the month. For example, every 2nd month on the 23rd, or on the 1st Monday of the month.
        • Every: Months - recurrence interval in months, from 1 to 12
        • On specified dates of month - repeat on the specified dates of the month. Several dates can be selected
        • On specified days of month - repeat on specified days of the month: the 1st Monday, the 4th Sunday, ...
      • By Years - repeat every Nth year
        • Every: Years - recurrence interval in years
        • On specified months - months of the year in which the event recurs. It occurs on the day of the month specified by the start date
        • On specified days - to repeat on a specified weekday rather than a calendar date, select At specified Day. For example, you can configure recurrence on the 1st Monday of the month

Routine. Routines​

Routine - a scenario that runs automatically when a specified event occurs. The event can be data received from equipment or an Event in the server schedule.

Settings​

Click the Routine tab in the iRidi Server project to open the routine settings window:

routine_setup1.png

  • add a routine
  • delete a routine
  • edit routine settings

Add a routine:

routine_ready.png

  • Name - event name
  • Description - optional short description
  • WHEN - the condition monitored by the routine. When it is met, the commands specified in THEN execute sequentially. Several conditions can be specified; meeting any one of them triggers the routine (OR). The following WHEN conditions are available:
    • Feedback - a driver channel changes
    • Event - a scheduled event starts or finishes
  • THEN - when the WHEN condition is triggered, all commands configured in THEN execute one after another as a sequence
  • BUT ONLY IF - limiting conditions. The routine does not run unless the conditions configured in BUT ONLY IF are met. If there are several conditions, all must be met (AND)
    • Feedback - a condition comparing a driver channel with a value is met
    • Event - a scheduled event is or is not currently in progress

Configuring WHEN, THEN, and BUT ONLY IF conditions:

routine_setup_when.png routine_setup_then.png routine_setup_butonlyif.png

  • Routines use event-driven logic: the WHEN condition is active only once, at the moment it changes from false to true. In subsequent true states, the WHEN condition is no longer active. Therefore, the THEN action sequence executes only once after WHEN is activated.

If the WHEN condition is already true when iRidi server starts, the THEN actions do not execute because a preceding false state of the WHEN condition was not recorded, which is required to activate the routine.

Using the schedule in routines​

WHEN. Scheduled event statuses are used to start routines:

  • Start - the event has started
  • Finish - the event has finished

BUT ONLY IF. The following states are used as checks when running a routine:

  • In process - the event is currently in progress
  • Not in process - the event is not currently in progress

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 by the channel 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: graphical 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 field:

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;
}

ModifyJSinWindow.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.

  • return the modified value (in_Value) to the variable using return in_Value;

  • returning a modified value is optional; you can simply perform a one-time action. In that case, the original value received by the function does not reach the destination and only triggers execution of the function.

  • The server web interface displays modified tag and channel values:

  • tag values in the web interface are the result of the Script Modifier function,

  • values set in the web interface using Set are passed to the input of the Script Modifier function before being sent to a channel on the physical device.


Modifier examples​

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;
}
}

To select the variable processed by the modifier function, specify the function name in the variable settings:

Return_Mod_Value_FromJStoPToken.png

Only the modification result, not the variable's actual value, reaches the Server variable and then the control panel.

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);
}

To select the channel processed by the modifier function, specify the function name in the variable settings:

Return_Mod_Value_FromJStoCmd.png

Driver Tags

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

To select the tag processed by the modifier function, specify the function name in the variable settings:

Return_Mod_Value_FromJStoFb.png

The tag outputs only the modification result, not the original value.

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"]);
}
}

To select the variable to process, specify the function name in the variable settings:

Return_Mod_Value_VirtModFromJS.png

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%
}

To select the variable to modify, specify the function name in the variable settings:

Return_Mod_Value_VirtTagFromJS.png


Writing and reading variables​

Server variables include Driver Tokens, Channels, Tags, Virtual Channels, and Virtual Tags. Their states 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 IRIDIUM SERVER
  2. Use IR.SetVariable to write a value to the variable:

Syntax

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

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

Example

![SetVirtualvarJS.png](/img/dev-iridi/Editor_Server_Tools/SetVirtualvarJS.png)

IR.AddListener(IR.EVENT_START, 0, function()
{
IR.SetVariable("Server.Channels.Virtual 1", 100);
});

Notes

Tip
  • the method can be used with server channels and tags

Reading a variable value

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

Syntax

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

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

Example

![SetVirtualvarJS.png](/img/dev-iridi/Editor_Server_Tools/SetVirtualvarJS.png)

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

Notes

Tip
  • the method can be used with 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.

download the example

ModifyFunc_Scheme_server.png

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

  1. Create a new project for iRidi Server
  2. Create a virtual channel (command) and a tag (feedback channel) with identical names. 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

ModifyFunc_ImageStudio_server.png 5. Configuration is complete. Writing a value to Server.Channels.Virtual 1 automatically passes it to Server.Tags.Virtual 1, and the control panel can display it as feedback.

Passing data between drivers​

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

download the example

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 scenario from the control panel​

  • 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.Scenario 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.Scenario 1");

To run this scenario, send the value 1 from the control panel to the server channel "Server.Channels.Scenario 1".

  • 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​

  • 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.

download: server project and client project

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

download: server project and client project

  • do not treat these projects as ready-to-use 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

    • data is written to the database only through server variable settings in iRidi Studio
    • can be read using special SQL queries
  • cannot be edited or deleted

  • User database

    • data is written to the database only through JavaScript
    • can be read using special SQL queries
    • can be edited and deleted using 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:

ServerStoreInDBsettings-2.png

  • Name - server variable name
  • Full Tag Name - full variable name; can be used for access from scripts and identifying the type
  • Description - optional variable description to make it easier to identify
  • Access - control panel access to the variable:
    • Public - allowed,
    • Private - prohibited
  • Script - a JavaScript modifier function that processes the variable before passing it to control panels
  • Persist - restore the variable's last value if the server restarts
  • Store In DB - format for storing the variable in the database
    • None - do not store
    • Signed 32bit - store as an integer
    • Float 64bit - store as a floating-point number
    • String UTF8 - store as a string
  • DB Save Strategy - 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 time interval
      • Deadband (Value) - minimum variable change requiring a database record
      • Interval (sec) - recording interval in seconds
  • Load On Start - restore the variable's value from the database after a server restart (unlike Persist = Yes , the restored value is not the very last value, but the last value stored in the database).

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 Panel Project. You then only need to link them to graphic items.

See Creating a project for the control panel


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