Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

FactoryTalk Historian and the

PIOleDb Data Provider


Ver .02
Contents
What is the FactoryTalk Historian PIOleDb Data Provider?....................................................................... 3
Application Requirements ....................................................................................................................... 3
Available Tools ........................................................................................................................................ 3
FactoryTalk Historian PIOleDb Tester Application............................................................................. 4
FactoryTalk Historian PI OLEDB MMC............................................................................................... 6
FactoryTalk Historian PIOleDb Queries .................................................................................................... 9
Write Value to FactoryTalk Historian ................................................................................................... 9
FactoryTalk Batch Database Statements ............................................................................................ 14
System Configuration..................................................................................................................... 14
Visualization of Batch Information from FactoryTalk Historian............................................................... 18
This document describes how to consider using the FactoryTalk Historian PIOleDb Data Provider. This
will apply to the following versions of FactoryTalk Historian 2.0, 2.1 and 2.2.

What is the FactoryTalk Historian PIOleDb Data Provider?


The FactoryTalk Historian PIOleDb Data Provider allows FactoryTalk Historian to appear as an OleDb
Data source. This can be very useful when requirements demand custom data be written to FactoryTalk
Historian or when reports need access to catalogs of data inside FactoryTalk Historian that standard
connectors do not expose (Batch Database and the Module Database). This is the time to consider the
use of the FactoryTalk Historian PIOleDb Data Provider.

Application Requirements
A requirement for the FactoryTalk Historian PIOleDb Data Provider is Administrator privileges to install.
When the install is run it will deploy the PISDK and all necessary components such as MDAC. To access
the PIOleDb Data Provider programmatically you will need Visual Studio 6 or Visual Studio .Net.
Microsoft .Net Visual Studio 2008 is recommended. Here is a list of the components that are installed
by the FactoryTalk Historian PIOleDb Install. The current supported version of the FactoryTalk Historian
PIOleDb Data Provider is 3.3.0.1.

MDAC

Microsoft Installer 3.1

Microsoft Windows Script

Microsoft .NET Framework 2.0

MSXML 6.0

PISDK

Available Tools
There are several available tools to use after installation. These can be found in the following directory.
If the Data Provider was installed on a computer that has other Rockwell Software FactoryTalk
Applications then it will be located in the following directory.

C:\Program Files\Rockwell Software\FactoryTalk Historian\Server\PIPC\OLEDB

Under this folder there should be the following:


Figure 1 FTH PIOleDb Data Provider Install Location

In the Tools Folder there are several tools – PIOleDb Tester and the PIOleDb MMC. Both of these will be
shown in the following descriptions

FactoryTalk Historian PIOleDb Tester Application


This tool contains examples of SQL Queries that can be run against a FactoryTalk Historian. Each
instance requires a login to the FactoryTalk Historian. This is simplified with the use of FactoryTalk
Security as the user does not have to be a Windows user but a FactoryTalk Security User – this is outside
the intended scope of this document.

The uses the PIOleDb Tester Application navigate to the following folder location.

C:\Program Files\Rockwell Software\FactoryTalk Historian\Server\PIPC\OLEDB\Tools\PI OLEDB Tester

Start the application PIOLEDBTester.exe.


Figure 2 PI OLEDB Tester Application

When the tester opens you can get a list of sample Statements – select this button and the application is
modified to host sample SQL Statements.
Figure 3 PI OLEDB Tester with Sample SQL Queries

Here you can see that there are groups of statements that you can select and then test. Note that the
statements assume that you have some configuration loaded in the Historian so they may not all work
depending on what is in the Historian.

The statement selected will work on a default install of FactoryTalk Historian.

This tool can be valuable in the refining of a query to be used in an application.

FactoryTalk Historian PI OLEDB MMC


This tool is located at the following location:

C:\Program Files\Rockwell Software\FactoryTalk Historian\Server\PIPC\OLEDB\Tools\MMC

This is shown in the following screen shot:


Figure 4 PIOLEDB MMC Tool

Start the tool by clicking on the PIOLEDB.msc file shown in figure 4.

This will bring up the following application.


Figure 5 PIOLEDB MMC Tool

This tool shows the relationship of the catalogs inside FactoryTalk Historian. This is useful in that the
sub catalogs are Data Providers that support functionality not provided or added at a later time. For
example the picomp2 supports the writing of tags and is the preferred path to write.

If you double click on the table picomp2 there are some built in SQL Statements that you can see.
These SQL Statements are not that useful but they do show the syntax on how to access the data in the
tables. Below is a screen shot showing the SQL statement of the picomp2 table.
Figure 6 PIOLEDB MMC Showing picomp2 SQL Statement

Here you can see the SQL Statement and the results in the upper right corner.

FactoryTalk Historian PIOleDb Queries


This section will document some common queries – the ability to write a value to the Historian – and the
ability to get a list of Batches with StartTime and EndTime.

Write Value to FactoryTalk Historian


To write a value to FactoryTalk Historian the preferred query would look like the following statement.

"INSERT piarchive..picomp2(tag, time, value, status) VALUES('TAGNAME', 'TIMESTAMP', "VALUE", 0)"

An Example of this given the following:

Tag: ABC

Time: 2/24/2011 9:19:44 AM

Value: 123

Status: 0

"INSERT piarchive..picomp2(tag, time, value, status) VALUES('ABC', '2/24/2011 9:19:44 AM', 123, 0)"
First the tag ABC was created using SMT Pointbuilder- the following screen shots show the status of this
tag.

Figure 7 Current Value of tag ABC

You can see the point created value and the time the tag was created.
Figure 8 Archive Editor showing ABC Tag Events

This shows the value of the tag ABC in the Archive –


Figure 9 PIOLEDB Tester With SQL Statement to Write tag ABC

The above statement was put into the PIOLEDB Tester and run.

Since there is no returned value or record set the dialog box indicates that there was success.
Now to verify the value in the Archive – at the specified time – I intentionally chose 1 min + 1 sec from
creation.

Figure 10 Tag ABC Current Value and Timestamp after the PIOLEDB Write

Figure 10 shows the value of the tag after the SQL statement at the specified timestamp.
Figure 11 Tag ABC Archive Value and Timestamp after the PIOLEDB Write

Figure 11 shows the value at creation and the archive event of the write at the specified time.

FactoryTalk Batch Database Statements


Some discussion must be made that there must be batches in the batch database to execute SQL
statements to return information about batches. The system that these queries are run uses PIBaGen
Data Provider and a ControlLogix program to produce the batches.

Also there needs to be an understanding of the terms of Batch and UnitBatch.

A Batch is the execution of the production of a product or material – this is independent of the
equipment that the batch ran. It is the UnitBatch that is the instance of the batch that is run on a
specific piece of equipment. With this definition it is usually the UnitBatch that we are interested in.
And explains why in the SQL Statements there is always a value of Module – which is intended to be a
piece of equipment.

System Configuration
The Module Database is part of this as well – and in the test environment that this SQL Statement is run
the following is a view of the Module Database.
Figure 12 System Module Database Configuration

In the Module Database there are two Units – Machine 1 and Machine 2. The path to the Module of
Machine 1 is \Reactor Section\Machine 1. This is important as to get the list of unit batches run on
Machine 1 you need to tell the system the path to the Module that you are interested in. Once again
the Module Database is an equipment model here.

Here is the SQL Query –

SELECT batchid, starttime, endtime, product FROM pibatch..piunitbatch

WHERE moduleuid = MODULEUID('\Reactor Section\Machine 1') AND starttime >= 't'

ORDER BY starttime

Note the path to the module of interest – this could have been Machine 2

Also note the Function MODULEUID(‘\Reactor Section\Machine 1’). This function gets the UID of the
module specified – the query runs off of the GUID given to the Module in the Module Database the
function allows for us to use the path to the module.

When this query is run in the PIOLEDB Tester here is the result.
Figure 13 Batch Query Record Set

Note the StartTime and the EndTime is provided as well as the product that was run. Each of these
UnitBatches have sub batches.

Another SQL Statement of interest may be to specify a particular batchid since midnight of any child
module of the Reactor Section –

Here is a Query that will do this:

SELECT h.name, u.batchid, u.starttime, u.endtime, u.product FROM pibatch..piunitbatch u

INNER JOIN pimodule..pimoduleh h ON u.moduleuid = h.uid


WHERE u.starttime >= 't' AND h.path LIKE '\Reactor Section\%' AND u.batchid = 'M1Part7865'

ORDER BY u.starttime, h.name

We want to know the information about batchid M1Part7865

After running this query in the PIOLEDB Tester here is the results – note the batch is in the list in figure
13.

Figure 14 Request Specific Batch ID on any Module under Reactor Section

This will return all the batches that have BatchID of M1Part7865 – in this system the batches are
incremented from 1 to 9999 so it is possible to have multiples of this batchid –

There is an overall time period of the search in this case it is ‘t’ which is the PITime of since midnight
today. This could use other times such as ‘*-1000d’ which is now (*) minus 1000 days – if this query was
run there would probably be multiple batches with the same id.
Visualization of Batch Information from FactoryTalk Historian
The question always comes up as to how to visualize the information from FactoryTalk Historian – there
are two answers – Of course one is preferred.

1. FactoryTalk VantagePoint
2. BatchView

It is possible to view BatchView reports or graphs in FactoryTalk VantagePoint – this is with the use of a
client side tool named ActiveView. ActiveView is a runtime render of ProcessBook displays that can be
imbedded in a web page.

More information is provided in the ActiveView.pdf.

Here is the text that is used to embed the ActiveView object in an html page.

Figure 15 ActiveView HTML Text

You might also like