Accessing Historian Archive Data in CIMPLICITY HMI via ADO Objects
Sometimes when logging to a Historian database, it is desirable to obtain the logged data from the database directly. How to do this via Proficy HMI/SCADA - CIMPLICITY.
Historian data in CIMPLICITY is accessed using a standard ADO Interface in conjunction with some scripting in the Basic Control Engine.
Install the OLEDB from the Historian CD on the CIMPLICITY node running the script. This will allow communication to the Historian database as it installs the driver to communicate.
Use the Event Editor to implement a script to access the historian database. The script should look similar to the following
Set conn = CreateObject("ADODB.Connection")
Dim strConn As String
' Assign the connection string to a variable. Use user id and password as necessary
strConn = "Provider=ihOLEDB.iHistorian.1;User Id=;Password="
'Assign the connection string and provider, then open the connection.
conn.ConnectionString = strConn
connProvider = "ihOLEDB.iHistorian.1"
' Create a recordset object.
Set rsPubs = CreateObject("ADODB.Recordset")
' Assign the Connection object.
rsPubs.ActiveConnection = conn
' Extract the required records.
rsPubs.Open "SELECT * FROM ihRawData"
Dim test As String
test = rspubs(2)
' Tidy up
Set rsPubs = Nothing
The SQL syntax is used to define the data to retrieve( rsPubs.Open "SELECT * FROM ihRawData" ). The specific Historian query with need to be configured to acquire the data desired. The example used here grabs every thing from ihRawData. It is possible to go to the Historian node and using the “Historian Interactive SQL” query tool to test the queries and ensure the proper data. Then use that string in the script.
Reference Historian Ebook for more information.
Start->Programs->Proficy Historian 3.1->Historian Electronic Book->Contents(Tab)-> Using the Historian OLE DB Provider-> Guidelines for Working with Clients-> Using the Historian Interactive SQL Application
Start->Programs->Proficy Historian 3.1->Historian Electronic Book->Contents(Tab)-> Using the Historian OLE DB Provider-> Supported SQL Syntax