int IComparable.CompareTo(object obj) { int result = 0; try { FixParam param = obj as FixParam; if (param != null) { if (this.Priority < param.Priority) { result = -1; } else if (this.Priority > param.Priority) { result = 1; } return(result); } else { throw new NotSupportedException("类型不同,无法比较"); } } catch (Exception ex) { throw new Exception("比较异常", ex.InnerException); } }
private void CheckData(string targetCitFile) { _CorrResult.Clear(); //左半边数据点个数,包括中间点 foreach (var kvp in _fixedData) { int leftTargetCount = TargetSamplingCount + 1; long filePostion = _citProcess.GetCurrentPositionByMilestone(targetCitFile, kvp.Value[0].OriginalMileage, true); if (filePostion != -1) { long targetStartPostion = _citProcess.GetAppointEndPostion(targetCitFile, filePostion, -1 * leftTargetCount); long targetStartCount = _citProcess.GetSampleCountByRange(targetCitFile, targetStartPostion, filePostion); long targetEndPostion = _citProcess.GetAppointEndPostion(targetCitFile, filePostion, TargetSamplingCount); long targetEndCount = _citProcess.GetSampleCountByRange(targetCitFile, filePostion, targetEndPostion); List <CorrelationResult> correlationResult = new List <CorrelationResult>(); foreach (var item in _fixedData[kvp.Key]) { int index = -1; double lastValue = 0; double[] newArr = _citProcess.GetOneChannelDataInRange(targetCitFile, item.ChannelID, targetStartPostion, (int)(targetEndCount + targetStartCount)); double[] carr = new double[item.Points.Length]; for (int i = 0; i < newArr.Length - item.Points.Length; i++) { Array.Clear(carr, 0, carr.Length); Array.Copy(newArr, i, carr, 0, carr.Length); //double per = Correlation.Pearson(item.Points, carr); double per = correlationCalc(item.Points, carr); if (per > lastValue) { lastValue = per; index = i; } } FixParam key = FixParams.FirstOrDefault(p => p.ChannelID == item.ChannelID); CorrelationResult result = new CorrelationResult(); if (key != null && lastValue > key.ThreShold) { result.FilePointer = targetStartPostion + index + item.FixPostion; result.IsFind = true; result.ChannelID = key.ChannelID; result.ChannelName = key.ChannelName; } else { result.IsFind = false; } correlationResult.Add(result); } _CorrResult.Add(kvp.Key, correlationResult); } } }