Timetable
Timetable is a Studio feature for convenient routine* management, similar to a task scheduler. Its key feature is a user interface for managing routines.
You can read the article on creating routines (Routines) here.
Applications:
-
Configuring lighting to turn on during a specified period;
-
Reducing power consumption at night;
-
Controlling when an irrigation system turns on, and more.
Working in iRidi Studio
First, configure the Panel Project. Create an item on a Panel Project page to reference from the server project.
Working with Timetable in a Panel Project Working with Timetable in a server project
Working with Timetable in a Panel Project
The "Timetable" component for a Panel Project is a graphical item that displays events triggering server routines (Routines) linked to this item.
Creating a Timetable item
- Create a Timetable graphical item. You can create the item in the script editor using IR.CreateItem(). To create the item on a specific page, apply IR.CreateItem() to a Page or Popup object reference obtained using IR.GetItem().
The item appears as a table with headers, styled as a calendar. You can configure the calendar format and other options in the script for the server side of the project. The item can be created only by a script, and all its settings (size, header and line colors) are configured only in the script editor.
Syntax:
IR.CreateItem(IR.ITEM_SCHEDULE, name, {parameter});
| Input | Value | Description |
|---|---|---|
| name | "SCHEDULE_ITEM" | type: String Timetable item name, unique within the page. |
| X | 8 | type: Number the X coordinate. |
| Y | 104 | type: Number the Y coordinate. |
| Width | 1008 | type: Number the item width. |
| Height | 656 | type: Number the item height. |
| Routine | "Routine 1" | type: String routine reference. |
| Output | ||
|---|---|---|
| Object | [Object DialogItemPrototype] | type: Object a graphical object instance. |
Example: creating a schedule on the active page
IR.AddListener(IR.EVENT_START,0, function() {
var scheduleItem = IR.CreateItem(IR.ITEM_SCHEDULE, "SCHEDULE_ITEM", { //метод
X: 8, // координата по оси Х
Y: 104, // координата по оси Y
Width: 1008, // ширина элемента
Height: 656, // высота элемента
Routine: "Routine 1", // привязка рутины
});
IR.Log(scheduleItem); // [Object DialogItemPrototype]
});
Example: creating a schedule on an inactive page
IR.AddListener(IR.EVENT_START,0,function() {
var scheduleItem = IR.GetItem("Page 2").CreateItem(IR.ITEM_SCHEDULE, "SCHEDULE_ITEM", { //метод
X: 8, // координата по оси Х
Y: 104, // координата по оси Y
Width: 1008, // ширина элемента
Height: 656, // высота элемента
Routine: "Routine 1", // привязка рутины
});
IR.Log(scheduleItem);
});
You can create the schedule at application startup or on any other event.
- Configure the color and font of individual Timetable elements using .UpdateColors .
Syntax:
scheduleItem.UpdateColors = ({parameter})
| Input | Value | Description |
|---|---|---|
| scheduleItem | IR.GetItem("Page 1") .GetItem("SCHEDULE_ITEM") | type: Object schedule reference |
Complete list of parameters you can change for Timetable:
- GridColor - background color behind the day and hour cells.
- TemplatesSelectState1Color - state 1 background color of the setting cells when adding an event.
- TemplatesSelectState2Color - state 2 background color of the setting cells when adding an event.
- CellsState1Color - text color for days without events in the year and month views.
- CellsState2Color - text color for days with events in the year and month views.
- CellsState1TextColor - background color of cells without events (months in the year view, days in the month view, hours in the day view).
- CellsState2TextColor - background color of cells with events (months in the year view, days in the month view, hours in the day view).
- EventBlockState1Color - event state 1 color in the week view.
- EventBlockState2Color - event state 2 color in the week view.
- EventBlockState1TextColor - event state 1 text color in the week view.
- EventBlockState2TextColor - event state 2 text color in the week view.
- HeaderColor - header background color (days in the week view, hours and date in the day view).
- HeaderTextColor - header text color (days in the week view, hours and date in the day view).
- ControlBackgroundColor - header color.
- ControlButtonState1Color - navigation button state 1 color.
- ControlButtonState2Color - navigation button state 2 color.
- ListBackgroundColor - background color behind the cells in the add event window (the add event window background).
- TemplatesDescriptionTextColor - setting value text color when adding an event.
- TemplatesLabelTextColor - setting name text color when adding an event.
- MonthNameState1TextColor - month name color in the year view without events.
- MonthNameState2TextColor - month name color in the year view with events.
- YearNumberTextColor - year color.
- ControlLabelTextColor - top header color.
- CheckMarkColor - checkbox (check mark) color.
- TemplatesCaptionAddTextColor - "Add" text color.
- TemplatesCaptionDeleteTextColor - "Delete" text color.
scheduleItem.UpdateColors({
GridColor : 0xFF4500FF, // цвет фона за ячейками дней и часов
TemplatesSelectState1Color : 0xD8BFD8FF, // цвет 1-ого состояния фона настроечных ячеек добавления события
TemplatesSelectState2Color : 0xF08080FF, // цвет 2-ого состояния фона настроечных ячеек добавления события
CellsState1Color : 0xFA8072FF, // цвет текста дней без события в годичном, месячном видах
CellsState2Color : 0xE9967AFF, //цвет текста дней с событиями в годичном, месячном видах
CellsState1TextColor : 0xFFA07AFF, // цвет фона ячеек без события (месяцев в годичном, дней в месячном, часов в дневном)
CellsState2TextColor : 0xDC143CFF, // цвет фона ячеек с событиями (месяцев в годичном, дней в месячном, часов в дневном)
EventBlockState1Color : 0xB22222FF, // цвет 1-ого состояния события в недельном виде
EventBlockState2Color : 0x8B0000FF, // цвет 2-ого состояния события в недельном виде
EventBlockState1TextColor : 0xF08080FF, // цвет текста 1-ого состояния события в недельном виде
EventBlockState2TextColor : 0xDC143CFF, // цвет текста 2-ого состояния события в недельном виде
HeaderColor : 0xFFFF00FF, // цвет фона заголовков (дни в недельном, часы и дата в дневном)
HeaderTextColor : 0xFF1493FF, // цвет текста заголовков (дни в недельном, часы и дата в дневном)
ControlBackgroundColor : 0xDC143CFF, // цвет заголовка
ControlButtonState1Color : 0xFA8072FF, // цвет 1-ого состояния навигационных кнопок (+ / Cancel / etc...)
ControlButtonState2Color : 0xF08080FF, // цвет 2-ого состояния навигационных кнопок (+ / Cancel / etc...)
ListBackgroundColor : 0xDC143CFF, // цвет фона за ячейками в окне добавления события (цвет подложки окна добавления события)
TemplatesDescriptionTextColor : 0xF08080FF, // цвет текста значения настроек в добавлении события
TemplatesLabelTextColor : 0xFA8072FF, // цвет текста имени настроек в добавлении события
MonthNameState1TextColor : 0xFF4500FF, // цвет имени месяцев в годичном виде без события
MonthNameState2TextColor : 0xFF8C00FF, // цвет имени месяцев в годичном виде с событием
YearNumberTextColor : 0xFFA500FF, // цвет года
ControlLabelTextColor : 0xFFFF00FF, // цвет верхнего заголовка
CheckMarkColor : 0xFF4500FF, // цвет чекбокса (галочки)
TemplatesCaptionAddTextColor : 0xFFA500FF, // цвет текста "Add"
TemplatesCaptionDeleteTextColor : 0x8B0000FF, // цвет текста "Delete"
})
- Link the required routine to the schedule using .Routine
Syntax:
scheduleItem.Routine = routine
| Input | Value | Description |
|---|---|---|
| scheduleItem | IR.GetItem("Page 1").GetItem("SCHEDULE_ITEM") | type: Object schedule reference. |
| routine | "Routine 1" | type: String routine reference. |
var scheduleItem = IR.GetItem("Page 1").GetItem("SCHEDULE_ITEM"); // ссылка на объект
scheduleItem.Routine = "Routine 1"; // привязка рутины
IR.Log("Линковка рутины: " + scheduleItem.Routine); // вывод в лог
- Activate the routine on the server using IR.SetRoutineActive() .
You can assign this method to a button to let the user activate or deactivate a routine. The end user can therefore control routine operation and adapt it to their needs.
Syntax:
IR.SetRoutineActive(routine, active)
| Input | Value | Description |
|---|---|---|
| routine | "Routine 1" | type: String, routine reference |
| active | 1 - routine enabled 0 - routine disabled | type: Number routine active status |
IR.AddListener(IR.EVENT_ITEM_PRESS, IR.GetItem("Page 1").GetItem("Item 1"),
function() //активация события
{
IR.SetRoutineActive("Routine 1", 1); // подключение рутины
IR.Log("Подключение рутины: Routine 1"); // вывод в лог
});
Item properties
Properties of a schedule, a graphical item of type Timetable:
IR.GetItem(page/popup).GetItem(schedule_Item).property
| Input | Value | Description |
|---|---|---|
| .Title | "Title 1" | type: String changes the item title. |
Working with Timetable in a server project
The "Timetable" component for a server project is a specialized version of a standard routine. Unlike a standard routine, it has special parameters for passing values to the routine from the Panel Project's "Timetable" component.
Creating a schedule
There are 2 schedule types: "Weekly schedule" and "Calendar schedule".
Set the schedule type in the script editor using IR.AddProRoutine (schedule_type).
Weekly schedule - displays a daily time schedule in 1 hour increments, from Sunday to Saturday. Routine events repeat every week, and the recurrence cannot be changed.
Calendar schedule - a detailed schedule with year, month, and day views and flexible recurrence settings.
- To create a schedule, open the "SCHEDULE" tab in the server project and click "+" to add a new event.
The event date and time settings dialog opens:

- Use "Start" and "Finish" to specify the default event start and finish times in the schedule.
- For a weekly schedule, select the recurrence (Repeat) in the event settings: Every week or Custom. All the listed types are suitable for a calendar schedule.
Selecting "Custom" opens additional event recurrence date settings:

In "Period", select a recurrence period by days, weeks, months, or years. To configure specific recurrence days in a weekly schedule, use "By weeks"; any of the available periods can be used for a calendar schedule.
- Specify when the schedule cycle ends in "End". *Never - the event continues to trigger until you stop the schedule manually; *Date - specify a particular date on which the schedule ends.
-
For full schedule setup details, follow this link.
-
Configured events are highlighted in the schedule. You can delete or deactivate them if needed (see "Using the Timetable item").

- In the script editor, add code to check whether the schedule exists. If the schedule cannot be retrieved, log an error:
IR.AddListener(IR.EVENT_START, 0, function () {
var scheduleID = 0; //<translate> <!--T:100-->
создание переменной с ID расписания</translate>
var scheduleEventID = 0; // <translate><!--T:101-->
создание переменной с ID события</translate>
<!--T:57-->
var scheduler = IR.GetScheduler("Schedule 1"); // <translate><!--T:102-->
создание переменной с расписанием</translate>
if (scheduler) { // <translate><!--T:103-->
проверка наличия расписания</translate>
scheduleID = scheduler.ID;
var schedulerEvent = scheduler.GetEvent("Event 1");
if (schedulerEvent)
scheduleEventID = schedulerEvent.ID;
<!--T:58-->
} else // <translate><!--T:104-->
иначе выводим ошибку</translate>
IR.Log("<translate><!--T:105-->
НЕ УДАЛОСЬ ПОЛУЧИТЬ РАСПИСАНИЕ</translate>");
- You can create a routine and specify an event and its activation condition in the server project's JS editor. For descriptions of the available routine methods, follow this link.
Example of working with server routines
IR.AddProRoutine("Routine 1", IR.ROUTINE_TYPE_TIMETABLE, IR.ROUTINE_SERVICE_SCHEDULE_TYPE_WEEKLY_CYCLE); // создаем рутину
var routine = IR.GetProRoutine("Routine 1"); //получаем доступ к рутине
// УДАЛЕНИЕ РУТИНЫ
/*
IR.Log("DELETE ROUTINE 2 RESULT: " + IR.DeleteProRoutine(routine_aut));
routine_aut = null;
IR.Log("ROUTINES: " + IR.GetProRoutines());
*/
if (routine) { //создание параметров
// строковый параметр
var stringParam = routine.AddParameter({
Type: IR.ROUTINE_PARAMETER_TYPE_STRING,
Name: "String"
});
<!--T:61-->
// числовой параметр
var numberParam = routine.AddParameter({
Type: IR.ROUTINE_PARAMETER_TYPE_NUMBER,
Name: "Number",
MinValue: 0,
MaxValue: 50
});
<!--T:62-->
// цветовой параметр
var colorParam = routine.AddParameter({
Type: IR.ROUTINE_PARAMETER_TYPE_COLOR,
Name: "Color",
});
<!--T:63-->
// параметр выбора
var selectParam = routine.AddParameter({
Type: IR.ROUTINE_PARAMETER_TYPE_SELECT,
Name: "Select",
SubType: IR.PT_INTEGER,
SubParameterArray: [{
Key: "ON",
Value: "1"
}, {
Key: "OFF",
Value: "2"
}]
});
<!--T:64-->
//вывод в лог
IR.Log("GET ROUTINE PARAMETERS: " + routine.GetParameters());
IR.Log("GET PARAMETER: " + routine.GetParameter("Number"));
<!--T:65-->
//УДАЛЕНИЕ ПАРАМЕТРА
/*
IR.Log("DELETE_PARAMETER RESULT: " + routine.DeleteParameter(numberParam));
numberParam = null;
IR.Log("GET PARAMETERS: " + routine.GetParameters();
*/
<!--T:66-->
// Создание события
var event = routine.AddEvent({
Type: IR.ROUTINE_SERVICE_TYPE_SCHEDULE,
ScheduleID: scheduleID,
ScheduleEventID: scheduleEventID,
Value: IR.SCHEDULE_EVENT_STATE_START,
ParametersValues: [{
ParameterID: stringParam.ID,
Value: "Hello, world!"
}, {
ParameterID: numberParam.ID,
Value: "50"
}, {
ParameterID: colorParam.ID,
Value: 0xFF00FFFF.toString()
}, {
ParameterID: selectParam.ID,
Value: "ON"
}]
});
<!--T:67-->
//Вывод в лог:
IR.Log("GET EVENTS: " + routine.GetEvents());
IR.Log("GET EVENT: " + routine.GetEvent(1));
IR.Log("GET EVENT VALUE: " + event.Value);
<!--T:68-->
//УДАЛЕНИЕ СОБЫТИЯ
/*
IR.Log("DELETE_EVENT RESULT: " + routine.DeleteEvent(event));
event = null;
IR.Log("GET EVENTS: " + routine.GetEvents());
*/
<!--T:69-->
//Создание условия
var condition = routine.AddCondition({
Type: IR.ROUTINE_SERVICE_TYPE_TOKEN,
Value: "1",
Token: "Server.Channels.Modbus TCP.Channel 1",
Operation: IR.ROUTINE_COMPARE_EQUAL
});
<!--T:70-->
//вывод в лог
IR.Log("GET CONDITIONS: " + routine.GetConditions());
IR.Log("GET CONDITION: " + routine.GetCondition(1));
<!--T:71-->
// УДАЛЕНИЕ УСЛОВИЯ
/*
IR.Log("DELETE CONDITION RESULT: " + routine.DeleteCondition(condition));
condition = null;
IR.Log("GET CONDITION: " + routine.GetCondition(1));
*/
<!--T:72-->
// Создание действий:
var numberAction = routine.AddAction({
Type: IR.ACTION_TYPE_SEND_NUMBER,
Channel: "AV & Custom Systems (TCP).AV Control Command",
Value: "1"
});
<!--T:73-->
var colorAction = routine.AddAction({
Type: IR.ACTION_TYPE_SEND_TAG,
Channel: "Modbus TCP.Channel 1",
Value: "Routines." + routine.Name + "." + colorParam.Name
});
<!--T:74-->
//Вывод в лог:
IR.Log("GET ACTIONS: " + routine.GetActions());
IR.Log("GET ACTION: " + routine.GetAction(1));
<!--T:75-->
// УДАЛЕНИЕ ДЕЙСТВИЯ
/*
IR.Log("DELETE ACTION RESULT: " + routine.DeleteAction(colorAction));
colorAction = null;
IR.Log("ACTIONS: " + routine.GetActions());
*/
}
});
<!--T:76-->
Using the TimeTable item
There are 2 schedule types: a weekly schedule and calendar schedule. In a weekly schedule, the specified event repeats every week at the same time until the schedule settings are changed. Calendar schedule events are set for a particular day of the year and do not repeat weekly or yearly (unless Repeat is configured).
Weekly schedule (navigation)

To open the event settings, click "+" in the upper-right corner of the page or select a cell at the intersection of the required event day and time.
Calendar schedule (navigation)
Year view - an overview of the calendar year. Today's date is highlighted, but scheduled events are not shown. Swipe up and down to move to previous and following years.

Month view - opens when you click a month in the year view. Displays dates with events.

Day view - opens when you click a date in the month. Displays events by time slot. Works like the week view but shows only 1 day. The event displays its parameters.

Creating and configuring events
Each view has a "+" in the navigation bar. Click it to open the event creation window:

- Name - unique event name.
- Day and time - event start and finish dates and times.
- Operation - activates a routine at the start or end of the specified time period (Day and time).
- Routine parameters (String, Number, Color, Select) - configurable device setpoints.
- Active status - activates / deactivates the event.
Day and time
The Day and time parameter has the following settings:

- Start / End - selects the event start and finish dates and times.
- Repeat - configures event recurrence.
Repeat:

- Never - the event does not repeat and triggers only once;
- Every week - the event repeats every week at the specified time / day of the week;
- Every 2 weeks - the event repeats every two weeks at the specified time / day of the week;
- Every month - the event repeats every month at the specified time / day;
- Every year - the event repeats every year at the specified time / day / month;
- Custom - advanced event recurrence settings.
Custom:

- Periodicity - selects the recurrence period (by days, weeks, months, or years);
- Every - selects the recurrence interval between the chosen periods. Example: repeat the event on Monday, Tuesday, and Wednesday every week (Every = 1).
Routine parameters
After creating an event, you must specify the data for activating the routine. Input data types are String, Number, Color, and Select. Schedule parameter setup and creation are described here.

After creating the event, click "Add" to add it to the schedule.

If needed, click "Delete" to delete the event.