Trend with data from MySQL

Find and share HowTos to various installations / configurations!
4 posts • Page 1 of 1
Nikolay
Posts:34
Joined: Tue Aug 21, 2012 7:10 am

Trend with data from MySQL

Post by Nikolay »

Dear colleagues, Hello again.
We have a MySQL database that stores analog values with timestamps. It is necessary to implement trends for these data sets, but the trouble is that the trends in WinCC OA are bound only to DataPoints. Please help, how should we be?

Image
Attachments
MySQL.JPG

Andorhal
Posts:127
Joined: Wed Nov 12, 2014 8:04 am

Re: Trend with data from MySQL

Post by Andorhal »

Hello Nikolay.

Depends on the level of integration you want to achieve.
You could use CONTROL-ADO to import the values (see product help for details).

You could also use BIRT inside a Webview EWO , this would allow for a (even combined) view on your internal OA data + your data in the MySQL (see product help for further details on BIRT).
You can set a refresh intervall on the BIRT page, this is no full substitute for live trending though.

Best regards,
Robert

leoknipp
Posts:2928
Joined: Tue Aug 24, 2010 7:28 pm

Re: Trend with data from MySQL

Post by leoknipp »

With the CTRL-ADO functions you read data from the database.
By using the trend attribute "curveValues" you can then show these values in a trend curve.
There is no need to write the information to DP elements to be able to show them in a WinCC OA trend.

Best Regards
Leopold Knipp
Senior Support Specialist

Nikolay
Posts:34
Joined: Tue Aug 21, 2012 7:10 am

Re: Trend with data from MySQL

Post by Nikolay »

Thank you all a lot of help! =)
That's what I got, maybe someone will be useful.

Code: Select all

int rc;
dbConnection conn;
dbCommand cmd;
string sql;
dbRecordset rs;
dyn_anytype data;
float PI, dPdT;
time DateRec;
bit64 stat = 15;
rc = dbOpenConnection ("driver = QMYSQL; server = localhost; uid = root; pwd =; database = test; port = 3306;", conn);
dbOpenRecordset (conn, "SELECT * FROM prpor", rs);
     while (! dbEOF (rs)) {
     dbGetRecord (rs, data);
     DateRec = data [2];
     PI = data [3];
     dPdT = data [4];
     TREND3.curveValue ("# 1_1", PI, DateRec, stat);
     TREND3.curveValue ("# 1_2", dPdT, DateRec, stat);
     //DebugN (DateRec + "-" + PI + "-" + dPdT);
     dbMoveNext (rs);
}
dbCloseRecordset (rs);
dbCloseConnection (conn);

4 posts • Page 1 of 1