Leading edge detection for discrete tags
- Last UpdatedFeb 06, 2025
- 2 minute read
If Leading is specified as the parameter in the edge detection time domain extension, the only rows in the result set are those that are the first to successfully meet the WHERE clause criteria (returned true) after a row did not successfully meet the WHERE clause criteria (returned false).
The following queries select values of "SysPulse" and "MyPulse" that have a value of 1 (On) from the History and WideHistory tables between 12:59 and 1:04 a.m. on December 8, 2001.
This example queries 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'
The results are:
|
DateTime |
TagName |
Value |
|---|---|---|
|
2001-12-08 00:01:00.000 |
SysPulse |
1 |
|
2001-12-08 00:01:00.000 |
MyPulse |
1 |
|
2001-12-08 00:02:20.000 |
MyPulse |
1 |
|
2001-12-08 00:03:00.000 |
SysPulse |
1 |
|
2001-12-08 00:03:40.000 |
MyPulse |
1 |
This example queries 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"
')
The results are:
|
DateTime |
SysPulse |
MyPulse |
|---|---|---|
|
2001-12-08 00:01:00.000 |
1 |
1 |
|
2001-12-08 00:03:40.000 |
1 |
1 |
Compare these results with the same query using no edge detection, as shown in Edge detection for discrete tags. 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.