API проекта BeeToo

BeeToo API aims to get profit from code reusability inside home automation project. Complex BeeToo UI project structure with 3 layers being controlled by connected API. That is not changing from project to project. This is the key feature, that helps not to write custom bunch of code for each installation project.

Animation framework

Animation framework is wrapper around standard iRidium Script API IR.Tween: https://wiki2.iridiummobile.ru/Systems_API/IR.Tween

Framework allows programmer to easily run animation, defining the target of animation process and the properties, which are will be changed during animation process.

Method of animation call almost the same as jQuery's animate function: https://api.jquery.com/animate

Typical call of our animation API looks like that:

Animation.run(IR.GetPopup('FoobarPopup').GetState(0), 'Opacity', {start: 0, finish: 255}, PLAN_POPUP_SHOW_TIME);

Syntax:

Animation.run(uiObject, uiProperty, {start: startValue, finish: finishValue}, time, [tweenFunction]);

Function parameters:

What's inside of Animation class?

When one run animation process, the current thread look through Animation processors pool for one that is not busy.

First free animation processor will receive animation task as an object with all necessary parameters.

That's all, your current thread is free to continue your own work. Cause each Animation processor works in separate non-blocking thread by means of IR.EVENT_WORK: https://wiki2.iridiummobile.ru/Systems_API/IR.EVENT_WORK

The pool of Animation processors (threads) is limited with 3 processors. Why exactly three? Cause each one is executing in separate thread and this is an extra overload for iRidium client application.

If you will try to run any (even empty) 5 or 10 threads with help of IR.EVENT_WORK, you will see the dramatic fall of speed and latency of UI will raise in i2next/i2control apps.

If one trying to run animation process and all animation threads are busy, than your traget's ui property will be changed without animation immediately.

And you will see in log record like that:

[12:45:02.453] Animation: failed to run animation. Cause: all animation threads are busy!

Special role plays global variable EVENT_WORK_PAUSED of Boolean type. All animation threads are paused while

EVENT_WORK_PAUSED==true

About purpose of such behaviour look in the 'Show hide popups framework' section. Please, do not access this global variable in your own routines. Use only setEventWorkPaused to change the value of EVENT_WORK_PAUSED.

Show hide popups framework

In project Project.irp we are using popups, that should be never hided. For example, BeeToo_background_popup. This popup contain beautiful backgrounds, each suitable for one room.

That's why we cannot use IR.HideAllPopups (see https://wiki2.iridiummobile.ru/GUI_API/IR.HideAllPopups). Cause it will hide background layer.

One should show popup through showPopup method and hide through hidePopup. hidePopup method each time checks, that the name of popup (popupName attribute) is contains in the SHOWED_POPUPS.

In the same manner, hideAllShowOnePopup method do not call IR.HideAllPopups, but call hidePopup method for each popup, intended to be hided.

Let's look closer to each function of API, defined inside BeeToo_show_hide_popups.js script file.

Who shows popup for special room and is't background after start?

After project starts, one popup (we call it main) for specific room will be shown. The background appropriate for this room will be shown too. The code, executing mentioned procedures always placed inside BeeToo_onstart_show_popups.js script file. For example, content of this script file could be:

                    IR.AddListener(IR.EVENT_START, 0,
                        function () {
                        showBackground('room1');
                        showPopup("BeeToo_room1_main_popup");
                        });