Use ODBC to access WinCC's historical database

zhaozj2021-02-16  24

Use ODBC to access WinCC's historical database

As a industrial control software, WinCC has a series of characteristics of industrial control software: display real-time data, historical data, generate real-time data curves and historical data curves, and can generate reports. However, WinCC and other industrial control software package have different places: its data is saved in a standard and powerful Sybase SQL Anywhere database, so we can directly access WinCC's historical database through ODBC like accessing a general database. .

First, access display data via Sybase Central 4.0

WinCC is installed in the system with Sybase Central 4.0 when installing, you can find Sybase Central 4.0 in Program Files / Sybase / Shared / Sybase Central 4.0, you can find ScjView.exe in its directory / java / This program function is equivalent to the Enterprise Manager of SQL Server. You can view your archive data in WinCC.

Instructions:

1) Run WinCC, then WinCC will add two data sources in ODBC:

CC_FY_02-10-16_10: 40: 18

CC_FY_02-10-16_10: 40: 18R

Where cc_fy_02-10-16_10: 40: 18R is the username and password can be read without using some of Sybase Central 4.0 and other tools. This is our WinCC's historical database.

Note: These two ODBC names are not constant, it is the structure

CC_FY_02-10-16_10: 40: 18R

CC: Inherent, indicating that it is the ODBC generated by WinCC.

FY: Project name, this is my WinCC project name

02-10-16: The date of the last revision.

10:40:18: The last revised time.

R: The representation is the run library.

2), run ScjView.exe, click Adaptive Server Anywhere 7 Press Right-click to select Connect. The Connect configuration interface will pop up.

In Identification's page, select ODBC Source Name Point Browse lists all ODBC names for the Sybase data engine, select CC_FY_02-10-16_10: 40: 18R, click "OK", "OK".

At this time, your computer name will appear in Adaptive Server Anywhere 7 and have connected your WinCC historical database.

Ok, we can now view the historical data of WinCC.

Expand: Adaptive Server Anywhere 7 (DBA)

Expand: TABLE

We can now see the table name and table structure of the database:

Table name: PDE # HQZ # GAS_PRE configuration method is as follows

PDE: Insufficient

HQZ: Archive Name

GAS_PRE: Variable name.

Table structure: There are three fields: t, v, f

T: Time

V: value

F: Sign

Since there is no reliable information, it is not known that the meaning of the name of F is unknown, but in my use, I will fly 8392705 as a legal value, there is no error in the WinCC processing, but don't The meaning of the FLAG value can only ask Siemens.

Second, use the VB writing program to access the WinCC history database.

The structure composition and table structure of WinCC's historical database has been explicitly described, then we can access WinCC's historical database. Like other data accessed by ODBC. As with the small example below in VB, first reference the ADO components. And declare the ADO variable.

Private cn as adodb.connection

Private rs as adodb.recordset

Const dsn = "cc_fy_02-10-16_10: 40: 18R"

Private subinsertdata (nowValue as double)

DIM NOWTIME AS STRING

NOWTIME = now

Cn.open DSN, "" ","

SQLSTR = "Insert INTO PDE # HQZ # GAS_PRE (T, V, F) Values ​​('" nowtime "," nowvalue ", 8392705)

Cn.execute SQLSTR

Cn.close

End Sub

The subroutine in this program only processes the data insert, and other readings are more simple, and other ADO access is exactly the same, here is not said.

Third, conclusion

Can access WinCC's historical data through ODBC, give us more solutions, especially in the enterprise information platform, can use non-real time data on the enterprise information platform, you can add the correct historical data to WinCC to make WinCC more powerful. .

This feature is not used when the ODBC name is related to the modification time of the project.

WinCC automatically adds an ODBC name when starting, automatically delete it, so after the WinCC is turned off, the ODBC cannot be accessed via ODBC.

转载请注明原文地址:https://www.9cbs.com/read-27238.html

New Post(0)