From OpenSCADAWiki
Jump to: navigation, search

Modified data storing/restoring into the logic level sources/wrappers

Sometime you can be to need for store and next restore, mostly in restart, some modified data like a hardware working time counters. At all like data source's and hardware's processing you need perform into the logic level of the subsystem DAQ. The task you can do in more ways means storing the data and next it's restoring to some storage but most known ways are:

  • Periodical the template parameter's context saving by the OpenSCADA user API request through cntrReq():
  • If the counter template's attribute is under archiving/historying then you can the last value take from the archive/history at the template start, like that:
if(f_start)    prevArchRestore = false;
if(!prevArchRestore && (archEnd=this.cntr.arch().end("FSArch.1s"))) {
    SYS.messInfo("testArch", "val="+this.cntr.arch().getVal(archEnd)+"; "
                            "val1="+this.cntr.arch().getVal(archEnd,false,"FSArch.1s")+"; "
    cntr = this.cntr.arch().getVal(archEnd);
    prevArchRestore = true;
  • Create some specific DB table and write/read the data direct to the table by the SQL-requests through SQLReq().