Querying WinCC Historical Archives via WinCC OLE-DB Provider and OpenPCS 7

Querying WinCC Historical Archives via WinCC OLE-DB Provider and OpenPCS 7

To query historical process values and alarm archives from external applications (such as MES, ERP, or custom .NET scripts) in SIMATIC PCS 7, utilize the WinCC OLE-DB Provider provided by the OpenPCS 7 software package. Configure an OLE-DB connection string using provider 'WinCCOLEDBProvider.1' pointing to the WinCC runtime database catalog, and execute specialized SQL commands ('TAG:R,...' for Tag Logging or 'ALARMVIEW:SELECT...' for Alarm Logging). OpenPCS 7 acts as the licensed gateway exposing historical and real-time process data without requiring direct access to the underlying SQL tables.

Table of Contents

Executive Summary

Enterprise Manufacturing Execution Systems (MES), laboratory information systems (LIMS), and corporate data warehouses regularly require read access to historical process trends and alarm logs stored inside SIMATIC PCS 7 OS Servers. Attempting to query WinCC SQL tables directly using standard Microsoft SQL drivers violates system security, encounters encrypted binary compressed tables, and can crash the active OS database. This article details the architecture of OpenPCS 7, the syntax and mechanics of the WinCC OLE-DB Provider, connection string formatting, and sample SQL query structures.

Architecture and Fundamental Mechanics

OpenPCS 7 and WinCC OLE-DB Provider Architecture:

  • Role of OpenPCS 7:
  • OpenPCS 7 is the official, certified communication interface providing OPC UA, OPC DA, OPC A&E, OPC HDA, and OLE-DB interfaces for external IT systems.
  • It abstracts complex WinCC internal database structures, dynamically decompressing raw binary archive segments into standard relational tables.
  • The WinCC OLE-DB Provider (WinCCOLEDBProvider.1):
  • A COM-based database provider enabling ADO / OLE-DB clients to query historical data using SQL-like syntax.
  • Specialized Query Syntax:
  • Process Value Archive Query (TAG:R):
    TAG:R,('ArchiveName\TagName'),'YYYY-MM-DD hh:mm:ss','YYYY-MM-DD hh:mm:ss'
  • Alarm Logging Query (ALARMVIEW:SELECT):
    ALARMVIEW:SELECT * FROM AlgViewEnu WHERE DateTime >= '...'
  • Licensing Requirements:
  • OpenPCS 7 requires a dedicated 'OpenPCS 7' runtime software license installed via Automation License Manager (ALM) on the hosting station.

Step-by-Step Implementation Procedure

Procedure to Configure and Query Historical Archives via OLE-DB:

  1. Install and License OpenPCS 7:
    - Install the OpenPCS 7 software package on a dedicated PC Station or OS Client.
    - Transfer the valid 'SIMATIC PCS 7 OpenPCS 7' runtime license to the PC using ALM.
  2. Format the OLE-DB Connection String:
    - Target connection string template:
    Provider=WinCCOLEDBProvider.1;Catalog=<DatabaseCatalogName>;Data Source=.\WinCC
    - Note: <DatabaseCatalogName> corresponds to the WinCC runtime database name (found in WinCC Explorer project properties, e.g., CC_OS_Proj_21_02_15_...R).
  3. Formulate the Process Tag Archive Query (SQL):
    - Example query retrieving 1-minute interpolated samples:
    sql TAG:R,('TagLoggingFast\TI101/PV_Out#Value'), '2021-02-15 08:00:00.000','2021-02-15 16:00:00.000', 'TIMESTEP=60,1'
  4. Formulate the Alarm Logging Query (SQL):
    - Example query retrieving all raised alarms:
    sql ALARMVIEW:SELECT MsgNo, DateTime, MsgText FROM AlgViewEnu WHERE DateTime >= '2021-02-15 00:00:00' AND MsgState = 1
  5. Execute Query via ADO / PowerShell Script:
    - Test connection using a simple PowerShell script or UDL (Universal Data Link) file.
    - Verify that recordsets return valid timestamps, values, and quality codes (16#80).

Verification

To verify OLE-DB provider connectivity:
1. Create a text file named test.udl on the OpenPCS 7 client machine; double-click to open Data Link Properties.
2. Under the 'Provider' tab, select 'WinCC OLE DB Provider for WinCC and PCS 7'.
3. Under 'Connection', specify the data source and catalog; click 'Test Connection'; confirm 'Test connection succeeded'.
4. Execute a sample TAG:R query; verify records return chronological floating-point data.

Limitations and Operational Precautions

Operational precautions:
- Never query production OS Servers with massive open-ended queries (e.g., retrieving years of uncompressed data) during active plant operations; distribute queries through a dedicated OpenPCS 7 station or Process Historian.
- All queries use UTC time; client applications must convert timestamps to local plant time.
- Direct SQL access bypassing WinCC OLE-DB Provider (e.g., querying SQL tables directly) is unsupported and voids system warranties.

Engineer FAQ

What is the WinCC OLE-DB Provider?

A specialized database provider that enables external applications to query WinCC historical tags and alarms safely using SQL syntax.

What software package provides the WinCC OLE-DB Provider?

OpenPCS 7 (or WinCC Connectivity Pack in standalone WinCC installations).

Does querying via OLE-DB return compressed data in readable format?

Yes, the OLE-DB provider automatically decompresses binary compressed Tag Logging archives into readable values.

What syntax is used to query process tag archives?

The TAG:R syntax followed by the archive name, tag name, and start/end timestamps.

Does OpenPCS 7 require an extra license?

Yes, OpenPCS 7 requires a dedicated runtime software license in Automation License Manager.

Technical References

Related Articles

Related Tags

  • OpenPCS 7
  • WinCC OLE-DB
  • Historical Archives
  • TAG:R Query
  • MES Integration
20 respuestas