private void delete_freqNavBar_Click(object sender, RoutedEventArgs e) { FreqNavBar objNavBar = (FreqNavBar)this; NavBarItem objNavItem = (NavBarItem)objNavBar.Parent; NavBarGroup objNavGroup = (NavBarGroup)objNavItem.Parent; NavBarControl nbc = (NavBarControl)objNavGroup.Parent; nbc.Groups.Remove(objNavGroup); }
/// <summary> /// 电磁信号与台站信息比对 /// </summary> /// <param name="dicOccupy"></param> private void compareStationInfoForAll(List <AnalysisResult> dicOccupy, FreqNavBar navBar) { List <ActivitySurroundStation> stationBaseList = SQLiteDataService.QueryStatBaseByPlaceID(LoginService.CurrentActivityPlace.Guid); //modify by michael 17.07.20 ObservableCollection <AnalysisResult> freqList = new ObservableCollection <AnalysisResult>(); Dictionary <string, ActivitySurroundStation> stationDic = new Dictionary <string, ActivitySurroundStation>(); int occuDegreeLimit = Convert.ToInt16(navBar.OccuDegreeLimit); int signalLimit = Convert.ToInt16(navBar.SignalLimit); foreach (AnalysisResult kv in dicOccupy) { AnalysisResult analysisResult = new AnalysisResult(); analysisResult.Id = Guid.NewGuid().ToString(); analysisResult.Frequency = Convert.ToDouble(kv.Frequency.ToString("0.0000")); //analysisResult.BandWidth = this.bandWidth; analysisResult.BandWidth = Double.Parse(navBar.BandWidth);; analysisResult.AnalysisBandWidth = Double.Parse(navBar.BandWidth);; analysisResult.AmplitudeMidValue = kv.AmplitudeMidValue; analysisResult.AmplitudeMaxValue = kv.AmplitudeMaxValue; analysisResult.Occupy = Convert.ToInt32(kv.Occupy); List <StationEmitInfo> tempList = new List <StationEmitInfo>(); foreach (ActivitySurroundStation sbe in stationBaseList) { tempList = sbe.EmitInfo.Where(x => (x.FreqEC - x.FreqBand / 1000) <= kv.Frequency && (x.FreqEC + x.FreqBand / 1000) >= kv.Frequency).ToList(); if (tempList.Count() > 0) { //analysisResult.FreqType = SignalTypeEnum.已占; analysisResult.StationName = sbe.STAT_NAME; analysisResult.StationGuid = sbe.STATGUID; analysisResult.NeedClear = (int)sbe.EmitInfo[0].NeedClear; analysisResult.FreqGuid = sbe.EmitInfo[0].Guid; analysisResult.ClearResult = (int)sbe.EmitInfo[0].ClearResult; if (!stationDic.Keys.Contains(sbe.STATGUID)) { stationDic.Add(sbe.STATGUID, sbe); } break; } else { //analysisResult.FreqType = SignalTypeEnum.空闲; } } if (analysisResult.Occupy >= occuDegreeLimit && analysisResult.AmplitudeMaxValue > signalLimit) { analysisResult.FreqType = SignalTypeEnum.已占; } else { analysisResult.FreqType = SignalTypeEnum.空闲; } analysisResult.MeasureId = MeasureId; analysisResult.StartFreq = Convert.ToDouble(navBar.FreqStart); analysisResult.EndFreq = Convert.ToDouble(navBar.FreqStop); analysisResult.FreqGuid = navBar.FreqGuid; freqList.Add(analysisResult); } foreach (ActivitySurroundStation sbe in stationBaseList) { if (stationDic.Keys.Contains(sbe.STATGUID)) { continue; } else { if (sbe.EmitInfo != null && sbe.EmitInfo.Count > 0) { AnalysisResult analysisResult = new AnalysisResult(); analysisResult.Id = Guid.NewGuid().ToString(); analysisResult.Frequency = Convert.ToDouble(sbe.EmitInfo[0].FreqEC.ToString()); //analysisResult.BandWidth = Convert.ToDouble((sbe.EmitInfo[0].FreqBand * 1000).ToString()); analysisResult.BandWidth = Convert.ToDouble((sbe.EmitInfo[0].FreqBand).ToString()); analysisResult.FreqGuid = sbe.EmitInfo[0].Guid; analysisResult.NeedClear = (int)sbe.EmitInfo[0].NeedClear; analysisResult.ClearResult = (int)sbe.EmitInfo[0].ClearResult; analysisResult.StationName = sbe.STAT_NAME; analysisResult.StationGuid = sbe.STATGUID; analysisResult.FreqType = SignalTypeEnum.已占; analysisResult.MeasureId = MeasureId; analysisResult.AnalysisBandWidth = Double.Parse(navBar.BandWidth); analysisResult.StartFreq = Convert.ToDouble(navBar.FreqStart); analysisResult.EndFreq = Convert.ToDouble(navBar.FreqStop); analysisResult.FreqGuid = navBar.FreqGuid; freqList.Add(analysisResult); } } } if (freqList.Count == 0) { initdata(freqList); } navBar.MeasureId = MeasureId; navBar.freqList = freqList; }
/// <summary> /// 生成占用度和最大值、均值数据 /// </summary> /// <param name="dicFreqStatModel">原始数据分析后统计数据</param> /// <param name="bandwidth"></param> private void ctrlStatDataForAll(Dictionary <double, FreqStatModel> dicFreqStatModel, FreqNavBar freqNavBar) { var listCreat = GetAnalysList(decimal.Parse(freqNavBar.FreqStart), decimal.Parse(freqNavBar.FreqStop), decimal.Parse(freqNavBar.BandWidth) / 1000); ChartSeriesPoints csps = new ChartSeriesPoints(); List <AnalysisResult> freqOccupancyDegreeDic = new List <AnalysisResult>(); int signalLimit = string.IsNullOrEmpty(freqNavBar.SignalLimit) ? 45 : Convert.ToInt16(freqNavBar.SignalLimit); int occuDegreeLimit = string.IsNullOrEmpty(freqNavBar.OccuDegreeLimit) ? 90 : Convert.ToInt16(freqNavBar.OccuDegreeLimit); if (listCreat != null) { PointPairList occupyValues = new PointPairList(); foreach (var item in listCreat) { double trueFreq = item.Frequency; double tempFreq; int occupyValueCount = 0; var list = dicFreqStatModel.Where((obj) => obj.Key >= item.StartFreq * 1000 && obj.Key < item.EndFreq * 1000).ToList(); List <AnalysisResult> tmpList = new List <AnalysisResult>(); PointPairList tmpOccupyValues = new PointPairList(); foreach (KeyValuePair <double, FreqStatModel> kvp in list) { PointPair spOccupy = new PointPair(); tempFreq = kvp.Key; int overSignalLimit = kvp.Value.DicAmplitudeCount.Where(x => x.Key > signalLimit).Select(x => x.Value).Sum(); int sum = kvp.Value.DicAmplitudeCount.Values.Sum(); double occpy = ((double)overSignalLimit / (double)sum) * 100; double maxValue = kvp.Value.DicAmplitudeCount.Keys.Max(); double AverageValue = kvp.Value.DicAmplitudeCount.Select(x => x.Key).Average(); spOccupy.X = tempFreq / 1000; spOccupy.Y = Convert.ToInt16(occpy); AnalysisResult tmpItem = Mapper <AnalysisResult, AnalysisResult>(item); tmpItem.Occupy = Convert.ToInt16(occpy); tmpItem.AmplitudeMidValue = Convert.ToInt16(AverageValue); tmpItem.AmplitudeMaxValue = Convert.ToInt16(maxValue); //如果不是第一次 if (occupyValueCount >= 1) { //如果占用度列表的上一个频率 + 带宽大于等于当前频率 if (tmpOccupyValues[occupyValueCount - 1].X + Convert.ToDouble(freqNavBar.BandWidth) / 1000 >= tempFreq / 1000) { //如果占用度列表的上一个占用度小于当前占用度 if (tmpOccupyValues[occupyValueCount - 1].Y < occpy) { //占用度列表的上一个占用度重新赋值 tmpOccupyValues[occupyValueCount - 1].X = tempFreq / 1000; tmpOccupyValues[occupyValueCount - 1].Y = occpy; //返回结果列表重新赋值 tmpList[occupyValueCount - 1].Frequency = tempFreq / 1000; tmpList[occupyValueCount - 1].Occupy = Convert.ToInt16(occpy); tmpList[occupyValueCount - 1].AmplitudeMidValue = Convert.ToInt16(AverageValue); tmpList[occupyValueCount - 1].AmplitudeMaxValue = Convert.ToInt16(maxValue); } } else { tmpOccupyValues.Add(spOccupy); tmpList.Add(tmpItem); occupyValueCount++; } } else { tmpOccupyValues.Add(spOccupy); tmpList.Add(tmpItem); occupyValueCount++; } } if (tmpList.Count > 0) { int occupyMax = tmpList.Max(obj => obj.Occupy); int amplitudeMax = tmpList.Max(obj => obj.AmplitudeMaxValue); int amplitudeMid = tmpList.Max(obj => obj.AmplitudeMidValue); item.Occupy = occupyMax; item.Frequency = trueFreq; item.AmplitudeMaxValue = amplitudeMax; item.AmplitudeMidValue = amplitudeMid; } freqOccupancyDegreeDic.Add(item); if (tmpOccupyValues.Count > 0) { var spOcp = new PointPair(); spOcp.X = trueFreq; spOcp.Y = tmpOccupyValues[0].Y; occupyValues.Add(spOcp); } } csps.OccupyPointPairList = occupyValues; } csps.MinFreq = Convert.ToDouble(freqNavBar.FreqStart); csps.MaxFreq = Convert.ToDouble(freqNavBar.FreqStop); csps.SignalLimit = signalLimit; csps.OccuDegreeLimit = occuDegreeLimit; //refreshChartFreqStatDelete(dicFreqStatModel, csps);//绘制统计图形 compareStationInfoForAll(freqOccupancyDegreeDic, freqNavBar); }
/// <summary> /// 生成占用度和最大值、均值数据 /// </summary> /// <param name="dicFreqStatModel">原始数据分析后统计数据</param> /// <param name="bandwidth"></param> private void ctrlStatData(Dictionary <double, FreqStatModel> dicFreqStatModel, FreqNavBar freqNavBar) { var listCreat = GetAnalysList(decimal.Parse(freqNavBar.FreqStart), decimal.Parse(freqNavBar.FreqStop), decimal.Parse(freqNavBar.BandWidth) / 1000); ChartSeriesPoints csps = new ChartSeriesPoints(); List <AnalysisResult> freqOccupancyDegreeDic = new List <AnalysisResult>(); int signalLimit = string.IsNullOrEmpty(freqNavBar.SignalLimit) ? 45 : Convert.ToInt16(freqNavBar.SignalLimit); int occuDegreeLimit = string.IsNullOrEmpty(freqNavBar.OccuDegreeLimit) ? 90 : Convert.ToInt16(freqNavBar.OccuDegreeLimit); if (listCreat != null) { //PointPairList maxValues = new PointPairList(); //PointPairList midValues = new PointPairList(); PointPairList occupyValues = new PointPairList(); foreach (var item in listCreat) { double trueFreq = item.Frequency; double tempFreq; int occupyValueCount = 0; var list = dicFreqStatModel.Where((obj) => obj.Key >= item.StartFreq * 1000 && obj.Key < item.EndFreq * 1000).ToList(); List <AnalysisResult> tmpList = new List <AnalysisResult>(); PointPairList tmpOccupyValues = new PointPairList(); foreach (KeyValuePair <double, FreqStatModel> kvp in list) { PointPair spOccupy = new PointPair(); tempFreq = kvp.Key; int overSignalLimit = kvp.Value.DicAmplitudeCount.Where(x => x.Key > signalLimit).Select(x => x.Value).Sum(); int sum = kvp.Value.DicAmplitudeCount.Values.Sum(); double occpy = ((double)overSignalLimit / (double)sum) * 100; double maxValue = kvp.Value.DicAmplitudeCount.Keys.Max(); double AverageValue = kvp.Value.DicAmplitudeCount.Select(x => x.Key).Average(); spOccupy.X = tempFreq / 1000; spOccupy.Y = Convert.ToInt16(occpy); AnalysisResult tmpItem = Mapper <AnalysisResult, AnalysisResult>(item); tmpItem.Occupy = Convert.ToInt16(occpy); tmpItem.AmplitudeMidValue = Convert.ToInt16(AverageValue); tmpItem.AmplitudeMaxValue = Convert.ToInt16(maxValue); //如果不是第一次 if (occupyValueCount >= 1) { //如果占用度列表的上一个频率 + 带宽大于等于当前频率 if (tmpOccupyValues[occupyValueCount - 1].X + Convert.ToDouble(freqNavBar.BandWidth) / 1000 >= tempFreq / 1000) { //如果占用度列表的上一个占用度小于当前占用度 if (tmpOccupyValues[occupyValueCount - 1].Y < occpy) { //占用度列表的上一个占用度重新赋值 tmpOccupyValues[occupyValueCount - 1].X = tempFreq / 1000; tmpOccupyValues[occupyValueCount - 1].Y = occpy; //返回结果列表重新赋值 tmpList[occupyValueCount - 1].Frequency = tempFreq / 1000; tmpList[occupyValueCount - 1].Occupy = Convert.ToInt16(occpy); tmpList[occupyValueCount - 1].AmplitudeMidValue = Convert.ToInt16(AverageValue); tmpList[occupyValueCount - 1].AmplitudeMaxValue = Convert.ToInt16(maxValue); } } else { tmpOccupyValues.Add(spOccupy); tmpList.Add(tmpItem); occupyValueCount++; } } else { tmpOccupyValues.Add(spOccupy); tmpList.Add(tmpItem); occupyValueCount++; } } if (tmpList.Count > 0) { int occupyMax = tmpList.Max(obj => obj.Occupy); int amplitudeMax = tmpList.Max(obj => obj.AmplitudeMaxValue); int amplitudeMid = tmpList.Max(obj => obj.AmplitudeMidValue); item.Occupy = occupyMax; item.Frequency = trueFreq; item.AmplitudeMaxValue = amplitudeMax; item.AmplitudeMidValue = amplitudeMid; } freqOccupancyDegreeDic.Add(item); if (tmpOccupyValues.Count > 0) { var spOcp = new PointPair(); spOcp.X = trueFreq; spOcp.Y = tmpOccupyValues[0].Y; occupyValues.Add(spOcp); } //occupyValues.Add(tmpOccupyValues); } csps.OccupyPointPairList = occupyValues; } #region 2016年10月26日修改 //if (dicFreqStatModel != null) //{ // //***** 1 // PointPairList maxValues = new PointPairList(); // PointPairList midValues = new PointPairList(); // PointPairList occupyValues = new PointPairList(); // //****** 2 // //SeriesPointCollection maxValues = new SeriesPointCollection(); // //SeriesPointCollection midValues = new SeriesPointCollection(); // //AmplitudeMaxValue = new List<short>(); // //AmplitudeAverageValue = new List<short>(); // double tempFreq; // int occupyValueCount = 0; // int Prec = GetPrec(decimal.Parse(freqNavBar.BandWidth) / 1000) + 1; // foreach (KeyValuePair<double, FreqStatModel> kvp in dicFreqStatModel) // { // //PointPair spMax = new PointPair(); // //PointPair spMid = new PointPair(); // PointPair spOccupy = new PointPair(); // //Visifire.Charts.DataPoint dpMax = new Visifire.Charts.DataPoint(); // //SeriesPoint spMax = new SeriesPoint(); // //SeriesPoint spMid = new SeriesPoint(); // tempFreq = kvp.Key; // int overSignalLimit = kvp.Value.DicAmplitudeCount.Where(x => x.Key > signalLimit).Select(x => x.Value).Sum(); // int sum = kvp.Value.DicAmplitudeCount.Values.Sum(); // double occpy = ((double)overSignalLimit / (double)sum) * 100; // double maxValue = kvp.Value.DicAmplitudeCount.Keys.Max(); // //AmplitudeMaxValue.Add(Convert.ToInt16(maxValue)); // //dpMax.XValue = tempFreq / 1000; // //dpMax.YValue = Convert.ToInt16(maxValue); // //spMax.X = tempFreq / 1000; // //spMax.Y = Convert.ToInt16(maxValue); // //maxValues.Add(spMax); // //maxPoints.Add(dpMax); // double AverageValue = kvp.Value.DicAmplitudeCount.Select(x => x.Key).Average(); // //spMid.X = tempFreq / 1000; // //spMid.Y = Convert.ToInt16(AverageValue); // //AmplitudeAverageValue.Add(Convert.ToInt16(AverageValue)); // //midValues.Add(spMid); // //if (occpy > occuDegreeLimit) // //{ // spOccupy.X = tempFreq / 1000; // spOccupy.Y = occpy; // AnalysisResult ar = new AnalysisResult(); // ar.Frequency = Math.Round(tempFreq / 1000, Prec); // ar.Occupy = Convert.ToInt16(occpy); // ar.AmplitudeMidValue = Convert.ToInt16(AverageValue); // ar.AmplitudeMaxValue = Convert.ToInt16(maxValue); // if (occupyValueCount >= 1) // { // if (occupyValues[occupyValueCount - 1].X + Convert.ToDouble(freqNavBar.BandWidth) / 1000 >= tempFreq / 1000) // { // if (occupyValues[occupyValueCount - 1].Y < occpy) // { // occupyValues[occupyValueCount - 1].X = tempFreq / 1000; // occupyValues[occupyValueCount - 1].Y = occpy; // freqOccupancyDegreeDic[occupyValueCount - 1].Frequency = tempFreq / 1000; // freqOccupancyDegreeDic[occupyValueCount - 1].Occupy = Convert.ToInt16(occpy); // freqOccupancyDegreeDic[occupyValueCount - 1].AmplitudeMidValue = Convert.ToInt16(AverageValue); // freqOccupancyDegreeDic[occupyValueCount - 1].AmplitudeMaxValue = Convert.ToInt16(maxValue); // } // } // else // { // occupyValues.Add(spOccupy); // freqOccupancyDegreeDic.Add(ar); // occupyValueCount++; // } // } // else // { // occupyValues.Add(spOccupy); // freqOccupancyDegreeDic.Add(ar); // occupyValueCount++; // } // } // //} // //csps.MaxPointPairList = maxValues; // //csps.MidPointPairList = midValues; // csps.OccupyPointPairList = occupyValues; //} #endregion csps.MinFreq = Convert.ToDouble(freqNavBar.FreqStart); csps.MaxFreq = Convert.ToDouble(freqNavBar.FreqStop); csps.SignalLimit = signalLimit; csps.OccuDegreeLimit = occuDegreeLimit; //refreshChartResultDelete(csps); refreshChartFreqStatDelete(dicFreqStatModel, csps); compareStationInfo(freqOccupancyDegreeDic); }