Working on a Barrier Breach Alert System
Today I've been working on a lot of ideas for a barrier breach alert - something where a data stream is coming into the system and you have set up a series of barriers defined by an expression - typically something like this:
value > (2.0*n + 1)*10000.0
where:
n = 0..5
so that the first barriers are actually at:
n | Expression |
0 | value > 100000.0 |
1 | value > 300000.0 |
2 | value > 500000.0 |
3 | value > 700000.0 |
4 | value > 900000.0 |
5 | value > 1100000.0 |
so now we have the barriers we'll be crossing through.
The trick is that when I cross any two barriers, I need to alert on the last one we crossed. So if we're going from 50,000 to 550,000 I want to alert on the 500,000 barrier not all the ones getting up to that value. Likewise, if I fall from 550,000 to 50,000 I need to alert on the 100,000 barrier not anything before that.
So we have to have an idea of direction of each barrier we're crossing, and we have to maintain a history of some sort to know what we crossed last, so as to know if we need to report on the crossing we're making right now.
This has been something I've been working on most of the day. Sadly, I do not, as yet, have a solution to the problem, but I'm sure I'll get something tomorrow.
[8/19] UPDATE: Yeah, I have something that seems to work rather nicely. I have two arrays of booleans - one for the previous state of all the barrier equations and another for the current state of the same equations. Then, I can compare the differences. If there's a difference, that's the "edge detection" we need. By looking at the values, we can tell if the current values are rising or falling.
Slick ideas that seem to be working nicely. Love this stuff.