+1
Under review

Log of channels and feedbacks in UI

Nikolay Rusanov 7 years ago in Server Solutions updated by Andrey S 7 years ago 9

Dear support and community!


Client needs a log of what hapenned in the system during last day, week, month. As a list in i3 pro:


...

18:01:21 - Main light 221 is 100

18:01:33 - Door magnet contact is 1

18:01:35 - Door magnet contact is 0

...


I see DB API can do this but I cannot understand how to use it. Can I have an example of this use?


Thank you

Thanks. But I need i3 pro example of how to show system database changes in UI

+1

You must disable Insert Cache in Server Settings or use User Database to see сurrent changes

   for (i=0;i<5;i++)
IR.SetVariable("Server.Tags.Log_tag", "from server "+i);

   var in_Value="";
   var sql = IR.GetDatabase(); // assign sql variable properties of the system database.
   var tag_id = sql.Request('SELECT TAG_ID FROM TAGS_PASSPORT WHERE NAME=\'Log_tag\'').GetRowValue(0,0);
   IR.Log('Log_tag TAG_ID='+tag_id);
   var examp = sql.Request('SELECT DATETIME, VALUE  FROM STRING_TAG_HISTORY WHERE TAG_ID='+tag_id+' ORDER BY DATETIME DESC');
   for (i=0;i<examp.Rows;i++) {//make a cycle to output value
      var dt=new iDate(examp.GetRowValue(0,i)); //iDate is ugly!
      var dt_txt=dt.date + "." + dt.month + "." + dt.year + " [" + dt.hours + ":" + dt.minutes + ":" + dt.seconds + "]";       
      in_Value += dt_txt+'  '+ examp.GetRowValue(1,i) + "\n";
   }
   sql.Close()
   IR.Log(in_Value);

and send it's value by virtual tag to panel

http://dev.iridiummobile.net/Editor_Server_Tools/en#Use_of_Intellectual_Gateway_Function_for_Data_Exchange_between_Virtual_Channel_and_Tag

Thanks for your attention, but again, this is not what is need. I need this in i3 pro:

...

18:01:21 - Main light 221 is 100

18:01:33 - Door magnet contact is 1

18:01:35 - Door magnet contact is 0

...

I need example of .sirpz and .irpz file from support team please

Under review

hello,

i attech an example

Jurnal(2).sirpz

Jurnal(2).irpz


wait for your feedback

Sorry it is not working at all. I even added modbus channels (I saw them in client project), but nothing


+1

Thank you very much, it is working good with following files:

Jurnal(4).sirpz

Jurnal(3).irpz


Data is taken from _user directory_\Documents\iRidium pro documents\Server\Database


Client project looks like this:



Add any drivers to server project and mark feedbacks to "Store in DB" as signed 32bit, then you see them in client project as list.


In client project you can change default 60 sec. for automatic updates:

var INTERVAL_TO_REFRESH = 60000; //Interval to refresh


In server project you can change limit of records in the list (if too many list may not show):

var LIMIT_TO_RECORD = 300; //Limit to display records

all types together in one query with datetime conversion

   var sq='SELECT datetime(DATETIME, \'+2415018 days\', \'+12 hours\', \'localtime\') DT, NAME, CAST(VALUE as text), QUALITY ' +
            'FROM   STRING_TAG_HISTORY  s ' +
            'INNER JOIN TAGS_PASSPORT t ' +
            'ON t.TAG_ID = s.TAG_ID ' +
            'UNION ' +
            'SELECT datetime(DATETIME, \'+2415018 days\', \'+12 hours\', \'localtime\') DT, NAME, CAST(VALUE as text), QUALITY ' +
            'FROM FLOAT_TAG_HISTORY f ' +
            'INNER JOIN TAGS_PASSPORT t ' +
            'ON t.TAG_ID = f.TAG_ID ' + 
            'UNION ' +
            'SELECT datetime(DATETIME, \'+2415018 days\', \'+12 hours\', \'localtime\') DT, NAME, CAST(VALUE as text), QUALITY ' +
            'FROM INTEGER_TAG_HISTORY i ' +
            'INNER JOIN TAGS_PASSPORT t ' +
            'ON t.TAG_ID = i.TAG_ID ' +            
            'ORDER BY DT DESC;'