Logo Logo en
  • iRidi Pro
    Основные компоненты
    • Приложение i3 Pro
    • iRidi Pro Server
    • iRidi Studio
    • iRidium studio v. 1.3.8 (устаревшая версия)
    Java Script в iRidi
    • Руководство
    • Справочник
    • Примеры
    • JS драйвера
    другие
    • Личный Кабинет
    • iRidium Cloud
    • iRidium Transfer
    • Push-уведомления
    • Лучшая практика
    Лицензирование
    • Лицензирование и передача проекта
    • Оффлайн-лицензирование
    • Активация iRidi Pro Server
  • Продукты
    i3 lite
    • Приложение i3 lite
    • Регистрация и лицензирование
    • Сервер
    • Модули
    KNX Home Server
    • Приложение i3 KNX
    • KNX Home Server
    BUS77 HOME SERVER
    • Приложения Bus77 Home и Bus77 Lite
    • Bus77 Home Server
    Решения
    • BYOD - решение для гостиниц
    • Портал жителя - решение для МКД
    iRidi SCADA
    • iRidi SCADA
  • Bus77
    НАСТРОЙКА BUS77
    • Основы Bus77
    • Приложения Bus77 Home и Bus77 Lite
    • Работа с драйвером Bus77 в iRidi Studio
    • Настройка шины Bus77 в iRidi Studio
    ПРОТОКОЛ BUS77
    • Характеристики CAN (Bus77)
    • Описание протокола
    • Исходники на GitHub
    ОБОРУДОВАНИЕ BUS77
    • Каталог Bus77 Pro
    • Каталог Bus77 Lite
  • Поддерживаемое оборудование
    Драйверы
    • Список драйверов
    • ProAV драйвера
    • AV & Custom Systems
    • JS драйвера
    • Сторонние драйвера и фриланс
    Протоколы и интерфейсы
    • Голосовое управление
    • 1-Wire
    • BACnet IP
    • Bus77
    • KNX
    • KNX IP BAOS
    • Weinzierl kBerry
    • Microsoft Exchange
    • Modbus
    • MQTT
    • NFC
    • ODBC
    • Onvif
    • SIP
    • SNMP
    • Wake On Lan
    • Z-Wave
    • ZigBee
    Производители
    • AMX
    • AVCiT
    • Beckhoff ADS
    • Biamp Tesira
    • Bluesound
    • Casambi
    • BSS Harman
    • Clipsal
    • ControlArt 7Port
    • Crestron
    • DigiBird
    • Domintell
    • Duotecno
    • EIDE
    • EPSNET
    • Global Cache
    • HDL Buspro
    • Helvar
    • IEAST
    • INELS BUS
    • INELS Wireless
    • Intesis
    • Kleger
    • Kramer VIA
    • Kramer 3000
    • Larnitech
    • Legrand Netatmo
    • LG TV
    • Lutron
    • Lutron Homeworks QS
    • MyHome
    • Nest
    • Novastar
    • Panasоnic PTZ
    • Philips Dynalite
    • PJLink
    • Satel
    • SamsungTV
    • Sonos
    • Somfy
    • SpinetiX
    • Televic Conference
    • TIS
    • Tion
    • URRI
    • Velbus
    • Velocio
    • Vinteo
    • WyreStorm
    • WiiM
    • Xicato
    • Yamaha
    • ZONT
    • Z-Wave.me
    Протестированное оборудование
    • Панель HDL S57
    • Панель HDL S10
    • SIP-домофон
    • Akuvox
    • Arlight
    • Divus
    • QBic TD-1050 PRO
    • QBic TD-1060 Slim
    • QBic TD-1070
    • Sigur
    • Uni-Ubi
    • Velocio
  • Оборудование iRidi

    Серверы
    • HS Сервер
    • ProAV Control Processor Basic
    • ProAV Control Processor Advanced
    • Спецификация контроллеров UMC
    • Настройка контроллера UMC C2
    • Настройка контроллера UMC C3
    • Настройка контроллера HDL IntelliCenter 2 (UMC C4)
    Модули расширения
    • I-PX-RS1
    • I-PX-RS4
    • I-PX-IR3
    KNX
    • KNX Home Server
    • KNX IP Interface
    Панели управления
    • iRidium Panel 7
    • Touch Panel P3
    • Touch Panel P6
    • Touch Panel P8
    • Touch Panel P10
    • Tabletop Touch Panel 10
    • AV Remote Control
    ОБОРУДОВАНИЕ BUS77
    • Каталог Bus77 Pro
    • Каталог Bus77 Lite
    • Differences
iRidium mobile web-site
Содержание
    Инструменты‌
    • Сведения о странице
    • Постоянная ссылка
    • Версия для печати
    • Спецстраницы
    • Связанные правки
    • Ссылки сюда
    Login / Create Account
    Материал из for iRidium developers
    Перейти к: навигация, поиск
    Эта страница является переводом страницы JS Samples. Перевод выполнен на 100%.

    Other languages:
    English • ‎русский
    The section is under development.

    Содержание

    • 1 Examples of using iRidium API
    • 2 Drivers (DDK, Drivers API)
      • 2.1 Custom TCP Server in iRidium Client
    • 3 Interface (GUI API)
      • 3.1 Animation of Items with the Help of IR.Tween
      • 3.2 Font Control
    • 4 Notifications (Push API)

    Examples of using iRidium API

    Examples of using iRidium API methods and functions
    « Guide « Handbook

    Examples of using iRidium JavaScript API with descriptions

    Updated: 06.2.2019
    Source language: JavaScript
    Language version: 1.5
    Specification: ECMAScript Edition 3
    The JS version that we use is not the latest
    one and it does not support new constructions,
    but its functions are enough for panel projects
    in 99% of all cases. To satisfy the remaining
    one per cent converters of the https://babeljs.io
    type can be used and of course experience
    and developer's skills help.
    Report an error


    Drivers (DDK, Drivers API)

    Examples of creating and editing driver settings with the help of iRidium API


    Custom TCP Server in iRidium Client

    Custom Server on the basis of the AV & Custom Systems driver can take client connections on the basis of AV & Custom Systems and third-party applications. It can also process data sent by the client and send commands to it.

    Remember, the server launched in the i3 pro application works only until the application is launched and the server cannot store the database as the iRidium Server specialized solution.

    Use of "the server on a client" is very limited. It can be used only for synchronization of some data between control panels, when installation of iRidium Server is not possible for some reason.

    // TCP server on port 5678
    function start_tcp_server(server_name)
    {
       // name, port, max connections
       var name = server_name;
       var port = 5678;
       var max_clients = 10;
       var tcp_device = IR.CreateDevice(IR.DEVICE_CUSTOM_SERVER_TCP, name, "", port, max_clients);
     
       // start server
       tcp_device.Connect();    
     
       // inform when the server online
       IR.AddListener(IR.EVENT_ONLINE, tcp_device, function(text)
       {
          IR.Log("Server is ONLINE");
       });
     
       // register connected client
       IR.AddListener(IR.EVENT_ACCEPT, tcp_device, function(id)
       {  
          IR.Log(tcp_device + " ACCEPT CLIENT "+id);
       });
     
       // process received data
       IR.AddListener(IR.EVENT_RECEIVE_TEXT, tcp_device, function(text)
       {
          //IR.Log("INPUT DATA: "+text);
          var strings = text.split('\r\n');
          var string;
          while(string = strings.shift())
          {
             var parts = string.split(":");  // parse the string with ":" devider
             switch(parts[0])
             {
                case "LOG":    // if the first substring of received data = "LOG"
                IR.GetItem("Page 1").GetItem("Item 1").GetState(0).Text = IR.GetVariable("System.Time.24")+" "+parts[1];
                IR.Log(IR.GetVariable("System.Time.24")+" "+parts[1]);
                break;
                case "ERROR":  // if the first substring = "ERROR"
                IR.GetItem("Page 1").GetItem("Item 2").GetState(0).Text = IR.GetVariable("System.Time.24")+" "+parts[1];
                IR.Log(IR.GetVariable("System.Time.24")+" "+parts[1]);
                break;
                case "DATABASE":  // if the first substring = "DATABASE"
                IR.Log(parts[1]);
                break;
             }
          }
       });
    }
     
    // start the server when project starts
    start_tcp_server("Custom Server TCP");
    download:
    • server example
    • example of a client connected to the server


    Interface (GUI API)

    Examples of controlling properties of pages, popups and graphic items with the help of iRidium API


    Animation of Items with the Help of IR.Tween

    The tweener specifies the variable value in the indicated segment calculated by some formula. It allows you to create animation with object movements on a particular segment of the indicated curve.

    The tweener can be used for the gradual appearance of a popup from the screen side. Use the linear tweener for the popup to move straightforward.

    function ShowTop() 
    {
       TopTween("Popup 1", 820, 34, 250);  // popup, X, Y, moving range from Top
    }
     
    ////////////////////////////////////////////////////////////////////////////////
    // Creating Effects
    ////////////////////////////////////////////////////////////////////////////////
    var timer = 0;
    var speed = 20;    // showing speed
     
    function TopTween(popup, X, Y, range)
    {
       IR.ShowPopup(popup);
       IR.GetItem(popup).X = X;
       var Tm = IR.SetInterval(1, function()
       {          
          timer++;
          var Tween = IR.Tween("TWEEN_LINEAR", timer, 0, range, speed); 
          IR.GetItem(popup).Y = Y+Tween; 
          if (timer > speed) IR.ClearInterval(Tm); timer = 0;
       });
    }

    download:

    sample of using


    Font Control

    You can set the font or change the font size for the item via the .FontId state property.

    FontId - the font identifier. It stores the pointer to the font and the font size. You cannot change the font size separately.

    Create a new font and assign it to the item state via FontId. For creation of new fonts it is important to use the identifiers which have not been used in the project (the editor creates its own system fonts using identifiers beginning with 1). For getting free id, your should use js method IR.FreeFontID

    Indicate which font file must be used as a basis, what size must be set up. Assign a font identifier not used in the project before:

    var Font=IR.FreeFontID; //Get free font ID
    IR.CreateFont(Font, "tahoma.ttf", IR.GetItem("Страница 1").GetState(0).FontSize+10);//Create new font with new size and id
    IR.GetItem("Страница 1").GetState(0).FontId=Font;//Set new font to the state
    download:
    • example of font creating and editing


    Notifications (Push API)

    Sending of Push notifications to control panels. The notifications are sent by the server (there are no any other possibility to do it in v1.0.10).


    1 "'Create groups of control panels"'

    By default, none of control panels will receive Push notifications until you place it in the Group of panels that can get Push notifications.

    The groups are set up on the web site, see the instructions.

    Each group has an ID and name. That is the group ID you will use when indicating which panels have to get notifications.


    2 "'Set up the script for sending notifications from the server"'

    In the server project create a new script file. Add the condition for notification sending and the command for sending Push notifications in it. The condition for sending Push notifications can be change of any server variable - associated with the driver or a virtual one.

    Example: send a notification when channel "Address 1" of the "KNX" driver takes value 1. The notification will be received by the group panels with ID = 1.

    function sendPush (text, group) 
    {
       IR.SendPush(text, "", group);  
       // text - message that will be displayed in notification
       // group - group of Panels seted up in Cloud Object properties on iRidium Mobile web site
    }
     
    IR.AddListener(IR.EVENT_TAG_CHANGE, IR.GetDevice("KNX"), function(name, value)
    {
       if (name == "Address 1" && value == 1) 
       {
          sendPush("Leakage in the kitchen! The water supply is turned off", 1); 
       } 
    });

    No additional settings and scripts are required on the control panel with i3 pro. The panel will get notifications if it is in the specified group.

    Источник — «https://dev.iridi.com/index.php?title=JS_Samples/en&oldid=70800»
    Категория:
    • Инструкции
    About us
    Company
    Team
    History
    Philosophy
    Rewards
    Partnership
    Our partner
    Partnership Programs
    Apply for partnership
    products
    iRidium pro
    iRidium lite
    iRidium gate
    iRidium server
    Loads
    iRidium pro
    iRidium lite
    Other version
    Marketing materials
    Support
    On-line courses/Video
    Recommended equipment
    Other version
    iRidium pro
    Documentation
    FAQ
    Forum
    iRidium lite
    Documentation
    Forum
    Projects
    Standart projects
    Smart buildings
    Smart house
    Special solution
    Find a dealer
    News
    Youtube
    Twitter
    VK
    Logo
    contact@iridi.com
    +7 (499) 322-73-29

    Privacy policy