Logo Logo en
  • iRidi Pro
    Major Components
    • i3 pro app
    • iRidi Pro Server
    • iRidi Studio
    • iRidium studio v. 1.3.8 (old version)
    Java Script in iRidi
    • Guide
    • Handbook
    • Samples
    • JS drivers
    others
    • My Account
    • iRidium Cloud
    • iRidium Transfer
    • Push notifications
    • Best practice
    Licensing policy
    • Licensing and giving ownership rights
    • Offline Licensing
    • iRidi Pro Server Activation
  • Products
    i3 lite
    • i3 lite app
    • Registration and licensing
    • Server
    • Modules
    KNX Home Server
    • i3 KNX app
    • KNX Home Server
    BUS77 HOME SERVER
    • Bus77 Home and Bus77 Lite apps
    • Bus77 Home Server
    Solutions
    • BYOD - solution for hotels
    • PMS - solution for buildings
    iRidi SCADA
    • iRidi SCADA
  • bus77_
    SETTING UP BUS77
    • Bus77 Basics
    • Bus77 Home and Bus77 Lite apps
    • Working with the Bus77 driver in iRidi Studio
    • Configuring the Bus77 in iRidi Studio
    BUS77 PROTOCOL
    • Characteristics of CAN (Bus77)
    • Исходники на GitHub
    Bus77 equipment
    • Bus77 Pro catalog
    • Bus77 Lite catalog
  • Works with
    Drivers
    • List of drivers
    • ProAV Drivers
    • AV & Custom Systems
    • JS drivers
    Protocols and interfaces
    • Voice Control
    • 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
    Manufacturers
    • 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
    Tested equipment
    • HDL S57 panel
    • HDL S10 panel
    • Intercom (SIP)
    • Akuvox
    • Arlight
    • Divus
    • QBic TD-1050 PRO
    • QBic TD-1060 Slim
    • QBic TD-1070
    • Sigur
    • Uni-Ubi
    • Velocio
  • iRidi equipment

    Servers
    • HS Server
    • ProAV Control Processor Basic
    • ProAV Control Processor Advanced
    • UMC Controller Specification
    • UMC C2 setting up
    • UMC C3 setting up
    • HDL IntelliCenter 2 (UMC C4) setting up
    Модули расширения
    • I-PX-RS1
    • I-PX-RS4
    • I-PX-IR3
    KNX
    • KNX Home Server
    • KNX IP Interface
    Control panels
    • iRidium Panel 7
    • Touch Panel P3
    • Touch Panel P6
    • Touch Panel P8
    • Touch Panel P10
    • Tabletop Touch Panel 10
    • AV Remote Control
    Bus77 equipment
    • Bus77 Pro catalog
    • Bus77 Lite catalog
    • Differences
iRidium mobile web-site
Contents
    Tools‌
    • Page information
    • Permanent link
    • Printable version
    • Special pages
    • Related changes
    • What links here
    Login / Create Account
    From for iRidium developers
    Jump to: navigation, search
    This page is a translated version of the page Log Journal and the translation is 100% complete.

    Other languages:
    English • ‎русский

    Example of Log Journal

    iRidium server allows to store data about device statuses in the database. Users often want to see in their control interface the journal of events that happened in the house this day (week, month). This example shows how to create a log journal in a panel project.
    To create a log jounal, you have to change a server project and a panel project,

    Server Project

    1 Set recording of tag values in the database

    ServerProjectTags.png

    2 Add two virtual channels to the project Day and Month and one virtual tag Data.
    3 Add a script to the project

    var LIMIT_TO_RECORD = 300;  //The maximum number of records
    /**
     * The funtion of getting values from the database
     * @param {string} Full tag name
     * @param {string} Tag value
     */
    function makeDataFromDatabase(in_TagName, in_Value) {
       var Day = new iDate(); // Get iDate object from the current date and time
       var l_oSql = IR.GetDatabase();  
       var l_oDate;
       var l_sTagID;
       var l_sTagName;
       var l_nGetDate;
       var l_nValue;
       var l_sMakeDate;
     
     
     
       if (in_Value == "day") {
          // Create iDate object from the last date
          l_oDate = new iDate(Day.year, Day.month, (Day.date - 1), Day.hours, Day.minutes, Day.seconds, Day.ms);
       }
       else if (in_Value == "month") {
          // Create iDate object from the last month
          l_oDate = new iDate(Day.year, (Day.month - 1), Day.date, Day.hours, Day.minutes, Day.seconds, Day.ms); 
       }
       // Request the database, select all events with the indicated date
       var l_oDataByDate = l_oSql.Request('SELECT TAG_ID, DATETIME, VALUE FROM INTEGER_TAG_HISTORY WHERE DATETIME > '
            +l_oDate.value+' ORDER BY DATETIME DESC'); 
       if (l_oDataByDate.Rows) {
          var l_nLimit = LIMIT_TO_RECORD > l_oDataByDate.Rows ? l_oDataByDate.Rows : LIMIT_TO_RECORD;
          for (var j = 0; j < l_nLimit; j++) {
             l_sTagID = l_oDataByDate.GetRowValue(0,j); //Get tag ID
             l_nGetDate = l_oDataByDate.GetRowValue(1,j); //Get the time when the tag value was changed
             l_nValue = l_oDataByDate.GetRowValue(2,j);  //Get tag value
     
             // Create iDate object from the time when the tag value was changed.
             var date = new iDate(l_nGetDate);
             //Create a string with the date and time
             l_sMakeDate = '';
             if (date.date < 10)
                l_sMakeDate += "0" + date.date + ".";
             else l_sMakeDate += date.date + ".";
             if (date.month < 10)
                l_sMakeDate += "0" + date.month + "." + date.year + " [";
             else l_sMakeDate += date.month + "." + date.year + " [";  
             if (date.hours < 10)
                l_sMakeDate += "0" + date.hours + ":";   
             else l_sMakeDate += date.hours + ":";   
             if (date.minutes < 10)
                l_sMakeDate += "0" + date.minutes + ":"; 
             else l_sMakeDate += date.minutes + ":";   
             if (date.seconds < 10)
                l_sMakeDate += "0" + date.seconds + "] ";
             else l_sMakeDate += date.seconds + "] ";
     
             // Ask the tag name from the database by its ID
             var l_oDataByTagID = l_oSql.Request('SELECT NAME, TAG_ID FROM TAGS_PASSPORT WHERE TAG_ID = '+l_sTagID); 
             var l_oDataByTagIDRows = l_oDataByTagID.Rows;
             for (var k = 0; k < l_oDataByTagID.Rows; k++) {  //Add the tag name and its value to the string
                l_sTagName = l_oDataByTagID.GetRowValue(0,k);
                l_sMakeDate += l_sTagName + " is " + l_nValue;  
                IR.SetVariable("Server.Tags.Data", l_sMakeDate);  //Write value to the server tag
             }
          }
          l_oSql.Close()  
       }     
    }
    IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function(in_sName, in_sValue)
    {
       if (in_sValue == "day" || in_sValue == "month")  
          //Call a function to generate data from the database
          makeDataFromDatabase(in_sName, in_sValue);
    });
     
    // Subscribe to tags
    IR.SubscribeTagChange("Server.Channels.Month");
    IR.SubscribeTagChange("Server.Channels.Day");

    Panel Project

    1 Then open a panel project and add a pop-up template with Item1 to it. Create a list where a log journal will be displayed. In the list properties set the popup created earlier as a template for the list. Create buttons to display events for a day and for a month.

    PanelProjectJournal.png

    2 Set "Day" and "Month" buttons to send text "day" and "month" to "Day" and "Month" virtual channels respectively.

    3 Add a script

    IR.AddListener(IR.EVENT_START,0,function()
    {  
       var l_sAllData = '';
       var l_bTest = false;
       var l_oInterval = null;
       var l_aNewData;
       var INTERVAL_TO_REFRESH = 60000;  //value of the data update interval
     
       //Interval of automatic data update
       IR.SetInterval(INTERVAL_TO_REFRESH, function(){
          IR.GetDevice("iRidium Server").Set("Day", "day");   
       });
       IR.SetTimeout(500, function () {
          IR.GetDevice("iRidium Server").Set("Day", "day");     
       });
       //Listener to change modes day\month
       IR.AddListener(IR.EVENT_CHANNEL_SET, IR.GetDevice("iRidium Server"), function (in_sName, in_sValue) {
          if (in_sName == "Day" || in_sName == "Month") {
             l_bTest = true;  
          } 
       });
     
       IR.AddListener(IR.EVENT_TAG_CHANGE, IR.GetDevice("iRidium Server"), function (in_sName, in_sValue) {      
          if (in_sName == "Data" && l_bTest) {
             IR.ClearInterval(l_oInterval);
             l_sAllData += (in_sValue + "\n");  
             IR.GetPage("Page 1").GetItem("Item 1").Clear();
             l_oInterval = IR.SetTimeout(1000, function () {  
                l_aNewData = l_sAllData.split("\n");  //Parse the string by "\n" separator
                for (var i = 0; i < l_aNewData.length - 1; i++) {
                   IR.GetPage("Page 1").GetItem("Item 1").CreateItem(i, 1, {Text: l_aNewData[i]});   //fill in the list
                }
                l_bTest = false; 
                l_sAllData = '';
                l_aNewData = [];            
             })             
          }   
       });    
    });


    Download an example of a server project
    Download an example of a panel project

    Retrieved from "https://dev.iridi.com/index.php?title=Log_Journal/en&oldid=112252"
    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