Your comments

Which version are you using on the server?

ScriptCall macro.When calling the function the reference to the item which called the function is transferred in the script

https://support.iridiummobile.net/communities/5/topics/13832-sender-in-scriptcall-macro

You must reboot server after 1min or press ESC key twice

https://translate.google.com/translate?sl=ru&tl=en&u=https%3A%2F%2Fsupport.iridiummobile.net%2Fcommunities%2F5%2Ftopics%2F12955-sohranenie-znachenij-tegov-na-servere-iridium%23comment-138979

Good afternoon.
Thanks for the information provided.
Indeed, when choosing Store in DB = UTF-8, the interval is 1 minute (more precisely, no more than 1 minute). However, the choice of strategy (by changing the value or by the interval) is absent in the studio settings (both old and new). After your appeal, we decided to add the possibility of choosing a conservation strategy to the database, but the implementation deadlines have not yet been determined. We will inform you when ready.

https://support.iridiummobile.net/s/attachments/15553/18/11018/a7f9f2d84eec2f1982ffeba051241053.bmp

Sorry, it's old code

Server.js

moderator: please, edit message above

1. Удалил БД

2. Создал новый проект

3. Добавил комманду и фидбэк

4. Добавил примитивный скрипт

IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function(in_sName, in_sValue) {

   IR.SetVariable("Server.Tags.Feedback 1", in_sValue); 
});
 
// subscribing for tag changes
IR.SubscribeTagChange("Server.Channels.Command 1");

5. Через веб-интерфейс вводил данные для Command 1, например числа или

[{"Name":"Blind open", "Start":1531909200, "End":1531923600, "Enabled":false, "Type":1, "RepeatEnd":0, "StartSunType":0}, {"Name":"Air conditioner switching", "Start":1532324760, "End":1532347200, "Enabled":true, "Type":0, "RepeatEnd":0, "StartSunType":0}]

Если добавить триггер в БД, то видно, что запись происходит раз в минуту

Владимир,

проверил время двумя способами:

1. Открывал БД SQLite через некоторое время, смотрел таблицу данных на наличие новых строк в [STRING_TAG_HISTORY]

2. Создал триггер в SQLite с записью времени

CREATE TABLE `time_log` (
    `ID`    INTEGER NOT NULL UNIQUE,
    `TAG_ID`    INTEGER,
    `VALUE`    TEXT,
    `CRTIME`    TEXT,
    PRIMARY KEY(`ID`)
);

CREATE TRIGGER T_time_log AFTER INSERT ON STRING_TAG_HISTORY
BEGIN
INSERT INTO time_log(ID,TAG_ID,VALUE,CRTIME)
         VALUES(NEW.ID,NEW.TAG_ID,NEW.VALUE,datetime('now','localtime'));
END;

Время записи Store In DB [String UTF8] составляет порядка 40секунд.


Как повлиять на это значение?


При корректном завершении (Ctrl + C в консоли сервера) записи истории так же не происходит.

server (correct formatting)

function clone(obj) {
    if (null == obj || "object" != typeof obj) return obj;
    var copy = obj.constructor();
    for (var attr in obj) {//if (obj.hasOwnProperty(attr))
         copy[attr] = obj[attr];
    }
    return copy;
}


//IR.Log("ENUM " + createNewProperty);


var schedule = IR.GetScheduler("Schedule 1");
// creating a string with schedule data
var EventChanger = function() {
var EventBuff = [];

//function EventP() { }

//MonkeyPathcing
var EventProt = {
    //constructor: EventP,
    Name: undefined,     // event name
    Start: undefined,   // event start date-time
    End: undefined,  // event finish date-time
    Enabled: undefined,
    Type: undefined,
    //Parent: undefined,
    Day: undefined,
    End: undefined,
    WeekDays: undefined,
    RepeatEnd: undefined,
    MonthRepeatType: undefined,
    MonthDays: undefined,
    DayNumber: undefined,
    WeekDay: undefined,
    StartSunType: undefined,
    //TODO: Sun Offset
}
    //EventP.prototype=EventProt;
    
 /* 
var Event = function(inp) {
    this.Name;     // event name
    this.Start;   // event start date-time
    this.End;  // event finish date-time
    this.Enabled;
    this.Type;
    this.Day;
    this.End;
    this.WeekDays;
    this.RepeatEnd;
    this.MonthRepeatType;
    this.MonthDays;
    this.DayNumber;
    this.WeekDay;
    this.StartSunType;
    //TODO: Sun Offset
    for (var inpn in inp) {
    this[inpn] = inp[inpn];
        //if (inp.hasOwnProperty(inpn) && inp[inpn]!==undefined){ 
            //IR.Log("add prop " + inpn.toString() + " = " + inp[inpn]);        
            //this[inpn.toString()] = inp[inpn];
            //}
    }
} 
*/

// writing schedule data in virtual tag
  this.Write = function(in_events) {
  
 
    EventBuff = [];
    for(i in in_events) {
    //.propertyIsEnumerable("Name"));
    //IR.Log ("PROTEIN " + in_events[i].__proto__);
    
    
        in_events[i].__proto__= EventProt;
        //for(j in  in_events[i]) {
        //    IR.Log("Enumerable " + j + " == " + in_events[i][j]);
        //}
        
        var d2 = clone(in_events[i]);

        //var NEvent = new Event(in_events[i]);
      EventBuff.push(d2);
    }
    var string = JSON.Stringify(EventBuff);                     
    IR.SetVariable("Server.Tags.EventData_from_server", string);   
  }   
// reading schedule data in virtual tag 
  this.Read = function(in_schedule, in_NewData) { 
    EventEdit = in_schedule.GetEvent(in_NewData.Name);
    EventEdit.Start = Math.floor(new Date(in_NewData.Start));
    EventEdit.End = Math.floor(new Date(in_NewData.End));
    EventEdit.Enabled = (in_NewData.Enabled == 1);
    EventEdit.Done();  // event update
  }  
}

var EventsObj = new EventChanger();
// getting schedule data at server start
IR.AddListener(IR.EVENT_START,0,function() {
  var svdData = IR.GetVariable("Server.Tags.EventData_from_server");
  var schedule = IR.GetScheduler("Schedule 1");

  if (svdData)
  {
     IR.Log("SAVEVED DAta " + svdData);
     EventsObj.Read(schedule, JSON.Parse(svdData));
  }
  else {
    events = schedule.GetEvents();
    EventsObj.Write(events); 
  }  
});

// getting new data from panel
IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function(in_sName, in_sValue) {

  var newData = JSON.Parse(in_sValue);
  EventsObj.Read(schedule, newData);
  events = schedule.GetEvents();
  EventsObj.Write(events); 
});
 
// subscribing for tag changes
IR.SubscribeTagChange("Server.Channels.EventData_to_server");