Quality rule - query 6
- Last UpdatedFeb 07, 2025
- 1 minute read
For RoundTrip, StateSummary, and ValueState modes, the OPC qualities are only combined with the same state in a cycle. If the state only occurs once in a cycle, then the qualities of that state will be returned. The returned NULL state will always have an OPC quality of 0 and Quality Detail of 65536. The same qualities are returned for a state that has no roundtrip in RoundTrip mode.
SELECT TagName, DateTime, Value, QualityDetail, OPCQuality, StateTime
FROM History
WHERE TagName = 'I001'
AND DateTime >= '2009-09-12 00:20'
AND DateTime <= '2009-09-12 00:40'
AND wwResolution = 10000
AND wwRetrievalMode = 'RoundTrip'
AND wwStateCalc = 'MaxContained'
If you run this query against the following sample data:
|
Tagname |
DateTime |
Resolution |
QualityDetail |
|---|---|---|---|
|
I001 |
2009-09-12 00:12 |
1 |
90 |
|
I001 |
2009-09-12 00:15 |
2 |
65 |
|
I001 |
2009-09-12 00:22 |
1 |
85 |
|
I001 |
2009-09-12 00:23 |
2 |
75 |
|
I001 |
2009-09-12 00:26 |
1 |
75 |
|
I001 |
2009-09-12 00:29 |
2 |
70 |
The results are:
|
Tagname |
DateTime |
Value |
QualityDetail |
OPC-Quality |
StateTime |
|---|---|---|---|---|---|
|
I001 |
2009-09-12 00:20 |
NULL |
65536 |
0 |
NULL |
|
I001 |
2009-09-12 00:20 |
1.0 |
90 |
90 |
NULL |
|
I001 |
2009-09-12 00:20 |
2.0 |
65 |
65 |
NULL |
|
I001 |
2009-09-12 00:20 |
1.0 |
64 |
64 |
4000 |
|
I001 |
2009-09-12 00:20 |
2.0 |
64 |
64 |
6000 |