Open source Freescada Database Storage Method (archiver) [MySQL for example]

Source: Internet
Author: User

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]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.