Эта страница является
переводом страницы
TimeTable. Перевод выполнен на 100%.
Timetable
Timetable is a capability realized in the studio for convenient control of routines*, it is like a task planner. The key feature is that a user gets an interface to control routines.
*You can read about creating Routines here.
Use:
1. Setting lighting to turn on at a definite period of time;
2. Decrease of power consumption at night;
3. Control of a watering system, etc.
Work iRidium Studio
The first step is to set a panel project. Then Create an item on a page of the panel project to which references will be made from a server project
Work with Timetable in a panel project
Work with Timetable in a server project
Working with Timetable in a Panel Project
A component of “Timetable” for a panel project is a graphic item that serves to display event, causing server Routines, connected with this item.
CreatingTimetable Item
1 Create' Timetable' graphic item.
It can be created int he Script editor with the help of IR.CreateItem().
To create an item on a definite page, use the following method IR.CreateItem() to a link to Page or Popup object, that is received with the help of IR.GetItem() method.
The item looks like a table with headings in the style of a calendar. The format of the calendar and other properties can be set in a script for the server part of the project. This item can be created only with the help of scripts and all its properties (size, color of headings and lines) are set only in the script.
Syntax:
IR.CreateItem(IR.ITEM_SCHEDULE, name, {parameter});
| On input |
Value |
Description
|
| name |
"SCHEDULE_ITEM" |
type: String the name of Timetable item that is unique for a page
|
| X |
8 |
type: Number X axis coordinate.
|
| Y |
104 |
type: Number X axis coordinate.
|
| Width |
1008 |
type: Number the width of the item.
|
| Height |
656 |
type: Number the height of the item.
|
| Routine |
“Routine 1” |
type: String a link to a routine.
|
| On output |
|
|
| Object |
[Object DialogItemPrototype] |
type: Object template of a graphic item.
|
Example to create a schedule on an active page
IR.AddListener(IR.EVENT_START,0, function() {
var scheduleItem = IR.CreateItem(IR.ITEM_SCHEDULE, "SCHEDULE_ITEM", {
//метод
X: 8, // X axis coordinate
Y: 104, // Y axis coordinate
Width: 1008, // the width of the item
Height: 656, // the height of the item
Routine: "Routine 1", // assigning a routine
});
IR.Log(scheduleItem); // [Object DialogItemPrototype]
});
Example to create 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", { //method
X: 8, // X axis coordinate
Y: 104, // Y axis coordinate
Width: 1008, // the width of the item
Height: 656, // the height of the item
Routine: "Routine 1", // assigning a routine
});
IR.Log(scheduleItem);
});
A schedule can be created by the app start or by any other event.
2 Set the clor and font of different items of Timetable with the help of .UpdateColors.
Syntax:
scheduleItem.UpdateColors = ({parameter})
| On input |
Value |
Description
|
| scheduleItem |
IR.GetItem("Page 1") .GetItem(“SCHEDULE_ITEM”) |
type: Object a link to a schedule
|
A full list of parameters that can be changed for Timetable:
- GridColor - the color of background behind the cells with days and a clock.
- TemplatesSelectState1Color - the color of state 1 of the background for setup sells that add an event.
- TemplatesSelectState2Color - the color of state 2 of the background for setup sells that add an event..
- CellsState1Color - the text color of days without an event in the yearly and monthly format.
- CellsState2Color - the text color of days with events in the yearly and monthly format.
- CellsState1TextColor - the background color of cells without events (months in a yearly schedule, days in a monthly schedule, hours in a daily schedule).
- CellsState2TextColor - the background color of cells with events (months in a yearly schedule, days in a monthly schedule, hours in a daily schedule).
- EventBlockState1Color - the color of state 1 of an event in a weekly format.
- EventBlockState2Color - the color of state 2 of an event in a weekly format.
- EventBlockState1TextColor - the font color of state 1 of an event in a weekly format.
- EventBlockState2TextColor - the font color of state 2 of an event in a weekly format
- HeaderColor - the color of heading background (days in a weekly schedule, hours and date in a daily schedule).
- HeaderTextColor - the text color of a heading (days in a weekly schedule, hours and date in a daily schedule).
- ControlBackgroundColor - the color of a heading.
- ControlButtonState1Color - the color of state 1 of navigation buttons.
- ControlButtonState2Color - the color of state 2 of navigation buttons.
- ListBackgroundColor - the background color behind the cells in the window to add events (the background color of a window to add an event).
- TemplatesDescriptionTextColor - the text color of setup values in adding an event.
- TemplatesLabelTextColor - the text color of the name of a setting in adding an event.
- MonthNameState1TextColor - the color of the month name in a yearly format without an event.
- MonthNameState2TextColor - the color of the month name in a yearly format with an event.
- YearNumberTextColor - the color of a year.
- ControlLabelTextColor - the color of the upper heading.
- CheckMarkColor - the color of the tick (in a checkbox).
- TemplatesCaptionAddTextColor - the color of the "Add" text.
- TemplatesCaptionDeleteTextColor - the color of the "Delete" text.
Version to use in a script
scheduleItem.UpdateColors({
GridColor : 0xFF4500FF, // the color of background behind the cells with days and a clock.
TemplatesSelectState1Color : 0xD8BFD8FF, // the color of state 1 of the background for setup sells that add an event
TemplatesSelectState2Color : 0xF08080FF, // the color of state 2 of the background for setup sells that add an event.
CellsState1Color : 0xFA8072FF, // the text color of days without an event in the yearly and monthly format
CellsState2Color : 0xE9967AFF, //the text color of days with events in the yearly and monthly format
CellsState1TextColor : 0xFFA07AFF, // the background color of cells without events (months in a yearly schedule, days in a monthly schedule, hours in a daily schedule)
CellsState2TextColor : 0xDC143CFF, // the background color of cells with events (months in a yearly schedule, days in a monthly schedule, hours in a daily schedule)
EventBlockState1Color : 0xB22222FF, // the color of state 1 of an event in a weekly format
EventBlockState2Color : 0x8B0000FF, // the color of state 2 of an event in a weekly format
EventBlockState1TextColor : 0xF08080FF, // the text color of state 1 of an event in a weekly formatе
EventBlockState2TextColor : 0xDC143CFF, // the font color of state 2 of an event in a weekly format
HeaderColor : 0xFFFF00FF, // the color of heading background (days in a weekly schedule, hours and date in a daily schedule)
HeaderTextColor : 0xFF1493FF, // the text color of a heading (days in a weekly schedule, hours and date in a daily schedule).
ControlBackgroundColor : 0xDC143CFF, // the color of a heading.
ControlButtonState1Color : 0xFA8072FF, // the color of state 1 of navigation buttons. (+ / Cancel / etc...)
ControlButtonState2Color : 0xF08080FF, // the color of state 2 of navigation buttons (+ / Cancel / etc...)
ListBackgroundColor : 0xDC143CFF, // the background color behind the cells in the window to add events (the background color of a window to add an event).
TemplatesDescriptionTextColor : 0xF08080FF, // the text color of setup values in adding an event
TemplatesLabelTextColor : 0xFA8072FF, // the text color of the name of a setting in adding an event.
MonthNameState1TextColor : 0xFF4500FF, // the color of the month name in a yearly format without an event.
MonthNameState2TextColor : 0xFF8C00FF, // the color of the month name in a yearly format with an event.
YearNumberTextColor : 0xFFA500FF, // the color of a year
ControlLabelTextColor : 0xFFFF00FF, // the color of the upper heading
CheckMarkColor : 0xFF4500FF, // the color of a tick (in a checkbox)
TemplatesCaptionAddTextColor : 0xFFA500FF, // the color of the "Add" text.
TemplatesCaptionDeleteTextColor : 0x8B0000FF, // the color of the "Delete" text
})
3 Assign a required routine to a schedule with the help of the Routine parameter.
Syntax:
scheduleItem.Routine = routine
| On input |
Value |
Description
|
| scheduleItem |
IR.GetItem("Page 1").GetItem(“SCHEDULE_ITEM”) |
type: Object a link to a schedule
|
| routine |
“Routine 1” |
type: String a link to a routine.
|
var scheduleItem = IR.GetItem("Page 1").GetItem("SCHEDULE_ITEM"); // a link to an object
scheduleItem.Routine = "Routine 1"; // assinging a routine
IR.Log("Linking a routine: " + scheduleItem.Routine); // logging
4 Activate a routine on a server with the help of IR.SetRoutineActive() method.
This method can be assigned to a button to allow a user to activate or deactivate a routine. Thus, an end-user can change the work of routines to suit his requirements.
Syntax:
IR.SetRoutineActive(routine, active)
| On input |
Value |
Value description
|
| routine |
“Routine 1” |
type: String, a link to a routine
|
| active |
1 - a routine is on 0 - a routine is off |
type: Number routine activity.
|
IR.AddListener(IR.EVENT_ITEM_PRESS, IR.GetItem("Page 1").GetItem("Item 1"),
function() //activating an event
{
IR.SetRoutineActive("Routine 1", 1); // assigning a routine
IR.Log("Assigning a routine: Routine 1"); // logging
});
Item Properties
Properties of a graphic item of Timetable type:
IR.GetItem(page/popup).GetItem(schedule_Item).property
| On input |
Value |
Description
|
| .Title |
“Title 1” |
type: String change of the item heading.
|
Work with Timetable in a Server Project
“Timetable” component for a server project is a special version of an ordinary routine. This routine differs from an ordinary one by special parameters that send values to a routine from the “Timetable” component of a panel project.
Creating a Schedule
There are 2 types of schedules: “Weekly schedule” and “Calendar schedule”.
The type of a schedule is set in the Script editor with the help of the following method IR.AddProRoutine (schedule_type).
Weekly schedule looks like a day schedule with1-hour slots for each day of the week from Sunday to Saturday. Events in the schedule are repeated every week without a capability to change it.
Calendar schedule is a detailed schedule with pages for a year, a month and a separate day with a flexible setting of repetition.
1 To create a schedule, open the “SCHEDULE” tab in a server project and add a new schedule by clicking “+”.
A popup appears to set the date and the time of an event.
2 Set the time of the start and the end of an event with the help of “Start” and “Finish”.
3 Set the frequency of Repetition in the settings of a weekly schedule: Every week or Custom. These types are suitable for a calendar schedule.
If “Custom” is selected, additional settings appear to set the dates for repeating the event:
Select a period of time during which repetition is required in the “Period”: By days , By weeks, By month or By year. To choose definite days for repetition in a weekly schedule, use By week. Any of the offered periods suits a calendar schedule.
4 Set the end of schedule work in the “End”.
- Never means that the event will be repeated until you stop the work of the schedule yourself;
- Date means that you must enter the exact date of the schedule end.
You can learn all details of setting a schedule if you follow this link.
Set events are highlighted in a schedule. If it is required they can be deleted or deactivated (read more in the "Use of Timetable Item") article.
5 Add a code to check if there are any schedules in the Script editor. In case no schedule is received, log an error:
IR.AddListener(IR.EVENT_START, 0, function () {
var scheduleID = 0; // creating a variable with a schedule ID
var scheduleEventID = 0; // creating a variable with an event ID
<!--T:57-->
var scheduler = IR.GetScheduler("Schedule 1"); // creating a variable with a schedule
if (scheduler) { // checking the availability of a schedule
scheduleID = scheduler.ID;
var schedulerEvent = scheduler.GetEvent("Event 1");
if (schedulerEvent)
scheduleEventID = schedulerEvent.ID;
<!--T:58-->
} else // otherwise we output an error
IR.Log("IMPOSSIBLE TO RECEIVE TIMETABLE");
6 You can create a routine, set an event and a condition to activate this event in JS in the Script editor of a server project. You can find a description of available methods to work with schedules if you follow this link.
An example of working with server routines
IR.AddProRoutine("Routine 1", IR.ROUTINE_TYPE_TIMETABLE, IR.ROUTINE_SERVICE_SCHEDULE_TYPE_WEEKLY_CYCLE); // create a routine
var routine = IR.GetProRoutine("Routine 1"); //get access to routine
// DELETE ROUTINE
/*
IR.Log("DELETE ROUTINE 2 RESULT: " + IR.DeleteProRoutine(routine_aut));
routine_aut = null;
IR.Log("ROUTINES: " + IR.GetProRoutines());
*/
if (routine) { //creating parameters
// string parameter
var stringParam = routine.AddParameter({
Type: IR.ROUTINE_PARAMETER_TYPE_STRING,
Name: "String"
});
<!--T:61-->
// numeric parameter
var numberParam = routine.AddParameter({
Type: IR.ROUTINE_PARAMETER_TYPE_NUMBER,
Name: "Number",
MinValue: 0,
MaxValue: 50
});
<!--T:62-->
// color parameter
var colorParam = routine.AddParameter({
Type: IR.ROUTINE_PARAMETER_TYPE_COLOR,
Name: "Color",
});
<!--T:63-->
// selection parameter
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-->
//log output
IR.Log("GET ROUTINE PARAMETERS: " + routine.GetParameters());
IR.Log("GET PARAMETER: " + routine.GetParameter("Number"));
<!--T:65-->
//DELETE PARAMETER
/*
IR.Log("DELETE_PARAMETER RESULT: " + routine.DeleteParameter(numberParam));
numberParam = null;
IR.Log("GET PARAMETERS: " + routine.GetParameters();
*/
<!--T:66-->
// Create event
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-->
//Log output:
IR.Log("GET EVENTS: " + routine.GetEvents());
IR.Log("GET EVENT: " + routine.GetEvent(1));
IR.Log("GET EVENT VALUE: " + event.Value);
<!--T:68-->
//DELETE EVENT
/*
IR.Log("DELETE_EVENT RESULT: " + routine.DeleteEvent(event));
event = null;
IR.Log("GET EVENTS: " + routine.GetEvents());
*/
<!--T:69-->
//Creation of condition
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-->
//log output
IR.Log("GET CONDITIONS: " + routine.GetConditions());
IR.Log("GET CONDITION: " + routine.GetCondition(1));
<!--T:71-->
// DELETE CONDITION
/*
IR.Log("DELETE CONDITION RESULT: " + routine.DeleteCondition(condition));
condition = null;
IR.Log("GET CONDITION: " + routine.GetCondition(1));
*/
<!--T:72-->
// Creating actions:
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-->
//Log output:
IR.Log("GET ACTIONS: " + routine.GetActions());
IR.Log("GET ACTION: " + routine.GetAction(1));
<!--T:75-->
// DELETE ACTION
/*
IR.Log("DELETE ACTION RESULT: " + routine.DeleteAction(colorAction));
colorAction = null;
IR.Log("ACTIONS: " + routine.GetActions());
*/
}
});
<!--T:76-->
Use of TimeTable Item
There are 2 types of timetables weekly timetable and calendar timetable. The feature of a weekly timetable is that a set event is repeated every week at the same time until the settings of a timetable are changed. Events in a calendar timetable are set in a definite day of the year and do not have a repetition property (weelky or yearly) (if the Repeat parameter is not set).
Weekly Timetable (Navigation)
To set an event, click “+” in the top right corner or select a slot of the required day and time of an event.
Calendar Timetable (Navigation)
Yearly page is a calendar for a year. In this page today is colored, but it does not show events that will happen according to the schedule. The calendar allows to go to the previous and the next years with up and down swipes.
Monthly page is opened by clicking in the month area in the “year” mode. It displays dates with events.
Daily page is opened by clicking a date in a month. It displays events in the time period. It works like n the “weekly” modem but it shows only 1 day. Event parameters are displayed on the event.
Creating and Setting Events
Each page of the navigation panel has “+”, by clicking which you can go to a window to create an event:
- Name - the unique name of an event.
- Day and time - date and time of event start and end.
- Operation - activation of a routine by the start or the end of a set period of time (Day and time).
- Routine parameters (String, Number, Color, Select) - set parameters for devices.
- Active status - activation / deactivation of an event.
Day and time
Day and time parameter has the following settings:
- Start / End is the selection of the date and time for the start and the end of an event.
- Repeat is the setting of event repetition.
Repeat:
- Never - the event won't be repeated and will work only 1 time;
- Every week - the event will be repeated every week at a set time / day of the week;
- Every 2 weeks - the event will be repeated at a set time / day of the week, every fortnight;
- Every month - the event will be repeated at a set time / date every month;
- Every year - the event will be repeated at a set time / date / month every year;
- Custom - more parameters to set repetition of an event.
Custom:
- Periodicity - selection of a time period for repetition (by days, weeks, months, years);
- Every - selection of a period to repeat.
Example: repeat an event on Monday, Tuesday and Wednesday every week (Every = 1).
Routine Parameters
After an event is created it's required to set data for routine activation. The input data can be of the following types: String, Number, Color and Select. Setting and creating routine parameters are described here.
After creating an event, click “Add” and the event will be added to the schedule.
If it is required, a created event can be deleted by clicking "Delete".