WONDERWARE 2013 Historian Concepts PDF
WONDERWARE 2013 Historian Concepts PDF
WONDERWARE 2013 Historian Concepts PDF
Historian Concepts
Guide
9/27/13
All rights reserved. No part of this documentation shall be reproduced, stored in a retrieval system, or
transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without the
prior written permission of Invensys Systems, Inc. No copyright or patent liability is assumed with respect
to the use of the information contained herein. Although every precaution has been taken in the
preparation of this documentation, the publisher and the author assume no responsibility for errors or
omissions. Neither is any liability assumed for damages resulting from the use of the information
contained herein.
The information in this documentation is subject to change without notice and does not represent a
commitment on the part of Invensys Systems, Inc. The software described in this documentation is
furnished under a license or nondisclosure agreement. This software may be used or copied only in
accordance with the terms of these agreements.
All terms mentioned in this documentation that are known to be trademarks or service marks have been
appropriately capitalized. Invensys Systems, Inc. cannot attest to the accuracy of this information. Use of
a term in this documentation should not be regarded as affecting the validity of any trademark or service
mark.
Alarm Logger, ActiveFactory, ArchestrA, Avantis, DBDump, DBLoad, DT Analyst, Factelligence,
FactoryFocus, FactoryOffice, FactorySuite, FactorySuite A2, InBatch, InControl, IndustrialRAD,
IndustrialSQL Server, InTouch, MaintenanceSuite, MuniSuite, QI Analyst, SCADAlarm, SCADASuite,
SuiteLink, SuiteVoyager, WindowMaker, WindowViewer, Wonderware, Wonderware Factelligence, and
Wonderware Logger are trademarks of Invensys plc, its subsidiaries and affiliates. All other brands may
be trademarks of their respective owners.
3
Contents
Welcome .................................................. 11
Wonderware Historian Documentation Set .................................. 11
Documentation Conventions ......................................................... 12
Technical Support .......................................................................... 13
Index..................................................... 365
Welcome
Documentation Conventions
This documentation uses the following conventions:
Technical Support
Wonderware Technical Support offers a variety of support options to
answer any questions on Wonderware products and their
implementation.
Before you contact Technical Support, refer to the relevant section(s)
in this documentation for a possible solution to the problem. If you
need to contact technical support for help, have the following
information ready:
• The type and version of the operating system you are using.
• Details of how to recreate the problem.
• The exact wording of the error messages you saw.
• Any relevant output listing from the Log Viewer or any other
diagnostic applications.
• Details of what you did to try to solve the problem(s) and your
results.
• If known, the Wonderware Technical Support case number
assigned to your problem, if this is an ongoing problem.
Chapter 1
Introduction
Process Data
Process data is any relevant information to successfully run a process.
The following information is considered to be process data:
• Real-time data - What is the current value of this tag?
• Historical data - What was the value of this tag every second last
Monday?
• Summary data - What is the average of each of these five tags?
• Event data - When did that boiler trip?
• Configuration data - How many I/O Servers am I using and what
are their types?
To improve performance and quality while reducing cost, process data
must be available for analysis. Process data is typically analyzed to
determine:
• Process analysis, diagnostics, and optimization.
• Predictive and preventive equipment maintenance.
• Product and process quality (SPC/SQC).
• Health and safety; environmental impact (EPA/FDA).
• Production reporting.
• Failure analysis.
Chapter 2
About Tags
The Wonderware Historian stores and retrieves values, where every
value gets stored with some timestamp and associated quality. This
triplet of value, timestamp, and quality is called VTQ and constitutes
the smallest addressable piece of data in the Wonderware Historian
data model. Sometimes a VTQ can be referred to as a value or data
point, but even in that case it is assumed that it means the whole
triplet.
A tag is an entity that identifies a set of VTQs received from the same
data source. Usually it represents a single attribute of some physical
process or device. In Wonderware Historian, a tag is identified by a
unique tag name.
Types of Tags
The following table describes the types of tags in the system.
Data quality is the degree of validity for a data value. Data quality can
range from good, in which case the value is exactly what was originally
acquired from the plant floor, to invalid, in which the value is either
wrong or cannot be verified. Essentially it is a piece of metadata
present in every VTQ and provides information about how much you
can rely on the value and the timestamp of that VTQ.
Wonderware Historian VTQ's quality element consists of two 16-bit
unsigned integers called OPCQuality and QualityDetail.
OPCQuality is the actual quality information provided by the data
source, such as an I/O Server or DAServer. This is the primary
indicator of the value's quality. Wonderware Historian keeps that
quality information intact in its exact original state since the moment
it was received.
QualityDetail is an additional proprietary piece of information created
by the Wonderware Historian and attached to every VTQ it processes.
QualityDetail is used to record information about what happened with
that VTQ while it was processed by various historian subsystems. For
example, it can indicate that some VTQ was stored as the first value
after the connection to the historian server was restored after a
temporary disconnect, or it can tell that the retrieved value is not the
actual value generated by an I/O Server or DAServer, but a manually
corrected one.
When executing a SQL query, there is a special indicator returned
through the Quality column at retrieval time that provides a summary
for the related data item. The value of that indicator is derived from
the available OPCQuality and QualityDetail. For a listing of these
values, see "Client-Side Quality Values" on page 66.
For additional information regarding data quality, see "Data Quality"
on page 61.
Tag Properties
Every Wonderware Historian tag is associated with one or more tag
metadata instances. A tag metadata instance is a set of properties
identified by a unique TagId. The TagId is a 16-byte globally unique
identifier (GUID). Tag metadata properties include tag name,
description, tag type, storage type, creation time, and so on.
Tag metadata properties describe what the tag is, where the data for
that tag is coming from, how the VTQs of that tag should be stored,
and how they should be retrieved and displayed by client applications.
The following table describes the most important tag metadata
properties:
Property Description
Note: The ability to set up an alternate file storage location for tag
metadata is possible to ensure it is available should the primary
location become corrupt or not accessible.
For the full list of tag metadata properties, see the tag-related tables
in Chapter 2, "Tables."
Security
The Wonderware Historian uses two security mechanisms:
• Windows operating system security
• Microsoft SQL Server security
For clients to access the historian, they must pass through both of
these security levels. The historian Management Console (within the
System Management Console) in particular adds an additional level of
security checking to restrict access to functions affecting the state of
the historian to only authorized users. Also, some of the historian
components require Windows and SQL Server logins.
For more information on configuring user rights assignments for local
security policies, see the Microsoft documentation.
For information on how to manage security, see Chapter 8, "Managing
Security," in the Wonderware Historian Administration Guide.
Authentication
Microsoft SQL Server authenticates users with individual login
account and password combinations. After the user’s identity is
authenticated, if authentication is successful, the user is allowed to
connect to a SQL Server instance. There are two types of
authentication:
• Windows authentication, in which users must connect to the SQL
Server using a Windows user account (a Windows login ID and
password that is provided during the Windows login session).
• SQL Server authentication, in which users must connect to the
SQL Server using SQL Server login account (a SQL Server login
ID and password).
SQL Server can operate in one of two security modes, which control
the type of accounts that must be used for access to the server:
• Windows authentication mode. In this mode, the SQL Server only
uses Windows authentication.
• Mixed mode. In this mode, the SQL Server uses both Windows
authentication and SQL Server authentication. If the login name
matches the Windows network username, then validation is
handled by the Windows security mechanisms. If the user login
name does not match the Windows network username, then
Microsoft SQL Server security mechanisms are used.
SQL Server authentication is provided for backward compatibility
only. Microsoft recommends that you use Windows authentication,
when possible.
Login
Name Password Description
aaAdmin pwAdmin A user who can access and modify all data
and create objects. Cannot drop the
database or truncate tables.
aaPower pwPower A user with full read access and the
ability to create objects and modify the
contents of the non-core tables.
aaUser pwUser A read-only user who can access all data,
but cannot modify data or consume
database resources.
aadbo pwddbo Database owner. Full permissions.
The default database for each of these logins is the historian Runtime
database. This default security model is provided as a starting point
for system security and is suitable for many types of installations.
These logins are valid if the Microsoft SQL Server is set to mixed mode
security. If only Windows authentication is used, you must configure
the access rights for each user.
Database Authorization
After a user successfully connects to the Microsoft SQL Server, the
user needs authority to access databases on the server. This is
accomplished by user accounts for each database. A database user
consists of a user name and a login ID. Each database user must be
mapped to an existing login ID.
User names are stored in the sysusers table in each database. When a
user tries to access a database, the Microsoft SQL Server looks for an
entry in the sysusers table and then tries to find a match in the
syslogins table in the master database. If the Microsoft SQL Server
cannot resolve the username, database access is denied.
The types of actions the user can perform in the database are based on
authority information defined in the user account. The authority to
perform a certain action is called a permission. There are two types of
permissions: object permissions and statement permissions.
Permission Description
Users can be grouped into roles, which is a single unit against which
you can apply permissions. Permissions granted to, denied to, or
revoked from a role also apply to any members of the role.
Username
in
Login ID Database Member of Role Permissions
The following users and roles are provided for backward compatibility
only. They will be deprecated in a future release. Do not use these
users and roles.
Username
in
Login ID Database Member of Role Permissions
Each default role contains the corresponding SQL Server user account,
as well as the corresponding default Windows security group. For more
information on the default Windows security groups, see "Default
Windows Security Groups" on page 29.
Time Handling
Timestamps for all data are stored in Coordinated Universal Time
(UTC). The current UTC time is derived from the current local time
and the time zone setting in the operating system of the computer on
which the Wonderware Historian is running. During data retrieval,
timestamps are returned in local time, by default. You can convert the
timestamps so that they are shown in local time by using a special
query parameter.
You should use the international date/time format for all timestamps
used in queries. The format is:
YYYYMMDD HH:MM:SS.000
where,
YYYY = year
MM = month
DD = day
HH = hour
MM = minutes
SS = seconds
000 = milliseconds
The format for timestamps returned from queries is controlled by the
default language settings of the SQL Server login. Make sure that you
configure the default language setting for SQL Server logins correctly,
especially in environments with mixed languages/regional settings.
If you have multiple historians and/or are using remote data sources,
it is very important that you synchronize the time between the
computers. For more information, see "Time Synchronization for Data
Acquisition" on page 91.
Make sure that you have selected the operating system setting to
automatically adjust time for daylight savings, if the time zone in
which the computer is located observes daylight savings time.
System Parameters
A system parameter is a parameter that controls some aspect of the
overall Wonderware Historian behavior. The following table describes
the default system parameters:
Name Description
Name Description
Name Description
Name Description
Name Description
System Messages
System messages include error messages and informational messages
about the state of the Wonderware Historian as a whole or for any of
the internal subsystems and individual processes. System messages
are logged to the:
• ArchestrA Logger.
• Windows event log, which can be viewed with the Windows Event
Viewer. Not all messages are logged to the Windows event log. In
general, only user actions and exceptional events are written to
this log. The messages are logged with the "Historian" or the name
of the Wonderware Historian service as the source.
System messages are divided into the following categories:
Category Description
TagName Description
Date Tags
The following analog tags have a storage rate of 5 minutes (300000
ms).
TagName Description
Time Tags
All of the following tags are analog tags. Each value change is stored
(delta storage).
TagName Description
TagName Description
TagName Description
SysDataAcqNBadValues* Number of data values with bad quality received. This tag
has a storage rate of 5 seconds. The maximum is 1,000,000.
SysDataAcqNOutsideRealtime* The number of values per second that were discarded
because they arrived outside of the real-time data window.
This tag has a storage rate of 5 seconds. The maximum is
1,000,000.
SysDataAcqOverallItemsPerSec The number of items received from all data sources. This
tag has a storage rate of 10 seconds. The maximum is
100,000.
SysDataAcqRxItemPerSecN* Tag value update received per second. This tag has a
storage rate of 10,000 milliseconds. Updated every 2
seconds for this IDAS.
SysDataAcqRxTotalItemsN* Total number of tag updates received since last startup for
this IDAS. This tag has a storage rate of 10,000
milliseconds.
TagName Description
*This status tag will exist for each defined IDAS. The identifying
number (N) in the is the IODriverKey from the IODriver table. The
number 0 designates MDAS and only applies to the
SysDataAcqNBadValues and SysDataAcqNOutsideRealtime tags.
Tag Description
Tag Description
*This status tag will exist for each defined IDAS. The identifying
number (N) appended to the end of the tag is the IODriverKey from
the IODriver table.
Tag Description
Tag Description
TagName Description
SysEventCritActionQSize Size of the critical action queue. For more information, see
"Action Thread Pooling" on page 360.
SysEventDelayedActionQSize Number of entries in the delayed action queue.
SysEventNormActionQSize Size of the normal action queue.
SysEventSystem A discrete tag that indicates the status of the event system
service (aahEventSvc.exe). 0 = Bad; 1 = Good.
SysStatusEvent Snapshot event tag whose value changes every hour.
TagName Description
TagName Description
TagName Description
TagName Description
Note: The six performance tags will exist for each defined IDAS. The
identifying number (N) appended to the end of the "DataAcq" portion of
the tagname is the IODriverKey from the IODriver table. For
example, 'SysPerfDataAcq1CPU'.
Suffix Description
Important: You need to ensure that the memory that SQL Server
reserves for the Wonderware Historian is adequate for the expected
load. Based on your particular environment, you may need to adjust
the SQL Server MemToLeave allocation. For more information on
MemToLeave, see the Microsoft documentation.
Supported Protocols
Wonderware Historian supports the following protocols:
Protocol Description
Modification Tracking
Wonderware Historian tracks modifications (inserts, updates, and
deletions) to columns in the Runtime database. If your plant tracks
changes for compliance with regulatory agencies, you can configure
the historian to use modification tracking.
Modification tracking is system-wide; it is controlled by the
ModLogTrackingStatus system parameter. You cannot turn
modification tracking on or off at a table level. Enabling modification
tracking decreases the historian's performance when making changes
to the system. This is due to the extra work and space required to
track the changes. However, there is no performance degradation
during run-time operation.
Information in the modification tracking tables are stored in the data
files of the Microsoft SQL Server database. If modification tracking is
turned on, the amount of data that is stored in these files is greatly
increased.
All of the objects for which modifications can be tracked are stored in
the HistorianSysObjects table.
You can track two types of modifications:
• Changes to configuration data. For example, additions or changes
to tag, I/O Server, and storage location definitions. For more
information, see "Modification Tracking for Configuration
Changes" on page 54.
• Changes to history data. For example, data inserts and updates by
Transact-SQL statements or CSV imports. For more information,
see "Modification Tracking for Historical Data Changes" on
page 55.
The types of changes that will be tracked is controlled by the
ModLogTrackingStatus system parameter. You can track inserts,
updates, and deletes, as well as various combinations. For more
information, see "Turning Modification Tracking On/Off" in Chapter 9,
"Viewing or Changing System-Wide Properties," in the Wonderware
Historian Administration Guide.
The OldValue column contains the value stored in the column before
the modification was made, if the modification was to a configuration
table. For modifications to history data using SQL INSERT and
UPDATE statements, this column contains the timestamp of the
earliest data affected by the INSERT or UPDATE operation. If
multiple changes are made to the same data, then only the most recent
change will be contained in this column. This column is not used for
modifications made to history data using a CSV file.
For example, if you insert 20 data values into history for the
ReactTemp analog tag using a CSV import, the following changes
would be reflected in the modification tracking tables:
• One row would be added to the ModLogTable table, to track the
change to the History_OLEDB table. The UserName column will
contain the name of the user as contained in the CSV file header.
• One row would be added to the ModLogColumn table to record that
the value change occurred. A value of 20 will be stored in the
NewValue column to indicate that 20 values were inserted.
Data Categories
There are various ways to store data in Wonderware Historian and
there are many operations that can be performed on that data along
the way. To provide a consistent framework for data operations in the
Wonderware Historian data model, internally the data is divided into
several categories and organized into the following hierarchy.
Make sure that the Historian Server computer has its timestamp
configured properly and is synchronized with other computers serving
data as data inserted with timestamp in the future will be
timestamped again to the Historian time at the time of processing.
There are three sub-types of original streamed data: real-time data,
late data, and replication data.
Real-Time Data
Real-time data is expected to be in time order, where the timestamp is
in the past relative to the current Wonderware Historian server time.
Sources of real-time data values are:
• I/O Servers and DAServers sending data with current timestamps
• System tags
• Transact-SQL INSERT statements where wwVersion =
REALTIME
• Wonderware Application Server
If the tag is stored using classic storage, then the streamed data must
fall within the real-time window boundaries to be considered real-time
data. For more information on the real-time window, see "About the
Real-Time Data Window for Classic Storage" on page 127.
All real-time data contains store-and-forward indicators in the
QualityDetail.
If a value has timestamp that is beyond 1 second in the future, relative
to the Historian Server time, it is later overwritten by another data
value, and the QualityDetail value will reflect the overwrite.
For more information on storage, see Chapter 5, "Data Storage
Subsystem."
Late Data
Late data is expected to be in time order, where the timestamp is far in
the past compared to the current Wonderware Historian server time.
Typical sources of late data values are:
• I/O Servers (RTUs) that send data far in the past compared to the
historian server time
• Wonderware Application Server that has been configured to send
late data to the historian
Late data contains store-and-forward indicators in the QualityDetail
value, but does not have the channel status enabled, so no NULL
values are injected if a disconnect occurs between the HCAL-enabled
client and the historian.
If the late data values are not in time order, then the value with the
later timestamp is overwritten with a manufactured value, and the
QualityDetail value reflects the overwrite.
Replication Data
Replication data is data that has been replicated from a tier-1
historian to a tier-2 historian. Replication data does not contain
store-and-forward indicators if a disconnect and a subsequent
store-and-forward occurs between the tier-1 and tier-2 historians.
Data Quality
There are three aspects of quality handling for the system:
• Data quality assignment by data acquisition devices (OPCQuality)
• Storage subsystem quality for the Wonderware Historian
(QualityDetail)
• Client-side quality definitions (Quality
For more information on quality for tags, see "VTQ for Tags" on
page 23
The historian uses three distinct parameters to indicate the quality of
every historized data value: Quality, QualityDetail, and OPCQuality.
OPCQuality is strongly related to QualityDetail. Quality is a derived
measure of the validity of the data value, while QualityDetail and
OPCQuality indicate either a good quality for the data value, or the
specific cause for degraded quality of the data value.
The historian persists four bytes of quality information for every data
value that is historized. (This does not imply that four bytes of quality
data are actually stored for every data value, but it guarantees that
every data value can be associated with 4 bytes of quality information
when the value is retrieved.) The 4 bytes of quality information
comprises 2 bytes for QualityDetail and 2 bytes for OPCQuality.
QualityDetail and OPCQuality are related, but may have different
values.
In essence, OPCQuality is provided as for client applications that are
fully aware of the OPC data quality standard, while QualityDetail
(and Quality) are maintained to ensure proper operation of existing
and legacy client applications. OPCQuality is sent by the data source,
and QualityDetail is added by the Wonderware Historian.
If you import history blocks from IndustrialSQL Server 7.1 or earlier
(that do not use OPC data quality), the OPCQuality is determined by
using the top 2 bits of the lower 8 bits of the QualityDetail.
Created
QualityDetail Quality String Description By
Created
QualityDetail Quality String Description By
Created
QualityDetail Quality String Description By
QualityDetail Flags
The following bit flags are stored in the high order byte of the quality
detail. Each bit is a flag that carries specific meaning.
0x0000 - Basic QualityDetail.
The following hi-byte flags are or'ed with the basic QualityDetail. The
three flags cannot coexist; only one is set at any point in time.
0x0100 - Value received in the future.
0x0200 - Value received out of sequence.
0x0400 - Configured for server time stamping.
The following hi-byte flag can coexist with any of the prior four
combinations.
0x0800 - Point generated by Rate Deadband filter.
The following hi-byte flag can coexist with any of the prior eight
combinations.
0x1000 - Partial cycle, advance retrieval results.
The following hi-byte flag can coexist with any of the prior eight
combinations.
0x2000 - Value has been modified by filter.
This bit is set during retrieval to indicate that retrieval has modified a
value or time stamp due to applying a filter such as SnapTo() or
ToDiscrete().
Initial Value and Doubtful are derived from QualityDetail. The Initial
Value is dependent on the type of query that is executed. For more
information, see "Using Comparison Operators with Delta Retrieval"
on page 296, "Using Comparison Operators with Cyclic Retrieval and
Cycle Count" on page 301, and "Using Comparison Operators with
Cyclic Retrieval and Resolution" on page 305.
QualityDetail contains detailed information that is potentially specific
to the device which supplied it. Quality values may be derived from
various sources, such as from I/O Servers or from the Wonderware
Historian storage system.
To retrieve a listing of the quality values that are used by the
historian, see "Viewing Quality Values and Details" on page 62.
Chapter 3
Configuration Subsystem
Component Description
Dynamic Configuration
The Wonderware Historian supports dynamic configuration; that is,
you can modify the configuration of tags and other objects in the
historian database while the system is running. The historian
automatically detects and applies the modifications to its internal
run-time state without requiring the system to be restarted. In
addition, clients do not experience interruptions due to configuration
changes.
The dynamic configuration feature in the historian caters for all
possible database modifications that affect the run-time operation of
the system. For some types of configuration modifications, the system
automatically creates a new history block. The configuration
subsystem is designed to ensure that no loss of data occurs for tags
that are not affected by the modifications being applied. However, tags
that require a change in data acquisition configuration will obviously
lose data during the reconfiguration.
Chapter 4
Component Description
Component Description
To acquire data from an I/O Server, you must add the I/O Server
addressing information to the historian database and then associate
the I/O Server with an IDAS.
For information on configuring I/O Servers and IDASs, see Chapter 4,
"Configuring Data Acquisition," in the Wonderware Historian
Administration Guide.
Address
Information I/O Server InTouch Microsoft Excel
For the Wonderware Historian to acquire data from an I/O Server, the
I/O Server addressing information must be added to the overall system
configuration. You can use the System Management Console to
manually add I/O Server definitions to the system, or you can import
I/O Server definitions from existing InTouch applications.
For more information about manually adding I/O Server definitions,
see Chapter 4, "Configuring Data Acquisition," in the Wonderware
Historian Administration Guide.
For more information on importing I/O Server definitions from
InTouch HMI software, see Chapter 3, "Importing and Exporting
Configuration Information," in the Wonderware Historian
Administration Guide.
About IDASs
A Wonderware Historian Data Acquisition Service (IDAS) is a small
software application that accepts data from one or more I/O Servers or
DAServers. An IDAS runs as a Windows service named SysDataAcq.
The IDAS processes the acquired data, if necessary, and then sends
the data to the Wonderware Historian, where it is subsequently
stored.
When you add an I/O Server definition to the historian, a topic object is
created in the associated IDAS. A separate topic object exists for each
unique combination of I/O Server computer, application, and topic.
Each topic object maintains its own state: idle, connecting, connected,
disconnecting, disconnected, overloaded, or receiving. Also, each topic
object is assigned a data time-out value based on your assessment of
how often data changes for that particular topic.
An IDAS can accept data from one or more I/O Servers, but only sends
data to a single historian.
An IDAS can run on the same physical computer as the historian, or
on a remote computer. However, only one instance of an IDAS can run
on any single computer. Both the IDAS and the historian use NetBIOS
network names for communication. Computers must be accessible by
those names. Use the Ping command to check the availability of the
remote IDAS or historian computers.
IDAS seamlessly handles data values, irrespective of their time. For
each data point acquired by IDAS, the timestamp, value, and quality
are historized in accordance with the storage rules for the tag to which
the data value belongs.
For information on configuring an IDAS, see Chapter 4, "Configuring
Data Acquisition," in the Wonderware Historian Administration
Guide.
IDAS Configuration
During normal operation, when the historian is started, it configures
an IDAS by sending it information about the tags (including their data
sources) for which the IDAS is to acquire data. When the historian
storage subsystem is ready to accept data, IDAS automatically
connects to its data sources, starts acquiring data, and sends the data
to the historian storage subsystem for historization.
The primary purpose for IDAS configuration files is to minimize
network traffic and provide information for IDASs configured for
autonomous startup. For more information on autonomous startup,
see "IDAS Autonomous Startup" on page 86.
An IDAS does not apply any storage rules (for example, delta or cyclic
storage) unless it is disconnected from the historian and is operating
in store-and-forward mode. If the IDAS is operating in
store-and-forward mode, all storage rules are applied before the data is
stored locally in the store-and-forward history blocks.
If the remote IDAS cannot communicate with the historian, all data
currently being processed can be stored (cached) locally on the
computer running IDAS. This hard drive location is called the
store-and-forward path and is configurable using the System
Management Console.
If the IDAS is unable to send the data to the historian, data is written
to this path until the minimum threshold for the cache is reached, at
which point no more data is stored. An error message is logged.
Remote store-and-forward paths are not supported.
The following actions occur after the historian becomes available
again:
• The historian verifies that the IDAS configuration information did
not change while the IDAS was disconnected. The historian
attempts to restore data transmission from the IDAS. The IDAS
stops local data caching and resumes sending data acquired from
its data sources to the historian.
IDAS Redundancy
For each IDAS that you define for the system, you can specify a
"failover" IDAS. If the Wonderware Historian stops receiving data
from the primary IDAS, it automatically switches to the failover IDAS.
The switch may take some short period of time, and some data may be
lost during the transition.
Note: You cannot specify a failover IDAS for an IDAS that has
store-and-forward functionality enabled. These two features are
mutually exclusive. Applications that require both failover and
store-and-forward functionality should use a redundant Application
Server with RedundantDIObjects.
The late date option must be enabled for the topic in order for late data
to be processed. If the late data option is not enabled, any data values
from that topic later than 30 seconds behind the Wonderware
Historian are discarded. Any discarded data is reflected in the
SysPerfDataAcqNOutsideRealtime system tag for the IDAS.
For more information on enabling late data, see "Editing Advanced
Information for an IDAS" in Chapter 4, "Configuring Data
Acquisition," in the Wonderware Historian Administration Guide.
Note: Time synchronization does not apply to I/O Servers that use
DDE because these servers do not perform timestamping. The time of
the IDAS computer is always used for data coming from DDE from I/O
Servers.
I/O Server 3
IDAS 1 IDAS 2
I/O Server 2
I/O Server 1
• Minimum free disk space. When the free disk space on the disk
configured for store-and-forward reaches the minimum free disk
space configured, the storage subsystem engine switches to
read-only mode to prevent total disk consumption and periodically
logs error messages in the ArchestrA Logger.
• Bandwidth usage. If an HCAL client will be operating in a shared
network environment, you can limit the bandwidth usage for
HCAL communications to minimize the impact on other
applications. This bandwidth limit applies to all types of data sent
from HCAL. If the limit is set below what is required for the
current load, HCAL goes into store-and-forward mode.
HCAL Security
A connection from an HCAL client is authenticated before replication,
storage, or retrieval tasks can be performed on the historian. HCAP
uses the security credentials supplied by the HCAL client.
To store data, the user must belong to one the following Windows
groups on the historian server computer:
• aaAdministrators
• aaPowerUsers
To retrieve data, the user must belong to one of the following Windows
groups on the historian server computer:
• aaAdministrators
• aaPowerUsers
• aaReplicationUsers
• aaUsers
To replicate data, the user must belong to the following Windows
group on the historian server computer:
• aaReplicationUsers
By default, the ArchestrA user specified during installation is included
in the aaAdministrators and aaReplicationUsers groups. If more than
one computer is included in the setup and each has different
ArchestrA users, you will need to manually add the remote account
that HCAL is using to the appropriate group on the Historian node.
Integrated Windows authentication is currently not supported.
Chapter 5
Storage Modes
When you define a tag, you need to specify a storage method, which
specifies how the tag’s data is saved as historical records. For example,
the system may be receiving 100 values per millisecond for an I/O
Server tag, but you might not want to store all of these values. How
you configure the storage method affects the number of values written
to disk and the resolution of the data that will be available later for
retrieval.
The following types of storage modes are available:
• No data values are stored.
• All data values are stored (forced storage).
• Only changed data values are stored (delta storage).
• Only data values that occur at a specified time interval are stored
(cyclic storage).
"Forced" Storage
Forced storage is the storage of each value as it comes in from the
plant floor or from a client application, without filtering applied (that
is, no delta or cyclic storage mode is used).
Forced storage is useful, for example, if you have an I/O Server that
collects data by exception from the plant floor device (instead of using
a polling interval). You can allow the I/O Server to filter the values by
exception, instead of the Wonderware Historian.
If the I/O Server uses a polling interval, then storage with no filtering
is similar to cyclic storage. However, the cyclic storage rate determines
the values that are stored, and that rate can only go down to a one
second resolution. If you use storage with no filtering, the I/O Server
controls which values are stored, and these can be at a finer resolution
than one second. For forced storage, if the data source is sending the
same values at each internal scan cycle, then each value is stored.
Delta Storage
The Delta storage mode stores data based on a change in a value.
Delta storage writes a historical record only if the current value
changes from the previous value. Delta storage is also called "storage
by exception." Delta storage is typically used to store discrete values,
string values, and analog values that remain constant for long periods
of time. For example, you don’t want to store the value of the discrete
tag "PUMPON" every ten seconds if the pump usually stays on for
months at a time. The value is stored along with a timestamp of when
the change occurred, to an accuracy of 1 ms.
The following types of deadbands can be applied for delta storage:
• Time deadband
• Value deadband
• Rate of change (swinging door) deadband
&
2
5
LPDJLQDU\
GDWD
VZLQJLQJ
SRLQW
GRRU
9DOXH
5
2
&
7LPH
10 11
9 12
13
14
8
15
7
16
6
18 19
4 17
1 2 3 5
The following graph shows the trend of the data values with a value
deadband applied. Notice how only the first data value that deviates
by the deadband from the previous value will be stored, and not any of
the values between the starting value and the first deviating value.
9 10 11 12
13
14
8
15
7
16
6
18 19
4 5 17
2 3
1
Value Deadband
The following graph shows the data values that will be stored for both
a value deadband and a swinging door deadband. Notice how the
swinging door deadband captures data before the deadband change,
allowing for a more complete view of the data.
.
9 10 11
12 13
14
8
15
7
16
6
18
4 19
2 3 5 17
1
Value Deadband
Swinging Door
A swinging door deadband is most useful for tags that have a steady
increase and decrease in slope, such as a tank level or tank
temperature that rises and falls. A swinging door deadband may not
be appropriate for "noisy" signals, in which the value of the tag
constantly fluctuates around a certain point for long periods of time.
Also, the reduction in storage requirements offered by the swinging
door deadband may not have much of an impact if you have an
application with a small tag count (for example, 500 tags). In this case,
it may not be necessary to use a deadband at all.
A swinging door deadband is applicable for analog tags that receive
data from the following sources:
• Real-time data values from I/O Servers, MDAS, or HCAL
• Store-and-forward data from a remote IDAS
• Late data from an I/O Server topic that was configured for late
data
• A "fast load" .CSV import
• Real-time inserts of data using a Transact-SQL statement
A swinging door deadband is not applicable for manual inserts of data
through a .CSV import of a Transact-SQL statement.
To best visualize the tag that uses swinging door storage, plot a trend
using the Historian Client Trend application and set the plot type from
to "line" (rather than "step-line").
All of the examples are based on the following raw data. The
numbered points represent actual values received from a data source.
10 18
9
17
0
8 16
7 15
6
14
1 2 3 4 5 11 12 13 20
19
9
17
0
8 16
7 Real time 15
window +30.0
seconds
6
14
1 2 3 4 5
11 12 13 19 20
Assume point 0 has been stored on disk. The system waits for point 2
to arrive before making its next storage decision. When point 2 is
received, the storage engine calculates the change in slope as follows:
Slope0_1 is considered the base slope, and Slope1_2 is considered
the current slope.
Slope0_1 = (Value1 - Value0) / (Time1 - Time0)
Slope1_2 = (Value2 - Value1) / (Time2 - Time1)
Slope_Change_Percent = 100* | (Slope1_2 - Slope0_1) / Slope0_1 |
If
Slope_Change_Percent > Rate_Deadband_Specified
15
14
1
16
13
3 5 7 9 11
Value
deadband
2 4 6 8 10 12 17
Assume that point 1 has been stored to disk. Point 3 passes the value
deadband check, allowing points 2 and 3 to be evaluated for rate
change. Assuming that the point exceeds the rate change requirement,
then point 2 is stored. Until point 13 is received, all intermediate
points are discarded by the value deadband filter. In this example, it is
assumed that the change in slope between points 2 through 3 and
points 12 through 13 is greater than the rate deadband, so point 12 is
stored on disk. When point 14 is received, the normal operation begins.
If a rate deadband is applied without a value deadband, all of the
"noisy" points (3 through 11) would have been stored, because the
slope of the signal changes radically between successive points. The
value deadband removes the noise, but also introduces some amount of
distortion in the resultant signal.
15
14
1
16
Deadband
override
period
13
3 5 7 9 11
Value
deadband
2 4 6 8 10 12 17
Cyclic Storage
Cyclic storage is the storing of analog data based on a time interval.
Cyclic storage writes a record to history at the specified interval, only
if a data changes during the time interval. For example, you could
store the value of an analog tag every five seconds.
The time interval for cyclic storage is called the storage rate. Each
analog tag has its own storage rate. The storage rate you should select
depends on the minimum timestamp resolution with which you want
to be able to retrieve the data sometime in the future. Storing data
using a very low time interval will result in a very high resolution of
data being stored over a small time span. Storing data using a very
high time interval, however, may result in significant data values
being missed. An exception to this will be values received or generated
due to a connect or disconnect event.
Available storage rates for analog tags are:
• 1, 2, 3, 5, 6, 10, 15, 30 seconds
• 1, 2, 3, 5, 6, 10, 15, 20, 30 minutes
• 1 hour
The timestamp for the first data value received during the cyclic time
span will be used. For example, you might have specified a 10 second
storage rate for a particular analog tag. The last data value received
during the 10 second lapse will be stored, along with the corresponding
timestamp.
The storage subsystem physically stores cyclically stored values in the
same manner as it does value stored by delta. That is, it keeps track of
repeated values in time in a logical manner and will "fill in" the
missing values upon retrieval. For example:
Data Conversions
The Wonderware Historian can store values up to 32-bits. If the data
source sends a 64-bit real number to Wonderware Historian, the
number is converted to a 32-bit real number and, consequently, loses
precision to six or seven decimal places. (The range depends on the
number of binary digits, which does not exactly map to a fixed number
of decimal places.) As a result, values that differ in the data source
system beyond the seventh digit will not register as a change for delta
storage and will not be re-stored. For example, a value of 1.0449991
followed by a 1.0450001 would both round to 1.045000, and the second
point would not be stored.
The maximum length of a string value that can be stored is 513
characters. Any characters over this limit are truncated. This limit
does not apply to variable-length strings.
History Blocks
The Wonderware Historian stores data in files of a proprietary file
format in units called history blocks. A history block is essentially a
sub-folder of the main historian data storage folder, defined during
installation or by subsequent dynamic configuration changes. A
history block is self-contained, containing all the information
necessary to retrieve data for the period represented by the history
block. You specify the duration of history blocks. The default duration
of a history block is one day, and the minimum allowed duration is one
hour. The historian automatically creates a new history block at
system startup, at scheduled block changeover times, at your request,
or in response to certain dynamic configuration actions.
Note: Configuration data and event history are not stored in the
history blocks; they are stored in the Runtime database file.
As data is acquired from the plant, the size of these history blocks
grows on a continual basis, being limited only by the size of the hard
disk on which the historian resides.
By storing plant data in the history blocks instead of in normal SQL
Server tables, the historian can store data in a fraction of the space
that would be required by a normal relational database. Compact
storage formats reduce the storage space requirements than would be
required in a standard relational database. Upon retreival, historical
data is presented by the Wonderware Historian OLE DB provider as if
it were stored in SQL Server tables.
$B
V\VWHPXVH EORFNQXPEHU
Note: The system supports 999 history blocks per day. If this limit is
reached, the system begins overwriting data in the first block for the
day. A warning message will be issued in the Wonderware Historian
Console when the limit is about to be reached. To reduce the number of
history blocks created per day, increase your standard history block
size (if it is less than 24 hours).
Note: The sizes in this example are purposely small; the disk drives
for storage locations should be much larger.
When tags are upgraded from classic storage, all tag data stored prior
to the upgrade remains in the classic storage subsystem, and any new
data values after the upgrade are stored in the storage subsystem.
The AIHistory column of the Tag table indicates whether data exists
for a tag in both storage and classic storage:
• AIHistory = 0 means that there is no data was previously collected
by classic storage
• AIHistory = 1 means that the tag may have data previously
collected by classic storage
If you query data for some tag where the query time interval goes
across the time of the tag upgrade, the retrieval subsystem fetches the
data from both storage and classic storage subsystems and presents it
in a seamless manner.
Consider the following steps of an upgrade for a system that uses both
the Wonderware Historian and Wonderware Application Server:
1 The Wonderware Historian version 10.0 is collecting data from
Wonderware Application Server 2012 or earlier
2 The Wonderware Historian is stopped and upgraded to version
2012 R2. The Application Server engines continue collecting data
in store-and-forward mode.
3 The Wonderware Historian is started. The Application Server
engines reconnect to the historian and continue storing data.
At this point, Application Server is storing data in the classic
storage subsystem. Both the AITag and AIHistory column values
will be 1 for all Application Server tags stored in the historian.
Chapter 6
Applies to Applies to
Storage Classic Storage
You must balance the need for a larger real-time window with the
amount of memory available on your computer. If your system has a
large tag count or high data throughput, increasing the real-time
window increases the memory requirements for storage because the
storage system must process more data as real-time data, which is
more resource-intensive than the storage of late or old data.
Adjusting the real-time window also has implications if you are using
delta storage with a swinging door deadband. For more information,
see ""Swinging Door" Deadband for Delta Storage" on page 104.
If the system does not have enough memory to adequately process
real-time data, the window is adjusted internally. An appropriate
message is logged. The value of the RealTimeWindow system
parameter, however, remains unchanged.
If you find a large number of forced storage points, you can either
reconfigure the tag to use delta storage or increase the real-time
window.
Note: The first two points received for a tag configured for swinging
door storage are always stored.
Note: The rate at which values are acquired by the active image is
NOT related to the value that is stored in the AcquisitionRate column of
the Tag table.
When the sample limit for the active image is reached, the oldest tag
values will start to be overwritten with new tag values. Overwriting
the older tag values makes room for new tag values, with a default
number of 65 values for each tag being held in the active image at any
given time. Also, all of the values stored in the active image may not be
stored to disk: it depends on the storage rate (from the StorageRate
column in the Tag table). If the samples in the active image are
acquired at a rate that is faster than the storage rate, tag values will
be acquired into the active image at a higher resolution than they will
be stored.
To prevent data values in the active image from being overwritten, the
number of samples held would need to be increased to cover the time
gap required for the storage subsystem to store the actual values to
disk.
Important: Although you can manually set the active image samples
for a variable length string to a value other than 0, NULL, or 65, this is
not recommended. The performance impact will be extremely high,
because each sample for a variable length string is 1038 bytes
allocated in memory.
Chapter 7
Retrieval Service
The retrieval service (aahRetSvc.exe) retrieves history data from both
the active image and history blocks on disk. The retrieval service:
• Formats data so that it can be passed up through the system to the
Wonderware Historian OLE DB provider or other MDAS-enabled
or HCAL-enabled client applications.
• Returns information regarding the history blocks, such as the start
and end dates and the location.
Linear scaling for analog tags is performed within retrieval using the
following formula.
V_out = (V_in - MinRaw)*(MaxEU - MinEU)/(MaxRaw - MinRaw)
+ MinEU
where:
V_out = scaled output value
V_in = stored raw value
MinRaw = minimum raw value for the tag
MaxRaw = maximum raw value for the tag
MinEU = minimum engineering unit value
MaxEU = maximum engineering unit value
Data access from the history blocks is made possible by SQL Server's
OLE DB provider technology. Client applications must connect
directly to the Microsoft SQL Server and then specify to use the
Wonderware Historian OLE DB provider in the syntax of the query.
The extension tables are:
• AnalogSummaryHistory
(INSQL.Runtime.dbo.AnalogSummaryHistory)
• History (INSQL.Runtime.dbo.History)
• HistoryBlock (INSQL.Runtime.dbo.HistoryBlock)
• Live (INSQL.Runtime.dbo.Live)
• StateSummaryHistory
(INSQL.Runtime.dbo.StateSummaryHistory)
• StateWideHistory (INSQL.Runtime.dbo.StateWideHistory)
The AnalogHistory, DiscreteHistory, StringHistory, AnalogLive,
DiscreteLive, StringLive, AnalogWideHistory, DiscreteWideHistory,
StringWideHistory, and v_SummaryData tables are provided for
backward compatibility. For more information, see Chapter 6,
"Backward Compatibility Entities," in the Historian Database
Reference.
The AnalogHistory, DiscreteHistory, StringHistory, and History tables
are the only tables which are updateable. The remaining tables are
read-only.
For more information on the history extension tables, see "History
Tables" in Chapter 1, "Table Categories," in the Historian Database
Reference.
For example:
SELECT * FROM History
WHERE TagName = 'SysTimeSec'
AND DateTime >= '2001-09-12 12:59:00'
AND DateTime <= '2001-09-12 13:00:00'
where "XYZ" is the statement to pass. You should be sure that the
value of "XYZ" is not more than 8000 characters. This limit is most
likely to cause a problem if you are querying many tags from a wide
table.
Also, you should supply the datetime in an OPENQUERY statement
in the following format:
yyyy-mm-dd hh:mm:ss.fff
For example:
2001-01-01 09:00:00.000
You cannot use variables in an OPENQUERY statement. For more
information, see "Using Variables with the Wide Table" on page 320.
Four-Part
Syntax Element Query OPENQUERY
IN Clause Limitations
If you are querying analog, discrete, or string tags from the
AnalogTag, DiscreteTag, or StringTag tables (respectively), you cannot
use the LIKE clause within an IN clause to condition the tagname
unless you are returning the vValue column. This restriction applies if
you are using the four-part naming convention or an extension table
view.
For example:
SELECT DateTime, TagName, vValue, Quality, QualityDetail
FROM History
WHERE TagName IN (SELECT TagName FROM StringTag WHERE
TagName LIKE 'SysString')
AND DateTime >='2001-06-21 16:00:00.000'
AND DateTime <='2001-06-21 16:40:00.000'
AND wwRetrievalMode = 'Delta'
OR Clause Limitations
You cannot use the OR clause to specify more than one condition for a
time domain extension. For more information, see "Wonderware
Historian Time Domain Extensions" on page 154.
The following example includes a string tag and converts the vValue
value to a char or varchar datatype. All values returned can be
converted to a string.
SELECT * FROM OpenQuery(INSQL, 'SELECT DateTime, Quality,
OPCQuality, QualityDetail, Value, vValue, TagName
FROM History
WHERE TagName IN ("SysString", "SysTimeMin", "SysPulse")
AND DateTime >= "2001-12-30 04:00:00.000"
AND DateTime <= "2001-12-30 09:00:00.000"
AND wwRetrievalMode = "Cyclic"
AND wwCycleCount = 300
')
WHERE convert(varchar(30), vValue) = '2001-12-30 14:00:00'
INSERT @TagList
SELECT 'SysTimeSec' UNION
SELECT 'SysPerfCPUTotal'
GO
To correct this issue, rewrite the query so that the tagname criteria is
passed to the Historian OLE DB provider correctly.
SELECT GETDATE()
INSERT @TagList
SELECT 'SysTimeSec' UNION
SELECT 'SysPerfCPUTotal'
GO
For example, if you want to execute a query that performs this type of
join, use the normal alias in specifying the first table (the analog
history table), and use the second alias in specifying the second table
(the discrete history table, hence the "D" added to the alias name).
For example, you could specify a value for the wwResolution column in
the query so that a resolution is applied to the returned data set:
SELECT DateTime, Value
FROM History
WHERE TagName = 'SysTimeSec'
AND DateTime >= '2001-12-02 10:00:00'
AND DateTime <= '2001-12-02 10:02:00'
AND Value >= 50
AND wwResolution = 10
AND wwRetrievalMode = 'cyclic'
Note: You cannot use the IN clause or OR clause to specify more than
one condition for a time domain extension. For example, "wwVersion
IN ('original', 'latest')" and "wwRetrievalMode = 'Delta'
OR wwVersion = 'latest'" are not supported.
Chapter 8
You can use a variety of retrieval modes and options to suit different
reporting needs and applications.
• Integral Retrieval
• Slope Retrieval
• Counter Retrieval
• ValueState Retrieval
A Wonderware Historian with a version of 10.0 or higher supports the
following additional mode:
• RoundTrip Retrieval
Cyclic Retrieval
Cyclic retrieval is the retrieval of stored data for the given time period
based on a specified cyclic retrieval resolution, regardless of whether
or not the value of the tag(s) has changed. It works with all types of
tags. Cyclic retrieval produces a virtual rowset, which may or may not
correspond to the actual data rows stored on the Wonderware
Historian.
In cyclic retrieval, one row is returned for each “cycle boundary.” You
specify the number of cycles either directly or by means of a time
resolution, that is, the spacing of cycle boundaries in time. If you
specify a number of cycles, the Wonderware Historian returns that
number of rows, evenly spaced in time over the requested period. The
cyclic resolution is calculated by dividing the requested time period by
the number of cycle boundaries. If you specify a resolution, the number
of cycles is calculated by dividing the time period by the resolution.
If no data value is actually stored at a cycle boundary, the last value
before the boundary is returned.
The default retrieval mode is cyclic for retrieval from analog tables,
including analog and state summary tables.
Cyclic retrieval is fast and therefore consumes little server resources.
However, it may not correctly reflect the stored data because
important process values (gaps, spikes, etc.) might fall between cycle
boundaries. For an alternative, see ""Best Fit" Retrieval" on page 177.
Data is retrieved in cyclic mode with a start time of TC0 and an end
time of TC2. The resolution has been set in such a way that the
historian returns data for three cycle boundaries at TC0, TC1, and TC2.
Each dot in the graphic represents an actual data point stored on the
historian. From these points, the following are returned:
• At TC0: P2, because it falls right on the cycle boundary
• At TC1: P7, because it is the last point before the cycle boundary
• At TC2: P11, for the same reason
Query 1
The following query returns data values for the analog tag
'ReactLevel'. If you do not specify a wwCycleCount or wwResolution,
the query will return 100 rows (the default).
SELECT DateTime, Sec = DATEPART(ss, DateTime), TagName, Value
FROM History
WHERE TagName = 'ReactLevel'
AND DateTime >= '2001-03-13 1:15:00pm'
AND DateTime <= '2001-03-13 2:15:00pm'
AND wwRetrievalMode = 'Cyclic'
Delta Retrieval
Delta retrieval, or retrieval based on exception, is the retrieval of only
the changed values for a tag(s) for the given time interval. That is,
duplicate values are not returned. It works with all types of tags.
Delta retrieval always produces a rowset comprised of only rows that
are actually stored on the historian; that is, a delta query returns all of
the physical rows in history for the specified tags, over the specified
period, minus any duplicate values. If there is no actual data point at
the start time, the last data point before the start time is returned.
Delta retrieval is the default mode for discrete and string tables and
from the History table.
Data is retrieved in delta mode with a start time of T1 and an end time
of T2. Each dot in the graphic represents an actual data point stored on
the historian. From these points, the following are returned:
• P2, because there is no actual data point at T1
• P5, P8, P9, P10, and P11, because they represent changed values
during the time period
For delta retrieval for replicated summary tags on a tier-2 historian, if
a point with doubtful quality is returned as the result of a value
selection from an input summary point with a contained gap, the same
point can be returned again with good quality if the same value is
selected again from the next input summary point that has good
quality.
Query 1
As an example of how delta mode works, consider the following query:
SELECT TagName, DateTime, Value, QualityDetail
FROM History
WHERE TagName = 'A001'
AND DateTime >= '2009-09-12 00:20'
AND DateTime <= '2009-09-12 00:40'
AND wwRetrievalMode = 'Delta'
The sample data points and the results are mapped on the following
chart. Only the data falling between the time start and end marks at
2009-09-12 00:20 and 2009-09-12 00:40 (shown on the chart as dark
vertical lines) are returned by the query.
Because there is no value that matches the start time, an initial value
at 2009-09-12 00:20 is returned in the results based on the value of the
preceding data point at 2009-09-12 00:16. Because there is no change
in the value at 2009-09-12 00:27 from the value at 2009-09-12 00:24,
the data point appears on the chart but does not appear in the results.
Similarly, the second 0.0 value at 2009-09-12 00:29 is also excluded
from the results.
You can further control the number of rows returned by using the
wwTimeDeadband, wwValueDeadband, and wwCycleCount
extensions. The use of a cycle count returns the first number of rows
within the time range of the query. For more information, see "Using
wwResolution, wwCycleCount, and wwRetrievalMode in the Same
Query" on page 287.
Also, the use of a time deadband and/or value deadband with delta
retrieval produces differing results. For more information, see "Time
Deadband (wwTimeDeadband)" on page 232 and "Value Deadband
(wwValueDeadband)" on page 236.
Query 1
SELECT DateTime, TagName, Value
FROM History
WHERE TagName IN ('SysTimeSec','SysTimeMin')
AND DateTime >= '2001-12-09 11:35'
AND DateTime <= '2001-12-09 11:36'
AND wwRetrievalMode = 'Delta'
Query 2
SELECT * FROM OpenQuery(INSQL,'SELECT DateTime, Value, Quality,
QualityDetail
FROM AnalogHistory
WHERE TagName = "SysTimeSec"
AND wwRetrievalMode = "Delta"
AND Value = 10
AND DateTime >="2001-07-27 03:00:00.000"
AND DateTime <="2001-07-27 03:05:00.000"
')
Query 3
For a delta query, if both a wwCycleCount and a Value comparison are
specified, the query will return the first number of rows (if available)
that meet the value indicated.
SELECT * FROM OpenQuery(INSQL,'SELECT DateTime, Value, Quality,
QualityDetail
FROM AnalogHistory
WHERE TagName = "SysTimeSec"
AND wwRetrievalMode = "Delta"
AND Value = 20
AND wwCycleCount = 10
AND DateTime >="2001-07-27 03:00:00.000"
AND DateTime <="2001-07-27 03:20:00.000"
')
The sample data points and the results are mapped on the following
chart. Only the data falling between the time start and end marks at
00:20 and 00:40 (shown on the chart as dark vertical lines) are
returned by the query.
Because there is no value that matches the start time, an initial value
at 00:20 is returned in the results based on the value of the preceding
data point at 00:16. Because there is no change in the value at 00:27
from the value at 00:24, the data point appears on the chart but does
not appear in the results. Similarly, the two 0.0 values at 00:33 and
00:35 are also excluded from the results. However, the non-NULL
value at 00:36 is returned, even though it is the same as the value at
00:28, because it represents a delta from the preceding (NULL) value
at 00:35.
Full Retrieval
In full retrieval mode, all stored data points are returned, regardless of
whether a value or quality has changed since the last value. This mode
allows the same value and quality pair (or NULL value) to be returned
consecutively with their actual timestamps. It works with all types of
tags.
By using full retrieval in conjunction with storage without filtering
(that is, no delta or cyclic storage mode is applied at the historian), you
can retrieve all values that originated from the plant floor data source
or from another application.
Full retrieval best represents the process measurements recorded by
the Wonderware Historian. However, it creates a higher load for the
server, the network and the client system because a very large number
of records may be returned for longer time periods.
For full retrieval for replicated summary tags on a tier-2 historian, if a
point with doubtful quality is returned as the result of a value
selection from an input summary point with a contained gap, the same
point can be returned again with good quality if the same value is
selected again from the next input summary point that has good
quality.
Data is retrieved in full mode with a start time of T1 and an end time
of T2. Each dot in the graphic represents an actual data point stored on
the historian. From these points, the following are returned:
• P2, because there is no actual data point at T1
• P3 through P12, because they represent stored data points during
the time period
Query 1
SELECT DateTime, TagName, Value
FROM History
WHERE TagName IN ('SysTimeSec','SysTimeMin')
AND DateTime >= '2001-12-09 11:35'
AND DateTime <= '2001-12-09 11:36'
AND wwRetrievalMode = 'Full'
Interpolated Retrieval
Interpolated retrieval works like cyclic retrieval, except that
interpolated values are returned if there is no actual data point stored
at the cycle boundary.
This retrieval mode is useful if you want to retrieve cyclic data for
slow-changing tags. For a trend, interpolated retrieval results in a
smoother curve instead of a "stair-stepped" curve. This mode is also
useful if you have a slow-changing tag and a fast-changing tag and
want to retrieve data for both. Finally, some advanced applications
require more evenly spaced values than would be returned if
interpolation was not applied.
By default, interpolated retrieval uses the interpolation setting
specified for the tag in the Wonderware Historian. This means that if a
tag is set to use stair-step interpolation, interpolated retrieval gives
the same results as cyclic retrieval.
Interpolation is only applied to analog tags. If you retrieve data for
other types of tags, stair-step interpolation is used, and the results are
the same as for cyclic retrieval.
Interpolated retrieval is a bit slower than cyclic retrieval. It shares the
limitations of cyclic retrieval in that it may not accurately represent
the stored process data.
Query 1
Two analog tags and a discrete tag are retrieved from the History
table, using linear interpolation. The start and end times are offset to
show interpolation of the SysTimeMin tag. The data points at all cycle
boundaries are interpolated for the two analog tags, while the values
returned for the discrete tag are stair-stepped.
SELECT DateTime, TagName, Value, wwInterpolationType FROM
History
WHERE TagName IN ('SysTimeMin', 'ReactTemp', 'SysPulse')
AND DateTime >= '2005-04-11 12:02:30'
AND DateTime <= '2005-04-11 12:06:30'
AND wwRetrievalMode = 'Interpolated'
AND wwInterpolationType = 'Linear'
AND wwResolution = 60000
Query 2
If you omit the interpolation type in the query, the historian
determines which interpolation type to use for an analog tag based on
the value of the InterpolationType column in the AnalogTag table, in
conjunction with the InterpolationTypeInteger and
InterpolationTypeReal system parameters.
In the following query both analog tags are set to use the system
default through the AnalogTag table, while the
InterpolationTypeInteger and InterpolationTypeReal system
parameters are set to 0 and 1, respectively. Because SysTimeMin is
defined as a 2-byte integer and ReactTemp is defined as a real we see
that only rows for ReactTemp are interpolated.
SELECT DateTime, TagName, Value, wwInterpolationType FROM
History
WHERE TagName IN ('SysTimeMin', 'ReactTemp', 'SysPulse')
AND DateTime >= '2005-04-11 12:02:30'
AND DateTime <= '2005-04-11 12:06:30'
AND wwRetrievalMode = 'Interpolated'
AND wwResolution = 60000
Query 3
SELECT TagName, DateTime, Value, QualityDetail,
wwInterpolationType
FROM History
WHERE TagName = 'A001'
AND DateTime >= '2009-09-12 00:20'
AND DateTime <= '2009-09-12 00:40'
AND wwRetrievalMode = 'Interpolated'
AND wwResolution = '10000'
The sample data points and the results are mapped on the following
chart. Only the data falling between the time start and end marks at
00:20 and 00:40 (shown on the chart as dark vertical lines) are
returned by the query.
Because there is no value that matches the start time, an initial value
at 00:20 is returned in the results based on the preceding data point at
00:17 because the following data point at 00:22 is NULL. Because a
NULL value precedes the 00:30 cycle boundary at 00:29, the NULL is
returned at the cycle boundary. The value at 00:40 is an interpolation
of the data points at 00:38 and 00:42.
For example, for one week of five-second data, 120,960 values would be
returned for delta retrieval, versus around 300 values for best-fit
retrieval.
Best-fit retrieval uses retrieval cycles, but it is not a true cyclic mode.
Apart from the initial value, it only returns actual delta points. For
example, if one point is both the first value and the minimum value in
a cycle, it is returned only one time. In a cycle where a tag has no
points, nothing is returned.
Data is retrieved in best-fit mode with a start time of TC0 and an end
time of TC2. The resolution has been set in such a way that the
historian returns data for two complete cycles starting at TC0 and TC1
and an incomplete cycle starting at TC2. P1 to P12 represent actual data
points stored on the historian. Of these points, eleven represent
normal analog values, and one, P7, represents a NULL value due to an
I/O Server disconnect, which causes a gap in the data between P7 and
P8.
Because P2 is located exactly at the start time, no initial value needs to
be interpolated at the start time. Therefore, point P1 is not considered
at all. All other points are considered, but only the points indicated by
green markers on the graph are returned.
Query 1
An analog tag is retrieved over a five-minute period using the best-fit
retrieval mode. The wwResolution parameter is set to 60000, thus
specifying five 1-minute cycles. Within each cycle, the retrieval
sub-system returns the first, minimum, maximum, and last data
points. There are no exception (NULL) points in the time period.
Notice how the points at the query start time and at the query end
time are interpolated, while all other points are actual delta points.
SELECT DateTime, TagName, CONVERT(DECIMAL(10, 1), Value) AS
Value, wwInterpolationType AS IT FROM History
WHERE TagName = 'ReactTemp'
AND DateTime >= '2005-04-11 12:15:00'
AND DateTime <= '2005-04-11 12:20:00'
AND wwRetrievalMode = 'BestFit'
AND wwResolution = 60000
Average Retrieval
For the time-weighted average (in short: “average”) retrieval mode, a
time-weighted average algorithm is used to calculate the value to be
returned for each retrieval cycle.
For a statistical average, the actual data values are used to calculate
the average. The average is the sum of the data values divided by the
number of data values. For the following data values, the statistical
average is computed as:
(P1 + P2 + P3 + P4) / 4) = Average
Data is retrieved in average mode with a start time of TC0 and an end
time of TC2. The resolution has been set in such a way that the
historian returns data for two complete cycles starting at TC0 and TC1
and an incomplete cycle starting at TC2. P1 to P9 represent actual data
points stored on the historian. Of these points, eight represent normal
analog values, and one, P5, represents a NULL due to an I/O Server
disconnect, which causes a gap in the data between P5 and P6. Assume
that the query calls for timestamping at the end of the cycle.
Query 1
The time-weighted average is computed for each of five 1-minute long
cycles.
Note that the wwTimeStampRule parameter is set to "Start" in the
query. This means that the value stamped at 11:18:00.000 represents
the average for the interval 11:18 to 11:19, the value stamped at
11:19:00.000 represents the average for the interval 11:19 to 11:20,
and so on. If no timestamp rule is specified in the query, then the
default setting in the TimeStampRule system parameter is used.
In the first cycle there are no points, so a NULL is returned. In the
second cycle value points are found covering 77.72 percent of the time
as returned in PercentGood. This means that the returned average is
calculated based on 77.72 percent of the cycle time. Because the same
OPCQuality is not found for all the points in the cycle, OPCQuality is
set to Doubtful. In the remaining three cycles, only good points occur,
all with an OPCQuality of 192.
Query 2
This query demonstrates the use of the average retrieval mode in a
wide query. Time-weighted average values are returned for the analog
tags ReactTemp and ReactLevel, while regular cyclic points are
returned for the discrete tag, WaterValve.
SELECT * FROM OpenQuery(INSQL,
'SELECT DateTime, ReactTemp, ReactLevel, WaterValve FROM
WideHistory
WHERE DateTime >= "2004-06-07 08:00"
AND DateTime < "2004-06-07 08:05"
AND wwRetrievalMode = "Average"
AND wwCycleCount = 5
')
Minimum Retrieval
The minimum value retrieval mode returns the minimum value from
the actual data values within a retrieval cycle. If there are no actual
data points stored on the historian for a given cycle, nothing is
returned. NULL is returned if the cycle contains one or more NULL
values.
As in cyclic retrieval, the number of cycles is based on the specified
resolution or cycle count. However, minimum retrieval is not a true
cyclic mode. Apart from the initial value, all points returned are delta
points.
Minimum retrieval only works with analog tags. For all other tags,
normal delta results are returned.
This example has a start time of TC0 and an end time of TC2. The
resolution has been set in such a way that the historian returns data
for two complete cycles starting at TC0 and TC1, a “phantom” cycle
starting at TCP, and an incomplete cycle starting at TC2. The phantom
cycle has the same duration as the first cycle in the query period,
extending back in time from the query start time.
For the queried tag, a total of 18 points are found throughout the
cycles, represented by the markers P1 through P18. Of these points, 17
represent normal analog values. The point P13 represents a NULL due
to an I/O Server disconnect, which causes a gap in the data between
P13 and P14.
or
wwRetrievalMode = 'Minimum'
Query 1
In this example, an analog tag is retrieved over a five minute period,
using the minimum retrieval mode. Because the wwResolution
parameter is set to 60000, each cycle is exactly one minute long. The
minimum data value is returned from each of these cycles.
SELECT DateTime, TagName, CONVERT(DECIMAL(10, 2), Value) AS
Value FROM History
WHERE TagName = 'ReactTemp'
AND DateTime >= '2005-04-11 11:21:00'
AND DateTime <= '2005-04-11 11:26:00'
AND wwRetrievalMode = 'Minimum'
AND wwResolution = 60000
The initial value at the query start time is the minimum value found
in the phantom cycle before the start time of the query.
The results are:
DateTime TagName Value
(phantom cycle) 2005-04-11 11:21:00.000 ReactTemp 104.00
(cycle 1) 2005-04-11 11:21:30.837 ReactTemp 14.00
(cycle 2) 2005-04-11 11:22:00.897 ReactTemp 36.00
(cycle 3) 2005-04-11 11:23:59.567 ReactTemp 18.60
(cycle 4) 2005-04-11 11:24:02.083 ReactTemp 14.00
(cycle 5) 2005-04-11 11:25:59.550 ReactTemp 108.60
Query 2
In this example, the minimum retrieval mode is used in a manner
equivalent to using the SQL Server MIN aggregate. Note that the
cycle producing the result is the five-minute phantom cycle just before
the query start time.
SELECT TOP 1 DateTime, TagName, CONVERT(DECIMAL(10, 2), Value)
AS Value FROM History
WHERE TagName = 'ReactTemp'
AND DateTime >= '2005-04-11 11:31:00'
AND DateTime <= '2005-04-11 11:31:00'
AND wwRetrievalMode = 'Minimum'
AND wwResolution = 300000
Query 3
This example shows how the minimum retrieval mode marks the
QualityDetail column to indicate that a minimum value is returned
based on an incomplete cycle. In this case, an incomplete cycle is a
cycle that either contained periods with no values stored or a cycle that
was cut short because the query end time was located inside the cycle.
All values returned for the QualityDetail column are documented in
the QualityMap table in the Runtime database.
SELECT DateTime, TagName, Value, QualityDetail FROM History
WHERE TagName = 'SysTimeSec'
AND DateTime >= '2005-04-11 11:18:50'
AND DateTime <= '2005-04-11 11:20:50'
AND wwRetrievalMode = 'Minimum'
AND wwResolution = 60000
The sample data points and the results are mapped on the following
chart. Only the data falling between the time start and end marks at
00:20 and 00:40 (shown on the chart as dark vertical lines) are
returned by the query. The resolution is set at 10,000 milliseconds.
Because there is no value that matches the start time, an initial value
at 00:20 is returned based on the minimum value of the preceding
cycle, which is the data point at 00:09. In the two subsequent cycles,
the minimum values are at 00:22 and 00:38. The quality for these two
values is set to 4288 (4096 + 192). The remaining data points are
excluded because they are not minimums. In addition, the first NULL
at 00:28 is included, but the second NULL (at 00:29) is not.
Maximum Retrieval
The maximum value retrieval mode returns the maximum value from
the actual data values within a retrieval cycle. If there are no actual
data points stored on the historian for a given cycle, nothing is
returned. NULL is returned if the cycle contains one or more NULL
values.
As in cyclic retrieval, the number of cycles is based on the specified
resolution or cycle count. However, maximum retrieval is not a true
cyclic mode. Apart from the initial value, all points returned are delta
points.
Maximum retrieval only works with analog tags. For all other tags,
normal delta results are returned.
All returned values are in chronological order. If multiple points are to
be returned for a particular timestamp, they are returned in the order
in which the tags were specified in the query. If the maximum value
occurs several times in a cycle, the maximum value with the earliest
timestamp is returned.
The maximum retrieval mode must use the "<=" operator for the
ending date/time.
Using the maximum retrieval mode with a cycle count of 1 returns the
same results as the SQL Server MAX aggregate; however, the data is
returned much faster.
This example has a start time of TC0 and an end time of TC2. The
resolution has been set in such a way that the historian returns data
for two complete cycles starting at TC0 and TC1, a “phantom” cycle
starting at TCP, and an incomplete cycle starting at TC2. The phantom
cycle has the same duration as the first cycle in the query period,
extending back in time from the query start time.
For the queried tag, a total of 18 points are found throughout the
cycles, represented by the markers P1 through P18. Of these points, 17
represent normal analog values. The point P13 represents a NULL due
to an I/O Server disconnect, which causes a gap in the data between
P13 and P14.
The maximum value for the “phantom” cycle starting at TCP is
returned as the initial value at TC0. Point P18 is not considered at all
because it is outside of the query time frame. All other points are
considered, but only the points indicated by green markers on the
graph are returned (P12, P13, and P15).
In total, four points are returned:
• P6 as the maximum value of the “phantom” cycle and the initial
point
• P12 as the maximum value in the first cycle
• P13 as the first and only exception occurring in the first cycle
• P15 as the maximum value in the second cycle
No points are returned for the incomplete third cycle starting at the
query end time, because the tag does not have a point exactly at that
time.
If the maximum value of the first cycle is located exactly at the query
start time, this value and the maximum value of the phantom cycle are
returned.
or
wwRetrievalMode = 'Maximum'
Query 1
In this example, an analog tag is retrieved over a five-minute period,
using the maximum retrieval mode. Because the wwResolution
parameter is set to 60000, each cycle is exactly one minute long. The
maximum data value is returned from each of these cycles.
SELECT DateTime, TagName, CONVERT(DECIMAL(10, 2), Value) AS
Value FROM History
WHERE TagName = 'ReactTemp'
AND DateTime >= '2005-04-11 11:21:00'
AND DateTime <= '2005-04-11 11:26:00'
AND wwRetrievalMode = 'Maximum'
AND wwResolution = 60000
The initial value at the query start time is the maximum value found
in the phantom cycle before the start time of the query.
Query 2
In this example, the maximum retrieval mode is used in a manner
equivalent to using the SQL Server MIN aggregate. Note that the
cycle producing the result is the five-minute phantom cycle just before
the query start time.
SELECT TOP 1 DateTime, TagName, CONVERT(DECIMAL(10, 2), Value)
AS Value FROM History
WHERE TagName = 'ReactTemp'
AND DateTime >= '2005-04-11 11:31:00'
AND DateTime <= '2005-04-11 11:31:00'
AND wwRetrievalMode = 'Maximum'
AND wwResolution = 300000
Query 3
This example shows how the maximum retrieval mode marks the
QualityDetail column to indicate that a maximum value is returned
based on an incomplete cycle. In this case, an incomplete cycle is a
cycle that either contained periods with no values stored or a cycle that
was cut short because the query end time was located inside the cycle.
All values returned for the QualityDetail column are documented in
the QualityMap table in the Runtime database.
SELECT DateTime, TagName, Value, QualityDetail FROM History
WHERE TagName = 'SysTimeSec'
AND DateTime >= '2005-04-11 11:19:10'
AND DateTime <= '2005-04-11 11:21:10'
AND wwRetrievalMode = 'Maximum'
AND wwResolution = 60000
The sample data points and the results are mapped on the following
chart. Only the data falling between the time start and end marks at
00:20 and 00:40 (shown on the chart as dark vertical lines) are
returned by the query. The resolution is set at 10,000 milliseconds.
Because there is no value that matches the start time, an initial value
at 00:20 is returned based on the maximum value of the preceding
cycle, which is the data point at 00:15. In the two subsequent cycles,
the maximum values are at 00:26 and 00:35. The quality for these two
values is set to 4288 (4096 + 192). The remaining data points are
excluded because they are not maximums. In addition, the first NULL
at 00:28 is included, but the second NULL (at 00:29) is not.
Integral Retrieval
Integral retrieval calculates the values at retrieval cycle boundaries by
integrating the graph described by the points stored for the tag.
Therefore, it works much like average retrieval, but it additionally
applies a scaling factor. This retrieval mode is useful for calculating
volume for a particular tag. For example, if one of your tags represents
product flow in gallons per second, integral retrieval allows you to
retrieve the total product flow in gallons during a certain time period.
Integral retrieval is a true cyclic mode. It returns one row for each tag
in the query for each cycle. The number of cycles is based on the
specified resolution or cycle count.
Integral retrieval only works with analog tags. For all other tags,
normal cyclic results are returned.
Query 1
In this example, the integral is computed for each of five 1-minute long
cycles. The wwQualityRule parameter is used to ensure that only
points with good quality are used in the computation, which means
that points with doubtful quality are discarded. The rules used to
determine the returned OPCQuality are the same as described for a
time weighted average query.
SELECT DateTime, TagName, CONVERT(DECIMAL(10, 2), Value) AS
Flow, OPCQuality, PercentGood FROM History
WHERE TagName = 'FlowRate'
AND DateTime >= '2004-06-07 08:00'
AND DateTime < '2004-06-07 08:05'
AND wwRetrievalMode = 'Integral'
AND wwCycleCount = 5
AND wwQualityRule = 'Good'
Also, the “phantom” cycle affects the integral retrieval mode just as it
does the average retrieval mode. For examples, see "Querying
Aggregate Data in Different Ways" on page 324.
Slope Retrieval
Slope retrieval returns the slope of a line drawn through a given point
and the point immediately before it, thus expressing the rate at which
values change.
This retrieval mode is useful for detecting if a tag is changing at too
great a rate. For example, you might have a temperature that should
steadily rise and fall by a small amount, and a sharp increase or
decrease could point to a potential problem.
The slope retrieval mode can be considered a delta mode. Apart from
the initial value and a value at the query end time, all returned points
are calculated delta points returned with the timestamp of an actual
delta point.
Slope retrieval only works with analog tags. For all other tags, normal
delta results are returned.
All returned values are in chronological order. If multiple points are to
be returned for a particular timestamp, they are returned in the order
in which the tags were specified in the query.
For every point in the time period, slope retrieval returns the slope of
the line going through that point and the point immediately before it.
For two points P1 and P2 occurring at times T1 and T2, the slope
formula is as follows:
(P2 - P1) / (T2 - T1)
The difference between T1 and T2 is measured in seconds. Therefore,
the returned value represents the change in Engineering Units per
second.
In this example, point P2 is located at the query start time, and
because there is a prior value (P1), the slope of the line through both
points is calculated and returned at time TS. Similarly, slopes are
calculated to be returned at times T3, T4, T7, and T8. The slope is also
calculated for the line through P8 and P9, but that value is returned as
point PTE at the query end time.
For point P6, there is no prior point with which to perform a slope
calculation. Instead, the slope of the flat line going through the point
(that is, the value 0) is calculated. At the time of P5, NULL is returned.
The quality detail and OPC quality returned with a slope point is
always directly inherited from the point that also provides the time
stamp. In this example, this means that point P2 provides the qualities
for the slope point returned at the query start time, TS.
Query 1
The following query calculates and returns the rate of change of the
ReactTemp tag in °C/second. The initial value in the Quality column at
the query start time shows no value is located exactly at that time, so
the slope returned is the same as the one returned at the next delta
point. (For more information on initial values, see "Determining Cycle
Boundaries" on page 288.)
Counter Retrieval
Counter retrieval allows you to accurately retrieve the delta change of
a tag’s value over a period of time even for tags that are reset upon
reaching a “rollover value.” The rollover value is defined in the
Wonderware Historian for each tag.
This retrieval mode is useful for determining how much of an item was
produced during a particular time period. For example, you might
have an integer counter that keeps track of how many cartons were
produced. The counter has an indicator like this:
The next value after the highest value that can be physically shown by
the counter is called the rollover value. In this example, the rollover
value is 10,000. When the counter reaches the 9,999th value, the
counter rolls back to 0. Therefore, a counter value of 9,900 at one time
and a value of 100 at a later time means that you have produced 200
units during that period, even though the counter value has dropped
by 9,800 (9,900 minus 100). Counter retrieval allows you to handle this
situation and receive the correct value. For each cycle, the counter
retrieval mode shows the increase in that counter during the cycle,
including rollovers.
Counter retrieval also works with floating point counters, which is
useful for flow meter data. Similar to the carton counter, some flow
meters “roll over” after a certain amount of flow accumulates. For both
examples, the need is to convert the accumulating measure to a “delta
change” value over a given period.
Counter retrieval is a true cyclic mode. It returns one row for each tag
in the query for each cycle. The number of cycles is based on the
specified resolution or cycle count.
The counter algorithm is only applied to analog tags and to discrete
tags. For integer analog tags, the result will be an integer returned as
a float data type. For a real analog tag, the rollover value and the
result may be real values and can include fractional values. If a query
contains tags of other types, then no rows are returned for those tags.
For discrete tags, the rollover value is assumed to be 2.
The rules used to determine the OPCQuality returned with a counter
value are the same as for a time weighted average query. For more
information, see "Quality Rule (wwQualityRule)" on page 247. When a
rollover has occurred in the calculation cycle, a special quality detail of
212 is returned in all non-NULL cases.
CTU counters will default to "signed integer" tags when imported into
the Historian, giving a normal range of -2147483648 to 2147483647
(for a 32-bit integer). In operation, these counters will count up to the
upper limit and "rollover" to the lower limit on the next increment. If
these tags are changed to be "unsigned integers" the normal range will
be 0 to 4294967295 and values will rollover to "0", conforming to the
expected behavior of a tag used with "counter" retrieval. When used
with a 16-bit CTU counter, the same rules apply, but the range of
values is -32768 to 32767 as "signed" and 0 to 65535 for an "unsigned".
This example has a start time of TC0 and an end time of TC3. The
resolution has been set in such a way that the historian returns data
for three complete cycles starting at TC0, TC1, and TC2, and an
incomplete cycle starting at TC3.
For the queried tag, a total of twelve points are found throughout the
cycles represented by the markers P1 through P12. Of these points,
eleven represent normal analog values. The point P9 represents a
NULL due to an I/O Server disconnect, which causes a gap in the data
between P9 and P10. Point P12 is not considered because it is outside of
the query time frame.
All points are considered in the counter calculation, but only the
yellow ones are actually used to determine which values to return to
the client. The returned points are PC0, PC1, PC2 and PC3, shown in
green at the top to indicate that there is no simple relationship
between them and any of the actual points.
All cycle values are calculated as the delta change between the cycle
time in question and the previous cycle time, taking into account the
number of rollovers between the two points in time. The counter
algorithm assumes that a rollover occurred if the current value is
lower than the previous value. The initial value at the query start time
(PC1) is calculated the same way, only based on a phantom cycle before
the query start time.
For example, the formula to calculate PC1 is as follows:
PC1 = n * VR + P6 - P1
where:
n = the number of rollovers that have occurred during the cycle
VR = the rollover value for the tag
If either n or VR are equal to zero, PC1 is simply the difference between
the values P1 and P6.
In the case of cycle C2, there is no value at the cycle time, so the NULL
value represented by point P9 is returned. In the case of cycle C3, a
NULL is again returned, because there is no counter value at the
previous cycle boundary to use in the calculation. There must be a full
cycle of values in order for the counter to be calculated.
If a gap is fully contained inside a cycle, and if points occur within the
cycle on both sides of the gap, then a counter value is returned, even
though it may occasionally be erroneous. Zero or one rollovers are
assumed, even though the counter might have rolled over multiple
times.
In the following example, the rollover value for the SysTimeSec system
tag is set to 0. In a two-minute time span, the SysTimeSec tag
increments from 0 to 59 two times. The following query returns the
total count within the two-minute time span. The QualityDetail of 212
indicates that a counter rollover occurred during the query time range.
select DateTime, TagName, Value, Quality, QualityDetail as QD
from History
where TagName = 'systimesec'
and DateTime >= '2009-08-13 1:00'
and DateTime < '2009-08-13 1:02'
and wwRetrievalMode = 'counter'
and wwCycleCount = 1
ValueState Retrieval
ValueState retrieval returns information on how long a tag has been in
a particular value state during each retrieval cycle. That is, a
time-in-state calculation is applied to the tag value.
This retrieval mode is useful for determining how long a machine has
been running or stopped, how much time a process spent in a
particular state, how long a valve has been open or closed, and so on.
For example, you might have a steam valve that releases steam into a
reactor, and you want to know the average amount of time the valve
was in the open position during the last hour. ValueState retrieval can
return the shortest, longest, average, or total time a tag spent in a
state, or the time spent in a state as a percentage of the total cycle
length.
When you use ValueState retrieval for a tag in a trend chart, you must
specify a single value state for which to retrieve information.
ValueState retrieval then returns one value for each cycle—for
example, the total amount of time that the valve was in the “open”
state during each 1-hour cycle. This information is suitable for trend
display.
If you don’t specify a state, ValueState retrieval returns one row of
information for each value that the tag was in during each cycle. For
example, this would return not only the time a valve was in the “open”
state, but also the time it was in the “closed” state. This information is
not suitable for meaningful display in a regular trend. You can,
however, retrieve this type of information in a query and view it as a
table.
ValueState retrieval works with integer, discrete, string, and state
summary tags. For other types of tags, no rows are returned. NULL
values are treated like any other distinct state.
The values returned at the query start time are the result of applying
the algorithm to a “phantom” cycle preceding the query range. It is
assumed that the tag value at the start of the cycle is located at that
point in time.
To specify the type of calculation, set the wwStateCalc parameter in
the query. For more information, see "State Calculation
(wwStateCalc)" on page 255.
Value
ValueState Retrieval
C0 C1 C2 C3
PC0 PC1 PC2 PC3
ON
OFF Gap
1 2 3 4 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29
Time
TC0 TC1 TC2 TC3
This example has a start time of TC0 and an end time of TC3. The
resolution has been set in such a way that the historian returns data
for three complete cycles starting at TC0, TC1, and TC2, and an
incomplete cycle starting at TC3. Time is measured seconds.
A gap in the data occurs in the third cycle due to an I/O Server
disconnect.
The state calculation is based on each cycle, and the values returned at
the query start time are not regular initial values, but are the
resulting values that occur after applying the algorithm to the last
cycle preceding the query range. The returned points are PC0, PC1, PC2
and PC3, shown in green at the top to indicate that there is no simple
relationship between the calculated values and any of the actual
points.
Assume the query is set so that the total time (wwStateCalc =
‘Total’)in the two states are returned. The timestamping is set to use
the cycle end time.
• For TC0, the query returns two rows (one for the “on” state and one
for the “off” state), calculated as a result of the “phantom” cycle
that precedes the query start time. The values have a timestamp of
the query start time.
• For TC1, one row is returned for the “on” state. The “on” state
occurred twice during the cycle--one time for four seconds and
again for two seconds before the cycle boundary, and the total time
returned is six seconds. The state was “off” twice during the cycle
for a total time of four seconds, and one row is returned with that
value.
• For TC2, one row is returned for the “on” state, and one row is
returned for the “off” state. The “on” state occurred for a total of
nine seconds between the cycle boundaries, and the “off” state
occurred for a total of one second.
• For TC3, one row is returned for the “on” state, and one row is
returned for the “off” state. The “on” state occurred for a total of
four seconds between the cycle boundaries, and the “off” state
occurred for a total of three seconds. An additional row is returned
for the NULL state occurring as a result of the I/O Server
disconnect.
Using the same data, if you queried the total contained time for the
states, the following is returned:
• For TC0, the query returns two values (one for the “on” state and
one for the “off” state), calculated as a result of the “phantom” cycle
the precedes the query start time. The value has a timestamp of
the query start time.
• For TC1, one row is returned for the “on” state, and one row is
returned for the “off” state. The “on” state occurred one time for
four seconds within the cycle. The two seconds of “on” time that
crosses the cycle boundary does not contribute to the total time.
The state was “off” one time during the cycle for two seconds
completely within the cycle boundary.
• For TC2, the state was not “on” for any contained time between the
cycle. Both occurrences of the “on” state cross over a cycle
boundary, so no rows are returned for this state. One row is
returned for the “off” state. The state was “off” one time during the
cycle for one seconds completely within the cycle boundary.
• For TC3, one row is returned for the “on” state, and one row is
returned for the “off” state. The state was “on” for a single
contained time of two seconds between the cycle boundaries. The
state was “off” three times during the cycle for three seconds
completely within the cycle boundary. An additional row is
returned for the NULL state occurring as a result of the I/O Server
disconnect. The state was NULL for a total of three seconds. The
I/O Server disconnect that “disrupted” the off state is treated as its
own state, thereby changing what would have been a single “off”
state instance of five seconds into two instances of the “off” state
for one second each.
Be sure that you use the "<=" operator for ending date/time.
Query 2
The following query finds the maximum time-in-state for the
SteamValve discrete tag in the same time period as in Query 1. Note
how both the minimum and maximum values for the "1" state are very
similar, while they are very different for the "0" state. This is due to
the "cut-off" effect.
SELECT DateTime, TagName, vValue, StateTime, wwStateCalc FROM
History
WHERE TagName IN ('SteamValve')
AND DateTime >= '2005-04-17 10:00:00'
AND DateTime <= '2005-04-17 10:05:00'
AND wwCycleCount = 1
AND wwRetrievalMode = 'ValueState'
AND wwStateCalc = 'Max'
DateTime TagName vValue StateTime wwStateCalc
2005-04-17 10:00:00.000 SteamValve 0 107514.0 MAXIMUM
2005-04-17 10:00:00.000 SteamValve 1 43750.0 MAXIMUM
2005-04-17 10:05:00.000 SteamValve 0 107514.0 MAXIMUM
2005-04-17 10:05:00.000 SteamValve 1 43750.0 MAXIMUM
Query 3
The following query returns the total of time in state for a discrete tag.
In this example, the TimeStampRule system parameter is set to "End"
(the default setting), so the returned values are timestamped at the
end of the cycle. The returned rows represent the time-in-state
behavior during the period starting at 2005-04-13 00:00:00.000 and
ending at 2005-04-14 00:00:00.000.
SELECT DateTime, vValue, StateTime, wwStateCalc FROM History
WHERE DateTime > '2005-04-13 00:00:00.000'
AND DateTime <= '2005-04-14 00:00:00.000'
AND TagName IN ('PumpStatus')
AND wwRetrievalMode = 'ValueState'
AND wwStateCalc = 'Total'
AND wwCycleCount = 1
Query 4
The following query returns the percentage of time in state for a
discrete tag for multiple retrieval cycles. The TimeStampRule system
parameter is set to "End" (the default setting), so the returned values
are timestamped at the end of the cycle. Note that the first row
returned represents the results for the period starting at 2003-07-03
22:00:00.000 and ending at 2003-07-04 00:00:00.000.
The "Percent" time-in-state retrieval mode is the only mode in which
the StateTime column does not return time data. Instead, it returns
percentage data (in the range of 0 to 100 percent) representing the
percentage of time in state.
SELECT DateTime, vValue, StateTime, wwStateCalc FROM History
WHERE DateTime >= '2003-07-04 00:00:00.000'
AND DateTime <= '2003-07-05 00:00:00.000'
AND TagName IN ('PumpStatus')
AND Value = 1
AND wwRetrievalMode = 'ValueState'
AND wwStateCalc = 'Percent'
AND wwCycleCount = 13
RoundTrip Retrieval
RoundTrip retrieval is very similar to ValueState retrieval in that it
performs calculations on state occurrences in the within a cycle period
you specify. However, ValueState retrieval uses the time spent in a
certain state for the calculation, and RoundTrip retrieval uses the time
between consecutive leading edges of the same state for its
calculations.
You can use the RoundTrip retrieval mode for increasing the efficiency
of a process. For example, if a process produces one item per cycle,
then you would want to minimize the time lapse between two
consecutive cycles.
The RoundTrip mode returns a rows for each state in any given cycle.
RoundTrip retrieval only works with integer analog tags, discrete tags,
and string tags. If real analog tags are specified in the query, then no
rows are returned for these tags. RoundTrip retrieval is not applied to
state summary or analog summary tags. NULL values are treated as
any other distinct value and are used to analyze the round trip for
disturbances.
RoundTrip retrieval is supported for the History and
StateWideHistory tables.
Any point on the boundary of the end cycle will be considered to the
next cycle. The point on the boundary of the end query range is not
counted in the calculation except that it is used to indicate that the
previous state is a contained state.
If no roundtrip state is found within the cycle for a supported tag, a
NULL StateTime value is returned. If there is no valid point prior to
the phantom cycle, a NULL state is returned for the phantom cycle.
Value
RoundTrip Retrieval
C0 C1 C2 C3
PC0 Round-trip PC1 PC2 PC3
ON
OFF Gap
Round-trip
1 2 3 4 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29
Time
TC0 TC1 TC2 TC3
This example has a start time of TC0 and an end time of TC3. The
resolution has been set in such a way that the historian returns data
for three complete cycles starting at TC0, TC1, and TC2, and an
incomplete cycle starting at TC3. Time is measured seconds.
A gap in the data occurs in the third cycle due to an I/O Server
disconnect.
The state calculation is based on each cycle, and the values returned at
the query start time are not regular initial values, but are the
resulting values that occur after applying the algorithm to the last
cycle preceding the query range. The returned points are PC0, PC1, PC2
and PC3, shown in green at the top to indicate that there is no simple
relationship between the calculated values and any of the actual
points.
Assume the query is set so that the total contained time in the two
states are returned. The timestamping is set to use the cycle end time.
The RoundTrip retrieval mode returns values for states that are
completely contained within the cycle boundaries. The following is
returned:
• For TC0, the query returns two values (one for the “on” state and
one for the “off” state), calculated as a result of the “phantom” cycle
that preceeds the query start time. The value has a timestamp of
the query start time.
• For TC1, one row is returned for the “on” state, and one row is
returned for the “off” state. The round-trip for the “on” state
occurred one time for four seconds completely within the cycle
boundary. The round-trip for the “off” state occurred one time
during the cycle for five seconds.
• For TC2, a round-trip did not occur for either state within the cycle
boundaries. One NULL row is returned for this cycle.
• For TC3, one row is returned for the “on” state, and one row is
returned for the “off” state. The state was “on” for a single
contained time of two seconds between the cycle boundaries. The
state was “off” one time during the cycle for one second completely
within the cycle boundary. An additional row is returned for the
NULL state occurring as a result of the I/O Server disconnect.
• For TC3, one row is returned for the “on” state, and one row is
returned for the “off” state. The state was “on” for a single
contained time of three seconds between the cycle boundaries. One
row is returned for the “off” state for a total contained time of seven
seconds. (The first round-trip for the “off” state includes the I/O
Server disconnect for a length of four seconds. The second
round-trip has a length of three seconds.) An additional row is
returned for the NULL state occurring as a result of the I/O Server
disconnect, and the returned value is NULL because there is no
round-trip during the cycle for it. The I/O Server disconnect that
“disrupted” the off state is treated as its own state, thereby
changing what would have been a single “off” state instance of five
seconds into two instances of the “off” state for one second each.
The first two rows are for the “phantom” cycle leading up to the query
start time and have a timestamp of the query start time.
The second two rows show the average amount of time for each state
and have a timestamp of the query end time (the default).
(wwInterpolationType)
Cycle Count (X Values
(wwValueDeadband)
(wwTimestampRule)
(wwTimeDeadband)
Spaced Every X ms)
Resolution (Values
Interpolation Type
(wwQualityRule)
State Calculation
Value Deadband
Timestamp Rule
over Equal Time
(wwResolution)
Time Deadband
History Version
(wwStateCalc)
(wwVersion)
Quality Rule
Intervals)
Cyclic Retrieval Y Y Y Y*
Delta Retrieval Y Y Y
Full Retrieval Y
Interpolated Y Y Y Y Y Y
Retrieval
Note: You cannot use the IN clause or OR clause to specify more than
one condition for a time domain extension. For example, "wwVersion
IN ('original', 'latest')" and "wwRetrievalMode = 'Delta'
OR wwVersion = 'latest'" are not supported.
The application of the cycle count also depends on whether you are
querying a wide table. If you are querying the History table, the cycle
count determines the number of rows returned per tag. For example, a
query that applies a cycle count of 20 to two tags will return 40 rows of
data (20 rows for each tag). If you are querying a WideHistory table,
the cycle count specifies the total number of rows to be returned,
regardless of how many tags were queried. For example, a query that
applies a cycle count of 20 to two tags returns 20 rows of data.
Values chosen:
• If wwResolution and wwCycleCount are not specified, then a
default of 100 cycles are chosen.
• If wwResolution and wwCycleCount are set to 0, then a default of
100000 cycles are chosen.
• If wwResolution and wwCycleCount are both set, then
wwCycleCount is ignored.
• If wwCycleCount is specified and is less than 0, then a default of
100 cycles are chosen.
• For ValueState retrieval, if the start time of the cycle is excluded,
no states are returned for the first cycle.
• For ValueState retrieval, if the end time of the cycle is excluded, no
states are returned for the last cycle.
Note: The rowset is guaranteed to contain one row for each tag in the
normalized query at every resolution interval, regardless of whether a
physical row exists in history at that particular instance in time. The
value contained in the row is the last known physical value in history, at
that instant, for the relevant tag.
• ValueState Retrieval
• RoundTrip Retrieval
For delta retrieval, you can achieve similar results by using a time
deadband. For more information, see "Time Deadband
(wwTimeDeadband)" on page 232.
However, the time difference between start and end time in the above
query is actually not required because the resolution has been
provided explicitly (wwResolution = 36000000). If the query specified
an end time equal to the specified start time and if it included the
equal sign for the end time, the query would still return the same
single row of data.
SELECT DateTime, Value, Quality, QualityDetail as QD, OPCQuality
FROM History
WHERE TagName IN ('SysTimeSec')
AND DateTime >= '2007-12-11 08:00:00'
AND DateTime <= '2007-12-11 09:00:00'
AND wwRetrievalMode = 'Avg'
AND wwCycleCount = 1
This second example also asks for hourly averages and it also returns
only a single row of data stamped at the query start time. This query,
however, must specify a time difference between the start and end
time, because the resolution is not explicitly defined in the query.
As in the preceding query, the specified interval and cycle count of 1
may look like the returned row has been calculated for the specified
interval, but the returned row is once again for the phantom cycle
leading up to the start time.
The StartDateTime makes it easier to see which time interval was
used to calculate the returned aggregate. This column returns the time
stamp of the beginning of the cycle used for the aggregate calculation.
The time stamp is always returned in accordance with the specified
time zone and always has the same offset as the time stamp returned
in the DateTime column, even when the two time stamps are on
different sides of a DST change.
Assuming results are timestamped at the end of the cycle (as is done
by default when wwTimeStampRule is set to END), the initial rows in
the examples above would return a DateTime equal to '2009-10-16
08:00:00', and the StartDateTime column would return '2009-10-16
07:00:00' making it easy to interpret the result.
If instead the query were to ask for results time stamped at the
beginning of the cycle with wwTimeStampRule set to START, the
initial rows in the same examples would still return a DateTime equal
to '2009-10-16 08:00:00', but the time stamp has now been shifted in
accordance with the time stamp request. The result is therefore
calculated for the specified time interval between 8 a.m. and 9 a.m. In
this example, the new StartDateTime column would return the same
time stamp as the DateTime column, '2009-10-16 08:00:00', again
making it easier to interpret the result.
For retrieval modes for which cycles are defined, the StartDateTime
column returns the cycle start time. These modes are:
• Cyclic
• Interpolated
• BestFit
• Min
• Max
• Average
• Integral
• Counter
• ValueState
• RoundTrip
In the remaining retrieval modes, the StartDateTime column returns
the same time stamp as the DateTime column.
For an additional example, see "Querying Aggregate Data in Different
Ways" on page 324.
Data is retrieved for the time period starting with TS and ending with
TE. All points in the graphic represent data values stored on the
historian. The grey areas represent the time deadband, which starts
anew with every returned value. Only the green points (P2, P4, P7, P8,
P9, P11) are returned. The other points are not returned because they
fall within a deadband.
Query 1
This query specifies to only return data that changed during a 5
second time deadband.
SELECT DateTime, TagName, Value
FROM History
WHERE TagName = 'SysTimeSec'
AND DateTime >= '2001-12-09 11:35'
AND DateTime <= '2001-12-09 11:37'
AND wwRetrievalMode = 'Delta'
AND wwTimeDeadband = 5000
Query 2
This query specifies to only return data that changed during a 4900
millisecond time deadband.
SELECT DateTime, TagName, Value
FROM History
WHERE TagName = 'SysTimeSec'
AND DateTime >= '2001-12-09 11:35'
AND DateTime <= '2001-12-09 11:37'
AND wwRetrievalMode = 'Delta'
AND wwTimeDeadband = 4900
Query 3
This query specifies to only return data that changed during a 2000
millisecond time deadband.
SELECT DateTime, TagName, Value
FROM History
WHERE TagName IN ('SysTimeSec','SysTimeMin')
AND DateTime >= '2001-12-09 11:35'
AND DateTime <= '2001-12-09 11:36'
AND wwRetrievalMode = 'Delta'
AND wwTimeDeadband = 2000
Data is retrieved for the time period starting with TS and ending with
TE. All points in the graphic represent data values stored on the
historian. The grey areas represent the value deadband, which starts
anew with every returned value. Only the green points (P2, P5, P6, P7,
P9, P10, P11) are returned. The other points are not returned because
they fall within a deadband.
Query 1
This query specifies to return only data that changed by more than 10
percent of the tag's full engineering unit range. Using a value
deadband of 10 percent equates to an absolute change of 5.9 for
'SysTimeSec.'
SELECT DateTime, Value
FROM History
WHERE TagName = 'SysTimeSec'
AND DateTime >= '2001-12-09 11:35'
AND DateTime <= '2001-12-09 11:37'
AND wwRetrievalMode = 'Delta'
AND wwValueDeadband = 10
2001-12-09 11:36:36.000 36
2001-12-09 11:36:42.000 42
2001-12-09 11:36:48.000 48
2001-12-09 11:36:54.000 54
2001-12-09 11:37:00.000 0
Query 2
This query specifies to only return data that changed by more than 5
percent of the tag's full engineering unit range. Using a value
deadband of 5 percent equates to an absolute change of 2.95 for
'SysTimeSec.'
SELECT DateTime, Value
FROM History
WHERE TagName = 'SysTimeSec'
AND DateTime >= '2001-12-09 11:35'
AND DateTime <= '2001-12-09 11:37'
AND wwRetrievalMode = 'Delta'
AND wwValueDeadband = 5
2001-12-09 11:36:03.000 3
2001-12-09 11:36:06.000 6
2001-12-09 11:36:09.000 9
2001-12-09 11:36:12.000 12
2001-12-09 11:36:15.000 15
2001-12-09 11:36:18.000 18
2001-12-09 11:36:21.000 21
2001-12-09 11:36:24.000 24
2001-12-09 11:36:27.000 27
2001-12-09 11:36:30.000 30
2001-12-09 11:36:33.000 33
2001-12-09 11:36:36.000 36
2001-12-09 11:36:39.000 39
2001-12-09 11:36:42.000 42
2001-12-09 11:36:45.000 45
2001-12-09 11:36:48.000 48
2001-12-09 11:36:51.000 51
2001-12-09 11:36:54.000 54
2001-12-09 11:36:57.000 57
2001-12-09 11:37:00.000 0
The type of data that you want to retrieve usually determines the
interpolation type to use. For example, if you have a thermocouple, the
temperature change is linear, so it’s best to use linear interpolation. If
you have a tag that contains discrete measurements, such as a set
point, then you probably want to use stair-stepped values. In general,
it is recommended that you use linear interpolation as the general
setting, and use stair-stepped values for the exceptions.
This option is relevant in the following retrieval modes:
• Interpolated Retrieval
• "Best Fit" Retrieval
• Average Retrieval
• Integral Retrieval
• End: The value for a given cycle is stamped with the cycle end
time. For example, in the following illustration of a cyclic query,
the following values are returned at the cycle boundaries:
• At TC0: P1, because it is the last value in the “phantom” cycle
ending at TC0. Because the End timestamp rule is used, the
value is timestamped at TC0.
• At TC1: P7, because it falls on the cycle boundary. In cyclic
mode, if there is a value right on the cycle boundary, it is
considered to belong to the cycle before the boundary. In this
case, this is the cycle starting at TC0 and ending at TC1, and
because the End timestamp rule is used, the value is
timestamped at TC1.
• At TC2: P11, because it is the last value in the cycle ending at
TC2
For the integral retrieval mode, the query does not summarize data for
gaps because there is no way to know which value to use for the
summarization. However, if the query specifies OPTIMISTIC quality,
the query uses the last known good value for the summarization in the
gap. As described for the counter retrieval example, the PercentGood
column also expresses the quality of the calculated value in integral
retrieval, so if the PercentGood is anything less than 100, then the
returned row may be incorrect.
To force a query to use points with both good and doubtful OPC
quality, specify the following in the query:
AND wwQualityRule = 'Extended'
When you combine the same OPC quality then that OPC quality will
be returned. However, when there is no good point in a cycle for cyclic
modes such as Integral, Average, Counter, or AnalogSummary, the
returned NULL value will have an OPC quality of 0 and a Quality
Detail of 65536, regardless of combined qualities.
SELECT TagName, StartDateTime, EndDateTime, OPCQuality,
PercentGood, wwRetrievalMode, first
FROM AnalogSummaryHistory
WHERE TagName = 'F0R5'
AND StartDateTime >= '2009-09-12 00:20'
AND EndDateTime <= '2009-09-12 00:40'
AND wwResolution = 10000
AND wwRetrievalMode = 'Cyclic'
The returned Quality Detail is the same as OPC quality unless there is
special flag for certain indication for example when there is indication
for role over in counter mode.
SELECT TagName, DateTime, Value, QualityDetail, OPCQuality
FROM History
WHERE TagName = 'I0R5'
AND DateTime >= '2009-09-12 00:20'
AND DateTime <= '2009-09-12 00:40'
AND wwResolution = 10000
AND wwRetrievalMode = 'Avg'
Note: Cyclic, Full, Delta, Maximum, Minimum, and BestFit do not have
combined qualities; therefore, the rules are not applied to these modes.
Outliers
N
s 2 weighted = ? wi (x -µ *)
i
2
i=1
Ranges where the value is NULL are excluded from these calculations.
A cyclic query example using a ‘SigmaLimit()’ filter without specifying
the n value would look like this:
SELECT DateTime, Value, wwFilter
FROM History
WHERE TagName = ('TankLevel')
AND DateTime >= '2008-01-15 15:00:00'
AND DateTime <= '2008-01-15 17:00:00'
AND wwRetrievalMode = 'Cyclic'
AND wwFilter = 'SigmaLimit()'
If the first value would be filtered out by the SigmaLimit filter, the
value will be replaced with the time weighted mean.
Here the operator is specified as >, so values greater than but not
including 29 are internally converted to ON, whereas values from 0 to
29 are converted to OFF. This query could return the following rows:
DateTime vValue StateTime wwFilter
2008-01-15 15:00:00.000 0 30000 ToDiscrete(29, >)
2008-01-15 15:00:00.000 1 30000 ToDiscrete(29, >)
2008-01-15 17:00:00.000 0 30000 ToDiscrete(29, >)
2008-01-15 17:00:00.000 1 30000 ToDiscrete(29, >)
The values returned in the StateTime column show that the shortest
amount of time that SysTimeSec had values equivalent to either ON or
OFF and remained in that state was 30 seconds. A similar RoundTrip
query would look like this:
SELECT DateTime, vValue, StateTime, wwFilter
FROM History
WHERE TagName IN ('SysTimeSec')
AND DateTime >= '2008-01-15 15:00:00'
AND DateTime <= '2008-01-15 17:00:00'
AND wwRetrievalMode = 'RoundTrip'
AND wwStateCalc = 'MaxContained'
AND wwResolution = 7200000
AND wwFilter = 'ToDiscrete(29, <=)'
The values returned in the StateTime column now show that the
longest amount of time found between roundtrips for both the OFF
and the ON state within the 2-hour cycles was 60 seconds.
Using the ToDiscrete() filter is similar to using edge detection for
event tags. Edge detection returns the actual value with a
timestamp in history for when a value matched a certain criteria.
The ToDiscrete() filter returns either a 1 or 0 to show that the
criteria threshold was crossed. The ToDiscrete() filter is more
flexible, however, in the following ways:
• You can use it with delta and full retrieval.
• You can combine it with “time-in-state” calculations to determine
how long a value is above a certain threshold or the duration
between threshold times.
Use the ToDiscrete() filter if you are mostly interested in when
something occurred, and not necessarily the exact value of the event.
For more information on edge detection, see "Edge Detection for
Events (wwEdgeDetection)" on page 266.
MIN or MINIMUM The first minimum value that The actual timestamp of the
occurs within the summary first minimum value
period. occurrence within the
summary period.
MAX or MAXIMUM The first maximum value that The actual timestamp of the
occurs within the summary first maximum value
period. occurrence within the
summary period.
AVG or AVERAGE A time-weighted average The summary period start
calculated from values within the time.
summary period.
INTEGRAL An integral value calculated from The summary period start
values within the summary time.
period.
STDDEV or A standard deviation calculated The summary period start
STANDARDDEVIATION from values within the summary time.
period.
Cyclic The last value within the summary period is used. The actual timestamp
of the last value occurrence within the summary period is used.
Delta The last value within the summary period is used. The actual timestamp
of the last value occurrence within the summary period is used.
Full The last value within the summary period is used. The actual timestamp
of the last value occurrence within the summary period is used.
Interpolated The retrieval mode determines the appropriate value to return. See the
following table for how AUTO applies to the value selection. This is the
default value.
Best Fit The first, last, min, and max points from analog summaries are all
considered as analog input points. Best fit analysis is done with these
points. If the analog summary percentage good is not 100%, the cycle is
considered to have a NULL.
Average The averages of analog summaries are calculated using the values from
the Average column of the AnalogSummaryHistory table. Interpolation
type is ignored for analog summary values, and STAIRSTEP
interpolation is always used. PercentGood is calculated by considering the
TimeGood of each analog summary.
If cycle boundaries do not exactly match the summary periods of the
stored analog summaries, the averages and time good are calculated by
prorating the average and time good values for the portion of the time the
summary period overlaps with the cycle. Quality will be set to 64
(uncertain) if cycle boundaries do not match summary periods.
If the QualityDetail of any analog summary considered for a cycle is
uncertain (64), the resulting quality is set to 64.
Minimum The first minimum value within the summary period is used. The actual
timestamp of the first minimum value occurrence within the summary
period is used.
Maximum The first maximum value within the summary period is used. The actual
timestamp of the first maximum value occurrence within the summary
period is used.
Integral The integrals of analog summaries are calculated using the Integral
column of the AnalogSummaryHistory table. Interpolation type is ignored
for analog summary values, and STAIRSTEP interpolation is always
used. PercentGood is calculated by considering the TimeGood of each
analog summary.
If cycle boundaries do not exactly match the summary periods of the
stored analog summaries, the integrals and time good are calculated by
prorating the integral and time good values for the portion of the time the
summary period overlaps with the cycle. Quality is set to 64 (uncertain) if
cycle boundaries do not match summary periods.
If the QualityDetail of any analog summary considered for a cycle is
uncertain (64), the resulting quality will be set to 64.
Slope The last value within the summary period is used. The actual timestamp
of the last value occurrence within the summary period is used.
ValueState Cannot be used with analog summary data. No values are returned.
Counter Cannot be used with analog summary data. No values are returned.
RoundTrip Cannot be used with analog summary data. No values are returned.
Option Results
D F
B
V
A
L
U
E
A C E G
TIME
Slopes A-B, C-D and E-F are rising edges, while slopes B-C, D-E and
F-G are falling edges. The slopes are affected by the WHERE clause,
which is a combination of the wwEdgeDetection option and the
comparison operator used against the value.
The following table describes the rows that would be returned for the
various edge detection settings:
* If the falling edge is a vertical edge with no slope, the query will
return the lowest value of that edge.
The following query selects all values of "SysTimeSec" that are greater
than or equal to 50 from the History table between 10:00 and 10:02
a.m. on December 2, 2001. No edge detection is specified.
SELECT DateTime, Value
FROM History
WHERE TagName = 'SysTimeSec'
AND DateTime >= '2001-12-02 10:00:00'
AND DateTime <= '2001-12-02 10:02:00'
AND wwRetrievalMode = 'Cyclic'
AND wwResolution = 2000
AND Value >= 50
AND wwEdgeDetection = 'None'
2001-12-02 10:01:56.000 56
2001-12-02 10:01:58.000 58
The query will return only the two values that were greater than or
equal to 50 for the time period specified:
DateTime Value
2001-12-02 10:00:50.000 50
2001-12-02 10:01:50.000 50
Compare these results with the same query using no edge detection, as
shown in "Edge Detection for Analog Tags" on page 267. Notice that
even though the original query returned ten rows, the edge detection
only returns the first row recorded after the event criteria returned
true.
The query returns only the two values that were the first to fail the
criteria in the WHERE clause for the time period specified:
DateTime Value
2001-12-02 10:01:00.000 0
2001-12-02 10:02:00.000 0
Compare these results with the same query using no edge detection, as
shown in "Edge Detection for Analog Tags" on page 267. Notice that
even though the original query returned ten recorded rows for each
value, the edge detection only returns the first row recorded after the
event criteria returned false.
Compare these results with the same query using no edge detection, as
shown in "Edge Detection for Analog Tags" on page 267. Notice that
value of the first row in the original query is returned in the result set.
Tag Description
1
MyPulse
1
SysPulse
0
00:03:20
00:03:40
00:04:00
00:01:00
00:01:20
00:01:40
00:02:00
00:02:20
00:02:40
00:03:00
Query 1
Query for History.
SELECT DateTime, TagName, Value
FROM History
WHERE TagName IN ('SysPulse','MyPulse')
AND DateTime > '2001-12-08 00:59:00'
AND DateTime <= '2001-12-08 01:04:00'
AND wwRetrievalMode = 'Delta'
AND Value = 1
AND wwEdgeDetection = 'None'
Query 2
Query for WideHistory.
SELECT * FROM OpenQuery(INSQL, 'SELECT DateTime, SysPulse,
MyPulse FROM WideHistory
WHERE DateTime > "2001-12-08 00:59:00"
AND DateTime < "2001-12-08 01:05:00"
AND SysPulse = 1
AND MyPulse = 1
AND wwRetrievalMode = "Delta"
AND wwEdgeDetection = "None"
')
Query 1
For a query on the History table, if the WHERE clause criteria specify
to return only discrete values equal to 1 (On), then applying a leading
edge detection does not change the result set.
SELECT DateTime, TagName, Value
FROM History
WHERE TagName IN ('SysPulse','MyPulse')
AND DateTime > '2001-12-08 00:59:00'
AND DateTime <= '2001-12-08 01:04:00'
AND Value = 1
AND wwEdgeDetection = 'Leading'
Query 2
For a query on the WideHistory table, applying a leading edge
detection requires that the condition only evaluate to true if both
values are equal to 1 (On).
SELECT DateTime, SysPulse, MyPulse FROM OpenQuery(INSQL, 'SELECT
DateTime, SysPulse, MyPulse
FROM WideHistory
WHERE DateTime > "2001-12-08 00:59:00"
AND DateTime <= "2001-12-08 01:04:00"
AND SysPulse = 1
AND MyPulse = 1
AND wwEdgeDetection = "Leading"
')
Compare these results with the same query using no edge detection, as
shown in "Edge Detection for Discrete Tags" on page 271. If you look at
the diagram, you might think that a row could be returned at 00:03:00,
but because both tags change at exactly this instant, their values are
not returned. In a normal process, it is unlikely that two tags would
change at exactly at the same instant.
Query 1
For a query on the History table, if the WHERE clause criteria
specifies to return only discrete values equal to 1 (On), then applying a
trailing edge detection is the same as reversing the WHERE clause (as
if Value = 0 was applied).
SELECT DateTime, TagName, Value
FROM History
WHERE TagName IN ('SysPulse','MyPulse')
AND DateTime > '2001-12-08 00:59:00'
AND DateTime <= '2001-12-08 01:04:00'
AND Value = 1
AND wwEdgeDetection = 'Trailing'
Query 2
For a query on the WideHistory table, applying a trailing edge
detection returns the boundaries where the condition ceases to be true
(one of the values is equal to 0).
SELECT DateTime, SysPulse, MyPulse FROM OpenQuery(INSQL, 'SELECT
DateTime, SysPulse, MyPulse
FROM WideHistory
WHERE DateTime > "2001-12-08 00:59:00"
AND DateTime <= "2001-12-08 01:04:00"
AND SysPulse = 1
AND MyPulse = 1
AND wwEdgeDetection = "Trailing"
')
Compare these results with the same query using no edge detection, as
shown in "Edge Detection for Discrete Tags" on page 271. If you look at
the diagram, you might think that a row could be returned at 00:03:00,
but because both tags change at exactly this instant, their values are
not returned. In a normal process, it is unlikely that two tags would
change at exactly at the same instant.
Query 1
SELECT DateTime, TagName, Value
FROM History
WHERE TagName IN ('SysPulse','MyPulse')
AND DateTime > '2001-12-08 00:59:00'
AND DateTime <= '2001-12-08 01:04:00'
AND Value = 1
AND wwEdgeDetection = 'Both'
Query 2
SELECT DateTime, SysPulse, MyPulse FROM OpenQuery(INSQL, 'SELECT
DateTime, SysPulse, MyPulse
FROM WideHistory
WHERE DateTime > "2001-12-08 00:59:00"
AND DateTime <= "2001-12-08 01:04:00"
AND SysPulse = 1
AND MyPulse = 1
AND wwEdgeDetection = "Both"
')
Compare these results with the same query using no edge detection, as
shown in the "Edge Detection for Discrete Tags" on page 271.
Chapter 9
Query Examples
The following query returns values for three tags from the
WideHistory table. "MyTagName" is a tag that periodically is invalid.
SELECT * FROM OpenQuery(INSQL,'
SELECT DateTime, SysTimeSec, SysTimeMin, MyTagName
FROM WideHistory
WHERE DateTime >= "2001-05-12 13:00:00"
AND DateTime <= "2001-05-12 13:02:00"
AND wwRetrievalMode = "Delta"
')
2001-05-12 13:01:02.000 02 01 2
2001-05-12 13:01:03.000 03 01 2
: : : :
: : : :
: : : :
The following query returns the minimum time in state, the minimum
contained time in state, and value for the SysTimeSec system tag.
SELECT TagName, StartDateTime, EndDateTime, StateTimeMin as STM,
StateTimeMinContained as STMC, Value
FROM StateSummaryHistory
WHERE TagName='SysTimeSec'
AND wwRetrievalMode='Cyclic'
AND wwResolution=5000
AND StartDateTime>='2009-10-21 17:40:00.123'
AND StartDateTime<='2009-10-21 17:40:05.000'
Query 1
This query returns data from the history table, based on a string tag
that you filter for from the StringTag table:
SELECT DateTime, T.TagName, vValue, Quality, QualityDetail
FROM StringTag T inner remote join History H
ON T.TagName = H.TagName
WHERE T.MaxLength = 64
AND DateTime >='2002-03-10 12:00:00.000'
AND DateTime <='2002-03-10 16:40:00.000'
AND wwRetrievalMode = 'Delta'
Query 2
This query returns data from the history table, based on a discrete tag
that you filter for from the Tag table:
SELECT DateTime, T.TagName, vValue, Quality, QualityDetail
FROM Tag T inner remote join History H
ON T.TagName = H.TagName
WHERE T.TagType = 2
AND T.Description like 'Discrete%'
AND DateTime >='2002-03-10 12:00:00.000'
AND DateTime <='2002-03-10 16:40:00.000'
AND wwRetrievalMode = 'Delta'
Retrieval Cycle
Mode Resolution Count Results
CYCLIC N 0 (or no All stored data for tags during the specified time
value) interval are queried, and then a resolution of N
ms applied.
CYCLIC 0 (or no 0 The server will return 100,000 rows per tag
value) specified.
CYCLIC 0 (or no N All stored data for tags during the specified time
value) interval are queried, and then a cycle count of N
evenly spaced rows is applied.
CYCLIC N (any value All stored data for tags during the specified time
is ignored) interval are queried, and then a resolution of N
ms applied.
CYCLIC (no value) (no value The server will return 100 rows per tag specified.
or a value
less than 0)
DELTA (any value is 0 All values that changed during the specified time
ignored) interval are returned (up to 100,000 rows total).
DELTA (any value is N Values that changed during the specified time
ignored) interval are queried, and then a cycle count (first
N rows) is applied. The cycle count limits the
maximum number of rows returned, regardless of
how many tags were queried. For example, a
query that applies a cycle count of 20 to four tags
will return a maximum of 20 rows of data. An
initial row will be returned for each tag, and the
remaining 16 rows will be based on subsequent
value changes for any tag.
DELTA (any value is (no value) All values that changed during the specified time
ignored) interval are returned (no row limit).
To perform the filtering, the SQL Server must determine the data type
of the constant (in this example, 2), and attempt to convert the variant
(string) to this destination type. The SQL Server assumes that a
constant without a decimal is an integer, and attempts to convert the
string to an integer type. This conversion will fail in SQL Server if the
string actually represents a float (for example, 2.00123).
You should explicitly state the destination type by means of a
CONVERT function. This is the only reliable way of filtering on the
vValue column, which contains variant data.
For example:
SELECT DateTime, Quality, OPCQuality, QualityDetail, Value,
vValue, TagName
FROM History
WHERE TagName IN ('ADxxxF36', 'SysTimeMin', 'SysPulse')
AND DateTime >= '12-04-2001 04:00:00.000'
AND DateTime <= '12-04-2001 04:03:00.000'
AND wwRetrievalMode = 'Delta'
AND convert(float, vValue) = 2
For any query, the SQL Server performs all date/time computations in
local server time, reformulates the query with specific dates, and sends
it on to the Wonderware Historian OLE DB provider. The Wonderware
Historian OLE DB provider then applies the wwTimeZone parameter
in determining the result set.
For example, the following query requests the last 30 minutes of data,
expressed in Eastern Daylight Time (EDT). The server is located in
the Pacific Daylight Time (PDT) zone.
SELECT DateTime, TagName, Value FROM History
WHERE TagName IN ('SysTimeHour', 'SysTimeMin',
'SysTimeSec')
AND DateTime > DateAdd(mi, -30, GetDate())
AND wwTimeZone = 'eastern daylight time'
Thus, for delta retrieval mode, a SUM or AVG is applied only if the
value has changed from the previous row.
If you perform an AVG in delta retrieval mode, AVG will be computed
as:
SUM of delta values/number of delta values
For example, an AVG is applied to all of the returned column values:
SELECT * FROM OpenQuery(INSQL,'SELECT Avg(SysTimeHour),
Avg(SysTimeMin), Avg(SysTimeSec), Avg(SysDateDay)
FROM WideHistory
WHERE DateTime >= "2001-08-15 13:20:57.345"
AND DateTime < "2001-08-15 13:21:03.345"
AND wwRetrievalMode = "Delta"
')
GO
Query 1
For this query, the start date will not correspond to a data change:
SELECT DateTime, Value, Quality
FROM History
WHERE TagName = 'SysTimeMin'
AND wwRetrievalMode = 'Delta'
AND DateTime >= '2001-01-13 12:00:30'
AND DateTime < '2001-01-13 12:10:00'
The start time (12:00:30) does not correspond with an actual change in
value, and is therefore marked with the initial quality of 133:
DateTime Value Quality
2001-01-13 12:00:30.000 0 133
2001-01-13 12:01:00.000 1 0
2001-01-13 12:02:00.000 2 0
2001-01-13 12:03:00.000 3 0
2001-01-13 12:04:00.000 4 0
2001-01-13 12:05:00.000 5 0
2001-01-13 12:06:00.000 6 0
2001-01-13 12:07:00.000 7 0
2001-01-13 12:08:00.000 8 0
2001-01-13 12:09:00.000 9 0
(10 row(s) affected)
Query 2
For this query, the start date will correspond to a data change:
SELECT DateTime, Value, Quality
FROM History
WHERE TagName = 'SysTimeMin'
AND wwRetrievalMode = 'Delta'
AND DateTime >= '2001-01-13 12:01:00'
AND DateTime < '2001-01-13 12:10:00'
2001-01-13 12:08:00.000 8 0
2001-01-13 12:09:00.000 9 0
(9 row(s) affected)
Query 3
For this query, the start date will return at least one row, even though
the query captures no data changes:
SELECT DateTime, Value, Quality
FROM History
WHERE TagName = 'SysTimeMin'
AND wwRetrievalMode = 'Delta'
AND DateTime >= '2001-01-13 12:00:30'
AND DateTime < '2001-01-13 12:01:00'
The query does not capture an actual change in value, and is therefore
marked with the initial value quality of 133 for the start time of the
query:
DateTime Value Quality
2001-01-13 12:00:30.000 0 133
(1 row(s) affected)
Query 1
For this query, the first row that will be returned will be the first valid
change after (but not including) the start time (12:00:30):
SELECT DateTime, Value, Quality
FROM History
WHERE TagName = 'SysTimeMin'
AND wwRetrievalMode = 'Delta'
AND DateTime > '2001-01-13 12:00:30'
AND DateTime < '2001-01-13 12:10:00'
The first row returned is the first valid change after (but not including)
the start time (12:00:30):
DateTime Value Quality
2001-01-13 12:01:00.000 1 0
2001-01-13 12:02:00.000 2 0
2001-01-13 12:03:00.000 3 0
2001-01-13 12:04:00.000 4 0
2001-01-13 12:05:00.000 5 0
2001-01-13 12:06:00.000 6 0
2001-01-13 12:07:00.000 7 0
2001-01-13 12:08:00.000 8 0
2001-01-13 12:09:00.000 9 0
(9 row(s) affected)
Query 2
For this query, the start date will correspond to a data change, but it
will be excluded from the result set because the operator used is
greater than, not greater than or equal to.
SELECT DateTime, Value, Quality
FROM History
WHERE TagName = 'SysTimeMin'
AND wwRetrievalMode = 'Delta'
AND DateTime > '2001-01-13 12:01:00'
AND DateTime < '2001-01-13 12:10:00'
Query 3
This query will return no rows, because no data changes are captured:
SELECT DateTime, Value, Quality
FROM History
WHERE TagName = 'SysTimeMin'
AND wwRetrievalMode = 'Delta'
AND DateTime > '2001-01-13 12:00:30'
AND DateTime < '2001-01-13 12:01:00'
(0 row(s) affected)
Note that there is a valid change at exactly the end time of the query
(12:10:00):
DateTime Value Quality
2001-01-13 12:01:00.000 1 0
2001-01-13 12:02:00.000 2 0
2001-01-13 12:03:00.000 3 0
2001-01-13 12:04:00.000 4 0
2001-01-13 12:05:00.000 5 0
2001-01-13 12:06:00.000 6 0
2001-01-13 12:07:00.000 7 0
2001-01-13 12:08:00.000 8 0
2001-01-13 12:09:00.000 9 0
2001-01-13 12:10:00.000 10 0
(10 row(s) affected)
Note that there is a valid change at exactly the end time of the query
(12:10:00), but it is excluded from the result set.
DateTime Value Quality
2001-01-13 12:01:00.000 1 0
2001-01-13 12:02:00.000 2 0
2001-01-13 12:03:00.000 3 0
2001-01-13 12:04:00.000 4 0
2001-01-13 12:05:00.000 5 0
2001-01-13 12:06:00.000 6 0
2001-01-13 12:07:00.000 7 0
2001-01-13 12:08:00.000 8 0
2001-01-13 12:09:00.000 9 0
(9 row(s) affected)
Query 1
This query uses a cycle count of 60, resulting in a 1 second resolution
for the data. The starting time is set to >=.
SELECT DateTime, Value
FROM History
WHERE TagName = 'SysTimeSec'
AND wwCycleCount = 60
AND DateTime >= '2001-01-13 12:00:00'
AND DateTime < '2001-01-13 12:01:00'
Query 2
This query also uses a cycle count of 60, resulting in a 1 second
resolution for the data. The ending time is set to <=.
SELECT DateTime, Value
FROM History
WHERE TagName = 'SysTimeSec'
AND wwCycleCount = 60
AND DateTime > '2001-01-13 12:00:00'
AND DateTime <= '2001-01-13 12:01:00'
Query 1
This query uses a resolution of 1000, resulting in a 1 second resolution
for the data.. The starting time is set to >=.
SELECT DateTime, Value
FROM History
WHERE TagName = 'SysTimeSec'
AND wwResolution = 1000
AND DateTime >= '2001-01-13 12:00:00'
AND DateTime < '2001-01-13 12:01:00'
Query 2
This query also uses a row resolution of 1000, resulting in a 1 second
resolution for the data. The starting time is set to <=.
SELECT DateTime, Value
FROM History
WHERE TagName = 'SysTimeSec'
AND wwResolution = 1000
AND DateTime > '2001-01-13 12:00:00'
AND DateTime <= '2001-01-13 12:01:00'
For cyclic retrieval, cycles start at the start DateTime and occur at
intervals specified by wwResolution in the query. If you query for the
data 2012-01-01 08:00:00 to 2012-01-01 08:01:00 with four cycles, the
wwResolution column in the results show the time in milliseconds
until the next point.
DateTime Value wwResolution
2012-01-01 08:00:00 34.42384 20000
2012-01-01 08:00:20 15.02637 20000
2012-01-01 08:00:40 20.29732 20000
2012-01-01 08:01:00 37.40273 20000
When the last point in the result occurs before the query end time, the
wwResolution column shows the time until the end of the query when
there is a next available point. If there are no more points, then the
wwResolution column shows NULL.
For example, the following is stored:
DateTime Value
2012-01-01 07:59:53 34.42384
2012-01-01 08:00:13 15.02637
2012-01-01 08:00:33 20.29732
2012-01-01 08:00:53 37.40273
2012-01-01 08:01:13 24.31662
If the last point happens to be end of the query, then the wwResolution
value is zero, even when there are no more points after the last point.
For example, if you query for data from 2012-01-01 08:00:00 to
2012-01-01 08:01:13, the results are:
DateTime Value wwResolution
2012-01-01 08:00:00 34.42384 13000
2012-01-01 08:00:13 15.02637 20000
2012-01-01 08:00:33 20.29732 20000
2012-01-01 08:00:53 37.40273 20000
2012-01-01 08:01:13 24.31662 0
SELECT DateTime,
"Sec" = datepart(ss, DateTime),
"mS" = datepart(ms, DateTime),
ReactTemp, ReactLevel
INTO MyTable
FROM OpenQuery(INSQL, 'SELECT DateTime, ReactTemp,
ReactLevel FROM WideHistory
WHERE wwResolution = 5000
AND DateTime >= "2001-03-13 1:58pm"
AND DateTime <= "2001-03-13 2:00pm" ')
FROM Runtime.dbo.EventHistory
OPEN Hist_Cursor
FETCH NEXT FROM Hist_Cursor INTO @DateValue, @EventTag,
@EventKey
WHILE @@FETCH_STATUS = 0
BEGIN
CLOSE Hist_Cursor
DEALLOCATE Hist_Cursor
Note: When you are using Wonderware Historian with SQL Server
2008, millisecond resolution is supported for retrieval by using the
DateTime2 data type.
For consistency with SQL Server 2005, it is important that any OLE
DB time functions present time data according to the same convention.
A rounding algorithm is incorporated to achieve the desired results.
This is necessary when a user calls a datetime function that
manipulates milliseconds within an OPENQUERY statement. For
example:
SELECT * FROM OpenQuery(INSQL,
'SELECT DATEPART(millisecond, getdate()), Value
FROM Live WHERE TagName = "ReactTemp"')
If you are using time or value deadbands for delta retrieval across a
data gap, the behavior is as follows:
• For a value deadband, all NULLs will be returned and all values
immediately after a NULL will be returned. That is, the deadband
is not applied to values separated by a NULL.
• For a time deadband, null values are treated like any other value.
Time deadbands are not affected by NULLs.
For cyclic retrieval, NULL will be returned for data values that occur
before the start of the history block.
Another non-valid start time is a start time that is later than the
current time of the Wonderware Historian computer. For delta
retrieval, a single NULL value will be returned. For cyclic retrieval, a
NULL will be returned for each data value requested.
Query 1
The following query uses the SQL Server average function to return
the average value of the SysTimeSec tag over the span of one minute.
SELECT AVG(Value) as 'SysTimeSec AVG'
FROM History
WHERE TagName = 'SysTimeSec'
AND DateTime > '2009-11-15 6:30:00'
AND DateTime < '2009-11-15 6:31:00'
AND wwRetrievalMode = 'Full'
Query 2
The following query uses the historian time-weighted average
retrieval mode to return the average for the same time period. Because
the cycle count is set to 2, a first row is returned for the
“phantom”cycle leading up to the query start time. The StartDateTime
column shows the time stamp at the start of the data sampling, which
is the start time of the phantom cycle. The second row returned
reflects is the actual data that you expect. The time stamp for the data
value is 2009-11-15 06:31:00 because the default time stamping rule is
set so that the ending time stamp for the cycle is returned. For more
information about the phantom cycle, see "About "Phantom" Cycles"
on page 230.
SELECT StartDateTime, DateTime, TagName, Value
FROM History
WHERE TagName = 'SysTimeSec'
AND DateTime >= '2009-11-15 6:30:00'
AND DateTime <= '2009-11-15 6:31:00'
AND wwRetrievalMode = 'Average'
AND wwCycleCount = 2
AND wwTimeStampRule = 'end'
Query 3
For the following query, local replication has been set up so that the
average of the SysTimeSec tag is calculated every minute and stored
to the SysTimeSec.1M analog summary tag. The query returns the
value of the SysTimeSec.1M tag for the time period specified.
SELECT TagName, StartDateTime, EndDateTime, Average as AVG
FROM AnalogSummaryHistory
WHERE TagName = 'SysTimeSec.1M'
AND StartDateTime >= '2009-11-15 6:30:00'
AND EndDateTime <= '2009-11-15 6:31:00'
Query 4
The following query, the History table is used instead of the
AnalogSummaryHistory table. Because the cycle count is set to 2, this
query returns a row for the phantom cycle. The time stamp for the
data value is 2009-11-15 06:31:00 because the default time stamping
rule is set so that the ending time stamp for the cycle is returned.
SELECT TagName, DateTime, Value
FROM History
WHERE TagName = 'SysTimeSec.1M'
AND DateTime >= '2009-11-15 6:30:00'
AND DateTime <= '2009-11-15 6:31:00'
AND wwRetrievalMode = 'avg'
AND wwCycleCount = 2
The results:
TagName DateTime Value
SysTimeSec.1M 2009-11-15 06:30:00 29.5
SysTimeSec.1M 2009-11-15 06:31:00 29.5
Query 5
The following query returns five minutes of summary data for an
event tag that has been configured to store the average value of the
SysTimeSec tag every minute.
SELECT TagName, CalcType, SummaryDate, Value
FROM v_SummaryData
WHERE TagName = 'SysTimeSec'
AND SummaryDate >= '2009-11-15 18:30:00'
AND SummaryDate <= '2009-11-15 18:31:00'
Chapter 10
Replication Subsystem
The tier-2 historian stores data replicated from the tier-1 historians.
Tier-2: Centralized
reporting and system
of record
Tier-1 Local
troubleshooting and
buffering
I/O
Tier-2
Tier-1
tag1 tag2
replicated to tag2 is a
tag2 on tier-2 tag of
Historian B Historian B
tag1 is a
tier-1 tag of
Historian A
tag3 is a tag4 is a
tier-1 tag of tier-2 tag of
Historian B Historian C
tag3 tag4
replicated to
tag4 on
Historian C
Simple Replication
When a tag is configured for simple replication, all values stored in the
tier 1 historian are replicated to the tier 2 server. Analog, discrete, and
string tags can be configured for simple replication. Replicated tags of
a tier-2 historian cannot be configured for further replication.
Tier-2 example: 1-
second data
Replicate all
data for tags
The results of replication are stored on the tier-2 historian using the
same tag type as was used for the tag on the tier-1 historian.
Simple replication of tag values occurs:
• Every time a new stored data value arrives into the active image of
the tier-1 historian.
• Every time there is a change made in the history of the tier-1 tag to
keep tier-1 and tier-2 tag values synchronized in history. For more
information, see "How Replication is Handled for Different Types
of Data" on page 339.
Summary Replication
Summary replication involves analyzing and storing statistical
information about the tag value at the tier-1 historian. This occurs at
an interval you specify, called the calculation cycle. The algorithm
used for the summaries is the same as for the summary retrieval
modes. However, when a summary computation is performed on a
tier-1 tag with multiple values at the same time, the order of these
values cannot be guaranteed and the summary may differ from the
summary computed by the replication service at run time.
The result of the calculation is sent to the tier-2 historian to be stored
with the timestamp of the cycle. Tier-2 tags are not dependent on the
"real-time window" that applies to tags that use classic storage.
Tier-2 example:
5-minute, hourly, daily rate
Many aggregate
values for each
“summary” tag
Replication Schedules
Each real-time summary has a specified schedule, by which the
summary is calculated and sent to the tier-2 historian to be stored
with the timestamp of the cycle.
There are two types of replication schedules:
• Periodic replication schedules
You can configure a summary to replicate based on an cycle such
as 1 minute, 5 minutes, 1 hour, 1 day, and so on. The cycle
boundaries are calculated starting at midnight, tier-1 server local
time, and continue in fixed time increments. The time between
cycles is constant within a day even through a daylight savings
change. Note that the last cycle in a day may be shorter to force
replication at midnight. The calculation cycle starts at midnight.
For example, a 13-minute cycle is stored at 12:00 a.m., 12:13,
12:26, ... 11:27 p.m., 11:40, 11:53 and then again at 12:00 a.m.
• Custom replication schedules
Custom schedules force replication cycles to occur at fixed times of
the day in tier-1 server local time. You choose the fixed times of
day.
In the next example, the summary period is configured for every four
hours. The scheduled summaries do not fall exactly on or within the
boundaries of the time change hour. In this case, on the “fall back” day,
the summary subsequent to the time change hour includes four hours
of data for the “fall back” day. An extra summary for an hour’s worth of
data is performed at the end of the “fall back” day. On the “spring
forward” day, the summary period that contains the skipped hour
includes one less hour of data.
Summary Period = 4 Hours
Replication Groups
A replication group abstracts a tag from a schedule. You can assign
multiple summary tags to a single replication group.
Replication Schedule
1 Day
Summary Tags
Summary Tag A
Summary Tag B
Replication 1 Day Summary Tag C
Server A
.
Replication Group Summary Tag N
Replication Schedule
8-hour shift
Summary Tags
Summary Tag A
My Group A Summary Tag B
Replication Summary Tag C
Server A
Summary Tag D
My Group B Summary Tag E
Summary Tag F
Replication Groups
Replication Schedule
8-hour shift
Summary Tags
Streaming Replication
When values of tier-1 tags are received from an IDAS or HCAL
(Wonderware Application Server) and arrive at the tier-1 historian as
a time-ordered data stream directly, the historian not only stores the
data, but also forwards it to the replication subsystem if replication is
configured for those tags.
Then the replication subsystem immediately streams that data to the
tier-2 historian for simple replication, or performs summary
calculations and streams the resulting summaries.
This happens equally efficiently for tag values of timestamps close to
the current system time and for late data tags.
Queued Replication
Queued replication is used for scenarios in which streaming
replication is not appropriate, such as the following:
• An interruption occurs in the tier-1 data stream, such as when a
remote IDAS configured for store-and-forward cannot
communicate with the tier-1 historian for a long period of time.
When the connection is restored and the store-and-forward data
finally arrives at the tier-1 historian, it may be already streaming
newer data.
• An insert, update, or CSV file import operation could be performed
for tier-1 tag values, so the summaries should be recalculated for
that time period and re-replicated to the tier-2 historian.
• If the tier-1 historian is started or stopped, and there are some
summaries spanning across the startup/shutdown time that must
be recalculated and re-replicated to the tier-2 historian.
In such cases, the replication subsystem receives notifications from the
manual data storage service that contain information about what kind
of tier-1 tag data (original or latest) has changed for a particular time
interval. Then the replication subsystem places that notification
record into the replication queue stored in the Runtime database of the
tier-1 historian. Later, when the connection to the tier-2 historian is
restored, the replication subsystem processes that queue by querying
the tier-1 data and replicating it to the tier-2 historian. As soon as a
queue item is successfully processed, it is removed from the replication
queue.
Although the replication subsystem optimizes the queue by combining
adjacent records, queued replication is slower and requires more
system resources as compared to streamed replication, because it
involves querying tier-1 data already stored on disk.
Queued replication does not support data values with timestamps
before the year 1970.
Replication Latency
Replication latency is the time it takes for the system to make a value
available for retrieval on tier-2 from the moment it was stored or
calculated on tier-1.
Replication latency depends primarily on whether the streaming or
queued replication method is being applied in each particular case and
the available system resources to execute that method in each
particular case.
Streaming replication tends to have a shorter latency period than
queued replication as it deals with smaller amounts of data and is
processed at a higher priority.
Continuous Operation
If a tier-2 historian becomes unavailable and is configured for
store-and-forward operations, you can still add, modify and delete
replication and summary objects in the local configuration of tier-1,
and store data locally for tier-2 tags created before tier-2 became
unavailable or while it is still unavailable.
After the tier-2 historian is available, the Replication Service
compares the latest replication and summary objects with the tier-2
tags currently existing on the tier-2 historian and performs a dynamic
reconfiguration to ensure all data is synchronized. The reconfiguration
history that was stored locally is also sent to the tier-2 historian and
merged into its history. It will appear as though the disconnection
between the tiers never took place.
Overflow Protection
If the tier-2 historian is unable to handle the incoming data from the
tier-1 historian, the Replication Service detects the situation and
switches into store-and-forward mode, where the data gets
accumulated locally until the storage limit is reached. If the limit is
reached, all data to be sent to the tier-2 historian gets discarded and
an error message is logged.
Chapter 11
Event Subsystem
Plant events range from startups and shutdowns, through trips and
shift changes, to batch events and operator actions.
You can use the Wonderware Historian event subsystem to detect
events and associate actions when they are detected. At a basic level,
anything that can be determined by examining stored data can be used
as an event. The event subsystem can be configured to periodically
check to see if an event occurred. This is called event detection. A
subsequent action can then be triggered after an event is detected.
However, there is no guarantee of immediacy for actions; in fact, other
mechanisms can preempt actions under certain circumstances.
For the historian, event storage encapsulates more than just the fact
that something happened. An event is the set of attributes describing
the moment a detection criterion is met on historical tag values in the
historian. Attributes of an event include the date and time that the
event occurred in history and the date and time that it was detected.
Records of detected events can be logged to the database regardless of
whether or not any configured actions are subsequently initiated. In
other words, sometimes it may be desirable to simply log the fact that
an event occurred without initiating an action. The opposite may be
true, as well.
Component Description
Configuration Editor Part of the System Management Console. Used to specify event
definitions and possible actions.
Runtime database Stores event definition information and all data generated by the
event subsystem, such as records of event detections, data
summaries, and data snapshots.
Event System Service Internal process that coordinates event detection and action
(aahEventSvc.exe) functions. This process runs as a Windows service. Using the System
Management Console, you can configure the event service to
automatically start and stop at the same time as the Wonderware
Historian. The event service is responsible for:
• Reading event definition information from the Runtime database.
• Creating event detectors and actions, including allocating the
necessary processing threads and establishing database
connections.
• Initiating the event detection cycle.
SQL variables Available for use in event queries.
Event Tags
An event tag is a name for an event definition in the system. For
example, if you want to detect an event when a tank temperature
reaches 100 degrees, you can define an event tag and name it
"TankAt100." Event tags differ from the other tag types in the
Wonderware Historian (analog, discrete, and string). Analog, discrete,
and string tag types are the definitions of variables to be stored. In
contrast, an event tag is a named reference for the definition of the
specific event you want to detect, including an optional action to
perform when the event is detected. An event tag provides a way to
reference all event definition information in the system.
Event tags are created and maintained using the System Management
Console. When you define an event tag, you must specify:
• A name, description, and other general configuration information.
• The event criteria, which describes the conditions that must exist
for the event and how often the event subsystem checks to see if an
event occurred.
• Whether or not to log the event detection.
• Whether or not to enable or disable event detection.
• An optional action that is triggered when an event is detected.
Event Detectors
Each event tag must have an associated event detector. An event
detector is a mechanism for determining when the set of event criteria
for an event tag has been satisfied. When you configure an event
detector, you must first configure its type and then configure the
parameters associated with that detector type. You can choose from
the following types of event detectors:
• SQL-Based Detectors
• Schedule Detectors
• External Detectors
The generic SQL, analog specific value, and discrete specific value
detectors are SQL-based detectors. The schedule detector is a
time-based detector. The external detector is used when triggering an
event by the ActiveEvent ActiveX control.
For all detectors, the event subsystem will initially base the query for
data in history at the time the event subsystem starts. Subsequently,
the event subsystem will base the query on the last successful
detection; that is, the time of the most recent detection becomes the
starting time for the next detection.
SQL-Based Detectors
Analog specific value, discrete specific value, and generic SQL
detectors operate on data stored in the database. The detection criteria
for each of these detectors is a SQL statement that is executed against
the Wonderware Historian. Generic SQL detectors can query against
both the historian and Microsoft SQL Server.
Schedule Detectors
The schedule detector is a time-based detector. A schedule detector
detects whether the system clock is equal to or greater than a specific
date and/or time. For example, you could log an event every week on
Monday at 2:00 p.m.
Schedule detectors are different from other detectors in that they are
real-time detectors. The value of the system clock is checked every
second. Schedule detectors are very fast and can be used without great
concern about efficiency. Thus, a schedule detector provides the only
real-time event processing. However, there is no guarantee of when
the action will occur.
All of the schedule detectors that you set up are handled by a
dedicated scheduling thread. This allows for a separation between the
processing load needed to execute schedule detectors and the
processing load needed to perform all of the other event work. The
scheduling thread will maintain a list of detection times in a time
queue. If you add a schedule detector, the thread will register the
detection time in the queue and then re-sort the list of all detection
times from the earliest to the latest.
The time of the system clock is then compared with the time of the first
item in the schedule queue. If the system clock time is equal to or
greater than the time of the first item, the detection algorithm for the
first item will be invoked and the detection will be performed.
The event subsystem does not account for Daylight Savings Time
changes. If you set up a schedule detector that runs periodically with a
specified start time, you will need to change the start time to reflect
the time change. Another solution would be to use the time-weighted
average retrieval mode instead of the event subsystem to generate
averages, because the retrieval mode handles the Daylight Savings
Time changes. However, if the period for the average is hourly, then it
is recommended that you use the event subsystem, as the amount of
data will not generally not be a factor in the speed of calculating the
average.
External Detectors
For an external detector, event detection is triggered from an external
source by the ActiveEvent ActiveX control that is provided as part of
the Wonderware Historian. For example, an InTouch or Visual Basic
script can invoke the necessary ActiveEvent methods to trigger an
event. This ActiveX control must be installed on the computer from
which you want to trigger the external event.
For more information, see Configuring an External Detector in
Chapter 11, Configuring Events, in the Historian Database Reference.
Event Actions
An event may or may not be associated with an event action. An event
action is triggered after the event detector determines that the event
has occurred. The event subsystem is not intended to run external
processes. There is only a very limited ability to run external program
files or to call methods from COM interfaces within the given system
or network.
Actions are not required; there are times when you may want to
simply store when events happened. In this case, you would select
"None" for the action type when defining the event tag.
Snapshot Actions
A snapshot action logs into dedicated SQL Server tables the data
values for selected analog, discrete, or string tags that have the same
timestamp as the detected event. Quality is also logged. Value
snapshots are stored in tables according to the tag type, either
AnalogSnapshot, DiscreteSnapshot, or StringSnapshot.
A snapshot action requires an expensive SQL join between the
extension tables and the snapshot tag table. The process of performing
the join and logging the retrieved results to the snapshot tables can be
very slow. This is because most of the tables used for event snapshots
are normal SQL Server tables, subject to the data processing
limitations of Microsoft SQL Server. Thus, the higher the number of
snapshots that are being taken by the event system, the higher the
transaction load on the Microsoft SQL Server.
E-mail Actions
An e-mail action sends a pre-configured Microsoft Exchange e-mail
message. Although e-mail actions are useful for sending non-critical
messages triggered by an event detection, these types of actions are
not to be used for alarm-type functionality. For e-mail notifications of
alarm situations, use an alarm system such as the SCADAlarm alarm
notification software.
Deadband Actions
A deadband action changes the time and/or value storage deadband for
one or more tags that are using delta storage. (Value deadbands only
apply to analog tags.) Deadband change actions are useful for
increasing data storage based on an event occurring. For example, an
event detector has detected that a boiler has tripped, you might want
to start saving the values of certain tags at a higher rate to help you
determine the cause of the trip.
Event deadbands only apply to tags that use classic storage.
Summary Actions
A summary action is a set of aggregation calculations to be performed
on a set of tags between a start time and an end time with a defined
resolution. When you configure a summary action, you must define the
type of aggregation you want to perform (called a summary operation)
and the analog tags that you want to be summarized. The event
subsystem performs average, minimum, maximum and sum
calculations on the basis of a specific event being detected.
Note: Summary actions using the event subsystem are retained for
backward compatibility. We recommend that you use the more robust
and flexible replication subsystem to perform data summaries. For
more information, see Chapter 10, "Replication Subsystem."
'HWHFWRU7KUHDG3RRO
7LPH,QWHUYDO
'HWHFWRUV
VLQJOHWKUHDG
7LPH,QWHUYDO
'HWHFWRUV
VLQJOHWKUHDG
7LPH,QWHUYDO1
'HWHFWRUV
VLQJOHWKUHDG
6FKHGXOH
VLQJOHWKUHDG 'HWHFWRUV
$FWLRQ7KUHDG3RRO
$FWLRQ3URFHVVRU
6LQJOH7KUHDG
&ULWLFDO4XHXH
$FWLRQ3URFHVVRU
6LQJOH7KUHDG
3RVW'HWHFWRU'HOD\4XHXH
$FWLRQ3URFHVVRU
6LQJOH7KUHDG
1RUPDO4XHXH
$FWLRQ3URFHVVRU
6LQJOH7KUHDG
Event Service 1
SQL-based detectors 1 per each time interval used
Schedule detectors 1
Action threads 4
• Detector overloads
A detector overload occurs when the system cannot process all of
the detectors in a timely manner. Detector overload is handled by
means of the detection window. This window is defined by the
difference between the current system time and the time of the last
detection. If the window grows larger than one hour, some
detections will be missed. This condition will be reported in the
error log.
• Action overloads
An action overload occurs when the system cannot process all of
the actions in a timely manner. Only actions assigned a normal
priority have overload protection. An action will not be loaded into
the normal queue by a detector if the earliest action currently
sitting in the queue has been there for an hour. (Basically, it is
assumed that the system has become so overloaded that it has not
had the resources to process a single action in the past hour.) This
prevents an accumulation of actions in the normal queue when the
system is unable to process them. The system will be allowed time
to recover, and actions will not start to be queued again until the
time difference between earliest and latest action in the queue is
less than 45 minutes (75 percent of the time limit). In short, when
the system becomes too overloaded, actions are not queued. This
condition is reported in the error log, but not for every single action
missed. The first one missed is reported, and thereafter, every
hundredth missed action will be logged.
There is no overload protection for critical actions, because these
types of actions should only be configured for a very small number
of critical events. There is also no overload protection for actions
that have been assigned a post-detector delay.
For more information on action priorities, see "Event Action Priorities"
on page 358. For more information on how actions are queued, see
"Action Thread Pooling" on page 360.
Index
Symbols service 43
< (less than) 296, 300, 302, 304, 308 sources of data 77
<= (less than or equal to) 296, 300, 301, 302, Transact-SQL 94
305 actions
> (greater than) 296, 298, 302, 304, 306, 308 See also event actions
>= (greater than or equal to) 296, 301, 302, active image 131
305, 306 about 130
automatic resizing 130
Numerics resizing 36
32-bit 114 retrieval 323
64-bit 114 storage 132
ActiveEvent 354
A ActiveX control 354
aaAdmin 30 aggregate functions 294
aadbo 30 aggregations 356
aaPower 30 AIAutoResize system parameter 36
aaUser 30 AIResizeInterval system parameter 36
acquisition alarm system 347
about 17 AllowOriginals system parameter 36
components 78 alternate storage location 116, 117
CSV data 99 analog specific value detector 351
I/O Servers 79 analog summary replication
IDASs 81 about 333
MDAS clients 98 analog tags
quality 65 about 22
data quality 65 L
failover 90 late data 87
inserting original data 36 LateDataPathThreshold system
modification effects 75 parameter 38
redirecting to InTouch 91 latency 341
time synchronization 39, 91 event detections 352
IDASs leading edge detection 269, 270, 273, 275
about 81 LicenseRemoteIDASCount parameter 38
acquisition 78, 81 LicenseTagCount parameter 38
configuration information 81 licensing
data processing 82 remote IDASs 38
data transmission 83 tag count 38
error logging 84 LIKE clause 145
failover 86 linear interpolation 242
late data handling 87 linear scaling 137
licensing 38 linked server 140, 153
modification effects 75 Live table 139
performance 51 querying 278
security 83 log file
slow and intermittent networks 89 See system message logs
store-and-forward 84 logins
system tags 45 Windows 27
time synchronization 39, 40, 91 Wonderware Historian 30
importing Wonderware Historian services 33
Holding database 72
IN clause 145 M
indexing 43 Management Console
indexing service 133 security 33
INNER REMOTE JOIN 147, 283 ManualDataPathThreshold system
INSERT statements 94 parameter 38
InSQLIOS maximum retrieval mode 194
See Historian I/O Server maximum, retrieval modes 194
integral retrieval mode 200 MDAS
integral, retrieval modes 200 acquisition 78
intermittent network. 89 clients
interpolated, retrieval modes 171 acquisition 98
interpolation 38, 171 retrieval 137
interpolation type 241 time synchronization 93
InterpolationTypeInteger parameter 38 data quality 66
InterpolationTypeReal parameter 38 storage 126
InTouch memory
redirecting I/O Server data 91 management 133
InTouch History Importer 78 tag information 37
item name 80 Microsoft Query 152
Microsoft SQL Server
J integration 18
JOIN clause 146, 147, 283 security 28
minimum, retrieval modes 188