1. Let's start with a new Freescada engineering example to see the actual storage effect:
A) set up several data channels as a data source (Communication menu Editor, Channels tree display):
b) Create a Database Archive (Toolbar archiver Settings):
c) Define the database connection properties (Databases Settings submenu under the Project menu):
d) Compile the project and run to view the database storage results:
2. Stored Procedure Inquiry ( archiver project underFreeSCADA2 solution):
We mainly analyze several methods in the Archiver.cs file under the Archiver project:
Start method:
Public BOOLStart () {DbWriter=NewDbWriter (); if(Dbwriter.open () = =false) return false; Channelupdaterthread=NewThread (NewParameterizedthreadstart (channelupdaterthreadproc)); Channelupdaterthread.start ( This); Dbreader=NewDbreader (); if(Dbreader.open () = =false) return false; returnisrunning;}
Channelupdaterthreadproc Method:
Private Static void Channelupdaterthreadproc(Objectobj) {Archivermain Self=(archivermain) obj; Try { for (; ; ) { //System.Console.WriteLine ("{0} Channelupdaterthreadproc:start Loop", System.DateTime.Now); foreach(Rule ruleinchself.channelSettings.Rules) {if(rule. Enable) {foreach(Basecondition condinchrule. Conditions) cond. Process (); if(rule. Archive) self.dbWriter.WriteChannels (rule. Channels); }} thread.sleep ( -); } } Catch(ThreadAbortException) {}if(Self.dbwriter! =NULL) Self.dbWriter.Close ();}
Stop method:
Public void Stop () { ifnull) { channelupdaterthread.abort (); Channelupdaterthread.join (); NULL ; if NULL ) dbwriter.close (); } if NULL ) dbreader.close ();}
Open source Freescada Database Storage Method (archiver) [MySQL for example]