Scenario 5: Calculate the total flow
- Last UpdatedMar 18, 2021
- 2 minute read
You can use the Integral retrieval feature to convert a rate into a quantity, such as totalizing a flow. For example, you can answer questions such as:
-
How much vanilla extract have we used in the last month to produce ice cream?
-
How much orange soda did we bottle yesterday?
What is Integral Retrieval?
Integral retrieval calculates the values at retrieval cycle boundaries by integrating the graph described by the points stored for the tag. It works much like average retrieval, but also applies a scaling factor.
Integral retrieval mode is ideal for calculating volume for a particular tag. For example, if a data tag represents product flow in liters per second, you can use integral retrieval to retrieve the total product flow in liters during a given time period.
Integral retrieval returns one row for each tag in the query for each cycle. You can specify cycles using resolution or cycle count.
Integral retrieval works only with analog tags.
Using Integral Instead of Counter
Integral retrieval and counter retrieval both deal in rates and quantities, but in different ways:
-
Counter retrieval converts a total quantity measurement into a rate.
For example, counter retrieval can take liters and a rate of 60000 to determine a rate in liters per minute.
-
Integral retrieval converts a rate measurement into a quantity.
For example, a rate in liters per minute can be translated into total liters for a given period.
Example: Calculating the Total Flow with Integral Retrieval
To use the integral retrieval mode, set the following parameter in your query:
wwRetrievalMode = 'Integral'
In this example, the value is computed for each of five one-minute cycles. The wwQualityRule parameter ensures that only points with good quality are used in the computation; data points with doubtful quality are discarded.
SELECT DateTime, TagName, Value, OPCQuality, PercentGood
FROM History
WHERE TagName like 'Flow1.PV'
AND DateTime >= '2015-09-24 12:00'
AND DateTime < '2015-09-25 8:00'
AND wwRetrievalMode = 'Integral'
AND wwCycleCount = 6
AND wwQualityRule = 'Good'
The results of this query are:
|
DateTime |
TagName |
Value |
OPCQuality |
PercentGood |
|---|---|---|---|---|
|
2015-09-24 12:00:00.000 |
Flow1.PV |
15820.7228325108 |
192 |
100.0 |
|
2015-09-24 16:00:00.000 |
Flow1.PV |
7776.62767927986 |
192 |
100.0 |
|
2015-09-24 20:00:00.000 |
Flow1.PV |
14535.3472187875 |
192 |
79.0 |
|
2015-09-25 00:00:00.000 |
Flow1.PV |
17058.0302965352 |
192 |
100.0 |
|
2015-09-25 04:00:00.000 |
Flow1.PV |
18737.2427425968 |
192 |
100.0 |
The Value column shows the total flow for each 4-hour cycle. To calculate the total flow for the entire period, add the flow values together.