Exemplo n.º 1
0
        //private void InitData()
        //{
        //    compareFreqs = new ComparableFreq[6];
        //    compareFreqs[0] = new ComparableFreq(18, 0, 2, "1");
        //    compareFreqs[1] = new ComparableFreq(19, 0, 2, "2");
        //    compareFreqs[2] = new ComparableFreq(20, 0, 2, "3");
        //    compareFreqs[3] = new ComparableFreq(20, 0, 4, "4");
        //    compareFreqs[4] = new ComparableFreq(21, 0, 2, "5");
        //    compareFreqs[5] = new ComparableFreq(22, 0, 4, "6");
        //    datagrid.ItemsSource = compareFreqs;

        //    calcFreqs = new ComparableFreq[1];
        //    calcFreqs[0] = new ComparableFreq(20, 0, 2, "1");

        //    //互调干扰数据源
        //    //接收  new EMCGeographyCoordinate(109, 36.01)
        //    receivers = new Receiver[1];
        //    receivers[0] = new Receiver("1",
        //        new ComparableFreq(30, 0,2, "1"),
        //        new ReceiverParams()
        //        {
        //            TuningRangeStart = new EMCFreqValue(EMCFreqUnitEnum.MHZ, 8),
        //            TuningRangeEnd = new EMCFreqValue(EMCFreqUnitEnum.MHZ, 32),
        //            IFBand = new EMCFreqValue(EMCFreqUnitEnum.MHZ, 4),
        //            Sensitivity = -1000,
        //            SensitivityUnit = SensitivityUnitEnum.dBm

        //        }, null );

        //    //发射 new EMCGeographyCoordinate(109, 36)
        //    transmitters = new Transmitter[4];

        //    transmitters[0] = new Transmitter("4", new ComparableFreq(10, 2, "2"),
        //        new TransmitterParams()
        //        {
        //            TuningRangeStart = new EMCFreqValue(EMCFreqUnitEnum.MHZ, 9),
        //            TuningRangeEnd = new EMCFreqValue(EMCFreqUnitEnum.MHZ, 15),
        //            Power = new EMCPowerValue(EMCPowerUnitEnum.W, 10)
        //        }, null
        //        );

        //    transmitters[1] = new Transmitter("5", new ComparableFreq(15, 2, "1"),
        //        new TransmitterParams()
        //        {
        //            TuningRangeStart = new EMCFreqValue(EMCFreqUnitEnum.MHZ, 10),
        //            TuningRangeEnd = new EMCFreqValue(EMCFreqUnitEnum.MHZ, 18),
        //            Power = new EMCPowerValue(EMCPowerUnitEnum.W, 10)
        //        }, null);

        //    transmitters[2] = new Transmitter("6", new ComparableFreq(20, 2, "1"),
        //        new TransmitterParams()
        //        {
        //            TuningRangeStart = new EMCFreqValue(EMCFreqUnitEnum.MHZ, 19),
        //            TuningRangeEnd = new EMCFreqValue(EMCFreqUnitEnum.MHZ, 22),
        //            Power = new EMCPowerValue(EMCPowerUnitEnum.W, 10)
        //        },
        //       null);

        //    transmitters[3] = new Transmitter("7", new ComparableFreq(40, 2, "2"),
        //       new TransmitterParams()
        //       {
        //           TuningRangeStart = new EMCFreqValue(EMCFreqUnitEnum.MHZ, 35),
        //           TuningRangeEnd = new EMCFreqValue(EMCFreqUnitEnum.MHZ, 45),
        //           Power = new EMCPowerValue(EMCPowerUnitEnum.W, 10)
        //       },
        //       null);

        //    transdatagrid.ItemsSource = transmitters;

        //}

        /// <summary>
        /// 同频计算
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnSameFreq_Click(object sender, RoutedEventArgs e)
        {
            //AnalysisType analysisType = AnalysisType.None ;
            //InterferenceAnalysisResult result = InterferenceAnalysis.Calculator(analysisType,compareFreqs, transmitters, receivers);

            this.samefreqresult.Text = null;
            SameFreqCalculator samefreqCalc = new SameFreqCalculator(calcFreqs, compareFreqs);

            SameFreqCompareResult[] samecompareResult = samefreqCalc.CalcSameFreqInterference();

            StringBuilder strmsg = new StringBuilder();

            if (samecompareResult != null && samecompareResult.Length > 0)
            {
                for (int i = 0; i < samecompareResult.Length; i++)
                {
                    SameFreqCompareResult sameresult = samecompareResult[i];
                    ComparableFreq        ifreq      = sameresult.Keys[0];
                    strmsg.AppendFormat("{0}:受干扰频率:ID:{1},频率:{2},带宽:{3} \r", i + 1, ifreq.FreqID, ifreq.Freq, ifreq.Band);
                    strmsg.Append("  干扰频率:");
                    string disfreq = string.Empty;
                    foreach (ComparableFreq item in sameresult.Values)
                    {
                        strmsg.AppendFormat("干扰频率:ID:{0},频率:{1},带宽:{2}\r", item.FreqID, item.Freq, item.Band);
                    }
                    strmsg.Append("\r");
                }
            }
            this.samefreqresult.Text = strmsg.ToString();
        }
        /// <summary>
        /// 向结果中添加同频结果
        /// </summary>
        /// <param name="freq">检索同频干扰关键字</param>
        /// <param name="disturbFreq">同频干扰频率 </param>
        private void AddSameFreqCompareResult(ComparableFreq freq, ComparableFreq disturbFreq, string interdescribe)
        {
            SameFreqCompareResult result;
            List <ComparableFreq> list;

            disturbFreq.InterfereResult = interdescribe;
            if (!this.resultList.TryGetValue(freq, out result))
            {
                if (this.dicFreqMapping.TryGetValue(freq, out list))
                {
                    ComparableFreq[] freqArray = new ComparableFreq[dicFreqMapping[freq].Count + 1];
                    freqArray[0] = freq;
                    dicFreqMapping[freq].CopyTo(freqArray, 1);
                    result = new SameFreqCompareResult(freqArray);
                }
                else
                {
                    result = new SameFreqCompareResult(freq);
                }

                this.resultList.Add(freq, result);
            }
            result.AddFreq(disturbFreq);
            if (this.dicFreqMapping.TryGetValue(disturbFreq, out list))
            {
                result.AddFreqRange(list.ToArray());
            }
        }