15. METODOLOGIA SDL (SECURITY DEVELOPMENT LIFECYCLE)
15.4. SEGUNDA FASE PROCEDIMIENTO DE DISEÑO
The purpose of the counter retrieval mode is to use a tag's rollover value to calculate and return the delta change between consecutive retrieval cycles. This retrieval mode is useful for determining how much of an item was produced during a particular time period. For example, you might have a counter that keeps track of how many cartons were produced. The carton counter would have an indicator such as this:
DateTime TagName Slope Quality QualityDetail
2005-04-17 08:00:00.000 ReactTemp 3.8110 133 192 2005-04-17 08:00:00.510 ReactTemp 3.8110 0 192 2005-04-17 08:00:01.713 ReactTemp 4.1563 0 192 2005-04-17 08:00:02.917 ReactTemp 4.1563 0 192 2005-04-17 08:00:04.230 ReactTemp 3.8081 0 192 2005-04-17 08:00:05.433 ReactTemp 4.1563 0 192 … … … 2005-04-17 08:01:16.743 ReactTemp -1.7517 0 192 2005-04-17 08:01:17.947 ReactTemp -27.0158 0 192 2005-04-17 08:01:17.947 ReactTemp NULL 1 17 2005-04-17 08:01:19.260 ReactTemp -1.7530 0 192 2005-04-17 08:01:20.463 ReactTemp -1.9119 0 192 2005-04-17 08:01:21.667 ReactTemp -1.9119 0 192 2005-04-17 08:01:22.977 ReactTemp -1.7517 0 192 … … …
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 would be 10,000. When the counter reaches the 9,999th value, the counter rolls back to 0.
To use the counter mode, set the following parameter in your query.
wwRetrievalMode = 'Counter'
The counter retrieval mode 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. Options for this retrieval mode include:
•
Specifying a timestamp rule.•
Specifying a quality rule.The counter algorithm is only applied to non-real analog tags and to discrete tags. If a query contains tags of other types, then no rows will be returned for those tags. For discrete tags, the rollover value is always assumed to be 2. The following illustration shows how the counter algorithm would determine the count for an analog tag.
This example has a start time of TC0 and an end time of TC3. The resolution
has been set in such a way that data will be returned 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 found and considered by the counter retrieval mode, but only the yellow ones are 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
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 that have occurred between the two points in time. The initial value to be returned at the query start time (PC1) is calculated the same way, only based
on a phantom cycle before the query start time. The counter algorithm will assume that a rollover occurred if the current value is lower than the previous value.
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 course of the cycle.
VR = the set 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.
The rules used to determine the OPCQuality returned with a counter value are the same as for a time weighted average query.
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.
If you have a counter that you typically reset manually before it rolls over, you will need to set the rollover value for the tag to 0 so that the count is simply how much change occurred since the manual reset.
For example, say that you have the following data values for five consecutive cycle boundaries, and that the value 0 occurs as the first value within the last cycle:
100, 110, 117, 123, 3
If you set the rollover value to 0, the counter retrieval mode assumes that the 0 following the value 123 represents a manual reset, and returns a value of 3, which would be the count after the manual reset. The value 0 itself does not contribute 1 to the counter value in this case.
If the rollover value is instead set to 200, then the counter retrieval mode assumes that the value 0 represents a normal rollover, and a count of 80 is calculated and returned. That is (200 - 123) + 3. In this case, the value 0 contributes 1 to the counter value, and that is the change from the value 199 to the value 200.