Home : Products : Hach WIMS : Interfaces : Hach WIMS Direct Server-Side Interface to Wonderware Historian (InSQL) : Documentation : Topics specific to the operation of this interface : Tech Notes
Q14153 - INFO: Tech Notes

Technical Notes

Retrieval Mode

Starting in v1.2.4, the interface uses different retrieval modes based on the stat that is requested.  For average, retrieval mode 'average' is used.  From the Wonderware Historian Concepts Guide:

"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

For a time-weighted average, values are multiplied by the time difference between the points to determine the time-weighted value. Therefore, the longer a tag had a particular value, the more weight that value holds in the overall average. The overall average is determined by adding all of the time-weighted values and then dividing that number by the total amount of time.  Which values are weighted depends on the interpolation setting of the tag. For a tag that uses linear interpolation, the midpoints between values are weighted. For a tag that uses stair-step interpolation, the earlier of two values is weighted.  For the following data values of a tag that uses linear interpolation, the time-weighted average is computed as:

(((P1 + P2) / 2) x (T2 - T1)) + (((P2 + P3) / 2) x (T3 - T2)) + (((P3 + P4) / 2) x (T4 - T3)) / (T4 - T1) = Average

If the same tag uses stair-step interpolation, the time-weighted average is:

((P1 x (T2 - T1)) + (P2 x (T3 - T2)) + (P3 x (T4 - T3))) / (T4 - T1) = Average

Filtering

When a Filter Tag is used, the interface uses cyclic retrieval to pull data every minute for both the Tag and the Filter Tag. 

According to the Wonderware Historian Concepts Guide:

"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."

The following illustration shows how values are returned for cyclic retrieval:
Data is retrieved in cyclic mode with a start time of TCO 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

Refer to your Wonderware Historian Concepts Guide for more information on retrieval mode.

Example Query to get the average for a day for a Tag:

select Avg(Value) from dbo.History
where TagName = 'ETP_RW_FlowTotal.FlowTotalOS' AND value is not null
AND wwRetrievalMode = 'Cyclic' AND wwRowCount = 1440
AND DateTime >= '2011-01-04 00:00:00' AND DateTime < '2011-01-05 00:00:00'

Notice the wwRowCount = 1440.  This means we are retrieving data once a minute for the day (there are 1440 minutes in a day - 24 hours * 60 minutes/hour) and taking the average of those values.  The interface always retrieves data once a minute and performs the statistics on the minutely data (regardless if retrieving daily data, hourly, etc...)

 

 

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 9/26/2013 3:02 PM.
Last Modified on 11/4/2015 1:50 PM.
Last Modified by Scott Dorner.
Article has been viewed 6446 times.
Rated 0 out of 10 based on 0 votes.
Print Article
Email Article