You are on page 1of 4

Report Generation in Dynamics iFIX

Using the Historical ODBC Driver to Build Summary Reports


as!"
Using the Dynamics iFIX historical ODBC driver, build a Crystal Reports query to retrieve hourly average
data over a !"hour period#
$imilar reports can be built in %icroso&t '(cel )using %icroso&t *uery, part o& the Custom Install &or O&&ice
+,-, or in .ccess +, )using the .ccess *uery /i0ard-#
Result"
1his demonstrates that the Dynamics iFIX historical data system e(poses its data via open protocols,
thereby enabling po2er&ul reporting, 2ith any standard reporting pac3age#
Steps"
4# $tart Crystal *uery Designer )included 2ith Crystal Reports version 5#6-
# $elect File 7 8e2 *uery
9# $elect the :Use Crystal *uery '(pert; option
!# In the :Create *uery e(pert;, select the :$*<7ODBC; button
=# 1o :<og on $erver;, page do2n to :ODBC > FIX Dynamics ?istorical Data
5# $elect :O@; A you should see :<og onto ODBC > FIX Dynamics ?istorical Data server succeeded
,# Under Choose $*< 1able, select the FIX Dynamics node name A clic3 :.DD; A :DO8';
B# $elect the :Fields; tab A add &ields as desired )e#g#, 1.C, D.1'1I%', D.<U', %OD'-
+# $elect :Erevie2 *uery;
8o2 the result o& the $*<7ODBC query is displayed )see Figure 4-# 'ach ro2 is one hourly historical
record, 2hich includes the tag name, date stamp, value and mode )sample, average, high or lo2 over the
speci&ied time interval-# 1he query can be saved and used as the basis &or a report 2hich &ills in the data
at generation time# Reports can be generated at run"time by using the Dynamics iFIX 1ime A 'vent
$cheduler, or on demand in the /or3space run"time environment##
1he &ollo2ing &ields )i#e#, columns- are supported by the Dynamics iFIX historical ODBC driverF
Historical Field Attribute
8OD' 8ode 8ame
1.C 1ag 8ame
FI'<D Field 8ame
D.<U' $tored ?istorical Dalue
D.1'1I%' Date71ime $tamp
%OD' $ample, .verage, ?igh or <o2
$1.1U$ Dalid 7 8ot Dalid
.<.R% .larm $tate
I81'RD.< Fi(ed Interval
a#le $% Dynamics iFIX historical ODBC driver supported process database fields.

Figure $% Example of Dynamics iFIX Hourly vera!e Historical Data "uery in Crystal #eports
&O'" Currently, the Dynamics iFIX ?istorical ODBC driver supports only the $*< $elect command#
1his means that the data retrieved by the ?istorical ODBC driver is read"only, 2hich is ideal &or reporting
purposes#
Building S() (ueries Using the Historical ODBC Driver
1he Dynamics iFIX historical ODBC driver enables vie2ing )i#e#, querying- the Dynamics iFIX historical
database as though it 2ere a relational database table# In the e(amples belo2, the name :FIX; is the
de&ault name o& the ODBC table lin3ed to the historical &iles on the node :FIX;#
?ere are a &e2 e(amples o& ho2 to build $*< queries using the Dynamics iFIX ?istorical ODBC driver#
1hese e(amples are valid in Crystal Reports# Other $*< implementations may use slightly di&&erent
synta(# For e(ample, %icroso&t .ccess requires a semicolon to terminate a $*< queryG Crystal Reports
does not# .ccess does not require double quotes delineating the column names, 2hereas Crystal
Reports does require them#
SQL Query English Translation
$'<'C1
FIX#H$1.1U$H, FIX#H.<.R%H, FIX#HI81'RD.<H,
FIX#H8OD'H, FIX#H1.CH, FIX#HFI'<DH,
FIX#HD.<U'H, FIX#HD.1'1I%'H, FIX#H%OD'H
FRO%
HFIXH FIX
Retrieve all records A &ields &rom the lin3ed
ODBC historical table :FIX;G i#e#, retrieve all
historical data A all supported &ields )the
de&ault query &or the iFIX ?istorical ODBC
driver retrieves sample data &or 4"minute
intervals over the last hours-
SQL Query English Translation
$'<'C1
FIX#H1.CH, FIX#HD.1'1I%'H, FIX#HD.<U'H,
FIX#H%OD'H
FRO%
HFIXH FIX
/?'R'
FIX#H1.CH I J1'%E'R.1UR'4; and
FIX#H%OD'H I J.D'R.C'J and
FIX#HI81'RD.<H I J64F66F66J and
FIX#HD.1'1I%'H K Lts J4++B"44", 66F66F66JM
and
FIX#HD.1'1I%'H N Lts J4++B"44"B 9F=+F=+JM
Retrieve historical hourly average data )tag
name, date stamp, value, mode- &or the tag
:1emperature4; &rom the node :FIX; &or the
duration beginning at midnight on 44","+B
A ending at midnight on 44"+"+B
a#le *% $ample Dynamics iFIX historical %ueries &from Crystal reports '.().
&O'" In the conditional )2here- clause above, the historical data mode is case"sensitive )i#e#, must be
upper case# .lso note the single quotes )required- delineating parameters#
1he time stamp notation, including braces, is based on one o& the $*< standard date &ormats#
Building +aria#le S() (ueries in +B, Using the Historical ODBC Driver
1he real po2er o& the Dynamics iFIX ?istorical ODBC driver comes &rom using variables that get &illed in
by users in the run"time environment )or is e(ecuted by the Dynamics iFIX 1ime A 'vent $cheduler-# .
single template screen )i#e#, a user inter&ace integrated into Dynamics iFIX- can be built that creates
generic historical reports, depending on the tag name, duration, interval and mode selected by the user at
run"time#
For e(ample
4
, the &ollo2ing sample $*< string 2as created in the Dynamics iFIX DB. environment ) &or
details, please re&er to the e(ample supplied 2ith the Dynamics iFIX graphics screen histreport#gr& -F
Dim str*uery.vg .s $tring
str*uery.vg I H$elect D.1'1I%', D.<U' FRO% FIX H A O
H/?'R' 1.C I JP A str1ag A QJ and %OD' I J.D'R.C'J H A O
Hand I81'RD.< I JP A strInterval A QJ and H A O
H)D.1'1I%' K Lts JH A str$tart1ime A HJM and H A O
HD.1'1I%' N Lts JH A str'nd1ime A HJM-H
: 8ote again the use o& single and double quotes#
: 1hen .DO

connection and recordset obRects are de&ined, A


: the connection is made to the Dynamics iFIX ?istorical ODBC server#
: 1hen the recordset is populated 2ith data &rom the historical queryF
Dim cn.DO .s Connection
Dim rs.DO .s Recordset
4
1his e(ample requires that the .DO #6 obRect libraries be installed A registered on the machine )see
222#microso&t#com7ado to do2nload-# .lso, a grid control such as %icroso&t Fle(Crid is required#

. proRect re&erence must be made to the .DO #6 ObRect <ibraries# 1his can be at the picture level in
FIX Dynamics#
I& cn.DO Is 8othing 1hen
$et cn.DO I 8e2 .DODB#Connection
cn.DO#Connection$tring I HD$8 I FIX Dynamics ?istorical DataG UID I saG E/D I GH
cn.DO#Open HFIX Dynamics ?istorical DataH, HsaH, HH
'nd I&
I& rs.DO Is 8othing 1hen
$et rs.DO I 8e2 .DODB#Recordset
'nd I&
rs.DO#Open str*uery.vg, cn.DO, adOpenFor2ardOnly, ad<oc3BatchOptimistic
: Eopulate a grid control &rom the recordset results
Dim r .s Integer
Dim c .s Integer
r I 4
/hile rs.DO#'OF NK 1rue
grd?ist#Ro2 I r
For c I 6 1o 4
grd?ist#Col I c
I& rs.DO)c- NK HH 1hen grd?ist#1e(t I rs.DO)c-
8e(t c
r I r S 4
rs.DO#%ove8e(t
/end

You might also like