1

I'm trying out StreamInsight and I came across a problem with a query I need.

I'm trying to throw a warning if there are several changes in my measured values (of up to 20% change) in the last 30 minutes.

This is the query I came up with for now but it isn't working and it's not even correct I think.

Apparently I can't filter on a window...?

var deviationQuery = from s in wcfStream
                     group s by s.SensorId into grouped
                     from window in grouped.HoppingWindow(TimeSpan.FromMinutes(30),TimeSpan.FromMinutes(1))
                     where window.StdDev(e => e.Value) > measurableValue * 1.2
                     select new OutputEvent
                     {
                         Error = "Deviation"
                     };

Thanks in advance!

4

2 回答 2

1

我为我的问题找到了一个有效的查询。起初我认为它不起作用,但我误解了结果。这可能不是最短最好的查询,所以如果您有更好的答案,请告诉我!

var deviationQuery = from s in wcfStream
                     where s.Value > measurableValue * (1 + deviationThreshold) || s.Value < measurableValue * (1 - deviationThreshold)
                     group s by s.SensorId into grouped
                     from window in grouped.HoppingWindow(TimeSpan.FromSeconds(180), TimeSpan.FromSeconds(120))
                     select window.Count();
var deviation = from c in deviationQuery
                where c > maxIncorrectValues
                select new OutputEvent
                    {
                        M = new Measurement() { SensorId = "354354", Value = 53, Time = DateTime.Now },
                        Deflection = c,
                        Error = "Deviation"
                    };
于 2012-10-11T07:40:30.397 回答
1

如果我理解正确,这就是你想要做的:

  1. 按 对流进行分组SensorId
  2. 将每组分成 30 分钟的窗口。
  3. 为具有太多错误值的窗口编写错误消息。

这应该可以做到,希望如此。

var deviationQuery = from s in wcfStream
                     group s by s.SensorId into grouped
                     from window in grouped.HoppingWindow(TimeSpan.FromMinutes(30),TimeSpan.FromMinutes(1))
                     where window.Count(event => event.Value > maxValue) > maxIncorrectValues                        
                     select new OutputEvent
                     {
                         Error = "Deviation"
                     };
于 2012-10-10T14:57:22.607 回答