private void InsertDate(AnalysisValue value) { value.IsValid = true; value.ValidValue = value.RawValue; _windowDatas.Add(value); }
/// <summary> /// 初始化稳定窗口 /// </summary> /// <param name="seed"></param> //public void ReCreateWindow(decimal seed) //{ // if (seed == SeedInit) // { // } // _windowDatas.Clear(); // for (var i = 0; i < _windowSize; i++) // { // _windowDatas.Add(new AnalysisValue(seed)); // } //} /// <summary> /// 过滤数据 /// </summary> /// <param name="value"></param> public void ProcessValue(AnalysisValue value) { if (IsOpenWindow) { _log.Debug(ToSimpleString()); } if (value == null) { return; } //复制一份放在窗口里面 var tempValue = new AnalysisValue(value.RawValue, value.IsValid); tempValue.ValidValue = tempValue.RawValue; //未过滤之前数据就是原始值 value.ValidValue = value.RawValue; try { //考虑到先对数据过滤,后面又暂停了! if (!IsOpenWindow) { if (_windowDatas.Count < _windowSize) { InsertDate(tempValue); } else { RemoveInsertData(tempValue); } return; } if (_windowDatas.Count == _windowSize && _windowDatas.Count > 0) //窗口已满,有数据 { //包含了窗口和变异系数的变化 if (R == Rinitvalue) { R = ValidateWindow.CalcRValue(RawValues, KThreshold); //初始化 } if (ValidateValue(tempValue) == false) //值无效 { value.IsValid = tempValue.IsValid; value.ValidValue = tempValue.ValidValue; if (_invalidCount++ >= ReCalcRValueThreshold) { RebuildWindow(); } } //调整位置 var cv = ValidateWindow.GetCoefficientOfVariationValue(ValidValues); if (cv > KThreshold) { R = ValidateWindow.CalcRValue(RawValues, KThreshold); //初始化 } if (NeedLog) { //打印出数据 _log.Debug(this.ToString()); _log.Debug(tempValue.ToString()); } } else //窗口未满 { InsertDate(tempValue); } } catch (UnStableWindowExcepiton ex) { //不稳定怎么处理--继续滑动窗口 RemoveInsertData(tempValue); } //Dump(null, null); }