Example #1
0
 void DataFrequencySpectrum_passPowerAndFreq(PowerAndFreq t)
 {
     if (m_UI_FrequencySpectrum != null && t != null)
     {
         m_UI_FrequencySpectrum.PushDataAttribute(t);
     }
     if (m_UI_WaterfallPlot != null && t != null)
     {
         m_UI_WaterfallPlot.PushDataAttribute(t);
     }
 }
        //频域显示参数LX
        public void PushDataAttribute(PowerAndFreq t)
        {
            double tScope1XAxisMin = (double)(t.StartFreq);
            double tScope1XAxisMax = (double)(t.StopFreq);

            try
            {
                scope1.BeginInvoke(new Action(() =>
                {
                    scope1.XAxis.Max.Tick.Value  = tScope1XAxisMax;
                    scope1.XAxis.MajorTicks.Step = 0.640 / t.Power.Length;
                    scope1.XAxis.Min.Tick.Value  = tScope1XAxisMin;
                }));
            }
            catch (Exception)
            {
            }
            PushFrequencyData(t.Power);
            Mark_max = t.Power.Max().ToString("0.00");
        }
Example #3
0
        public void PushDataAttribute(PowerAndFreq t)
        {
            double tScope1XAxisMin = t.StartFreq * 1000 - 70;
            double tScope1XAxisMax = (t.StartFreq + 0.5) * 1000 + 70 - 640 / t.Power.Length;

            try
            {
                waterfall1.BeginInvoke(new Action(() =>
                {
                    waterfall1.YAxis.Max.Tick.Value  = tScope1XAxisMax;
                    waterfall1.YAxis.MajorTicks.Step = 640 / t.Power.Length;
                    waterfall1.YAxis.Min.Tick.Value  = tScope1XAxisMin;
                }));
            }
            catch (Exception)
            {
            }


            PushData(t.Power);
        }
        //频域显示参数LX
        public void PushDataAttribute(PowerAndFreq t)
        {
            double tScope1XAxisMin = (double)(t.StartFreq);
            double tScope1XAxisMax = (double)(t.StopFreq);

            try
            {
                scope1.BeginInvoke(new Action(() =>
                {
                    scope1.XAxis.Max.Tick.Value  = tScope1XAxisMax;
                    scope1.XAxis.MajorTicks.Step = (t.StopFreq - t.StartFreq) / t.Power.Length;
                    scope1.XAxis.Min.Tick.Value  = tScope1XAxisMin;
                }));
            }
            catch (Exception)
            {
            }
            PushFrequencyData(t.Power);

            Mark_max = double.MinValue;
            int index = last_index;

            for (int i = 0; i < t.Power.Length; i++)
            {
                if (t.Power[i] > Mark_max)
                {
                    index    = i;
                    Mark_max = t.Power[i];
                }
            }
            if (Mark_max > -20 && Math.Abs(last_index - index) > 10)
            {
                last_index = index;
                checktime++;
            }
        }
        void m_queue_TEvent(DataAndFreq t)
        {
            double[] outData;
            outData = new double[t.m_Data.Length];
            int    mm_SmoothNum = m_SmoothNum;
            double offset       = 0;
            int    m_RFGain;
            int    m_DigitalGain;

            if (t.Type == 3)
            {
                Array.Copy(t.m_Data, 0, outData, 0, t.m_Data.Length);
                for (int k = 0; k < outData.Length; k++)
                {
                    IQdata[k][SmoothIndex] = outData[k];
                }
                offset = 0;
            }
            else
            {
                hdin  = GCHandle.Alloc(t.m_Data, GCHandleType.Pinned);
                hdout = GCHandle.Alloc(outData, GCHandleType.Pinned);
                dplan = fftw.dft_1d(t.m_Data.Length / 2, hdin.AddrOfPinnedObject(), hdout.AddrOfPinnedObject(), fftw_direction.Forward, fftw_flags.Measure);
                fftw.execute(dplan);
                fftw.destroy_plan(dplan);
                hdin.Free();
                hdout.Free();

                switch (t.NB_DataMode)
                {
                case DataAndFreq.NB_DATA_MODE.NB_MODE_IQ:
                case DataAndFreq.NB_DATA_MODE.NB_MODE_ISB:
                {
                    hdin  = GCHandle.Alloc(t.m_Data, GCHandleType.Pinned);
                    hdout = GCHandle.Alloc(outData, GCHandleType.Pinned);
                    dplan = fftw.dft_1d(t.m_Data.Length / 2, hdin.AddrOfPinnedObject(), hdout.AddrOfPinnedObject(), fftw_direction.Forward, fftw_flags.Measure);
                    fftw.execute(dplan);
                    fftw.destroy_plan(dplan);
                    hdin.Free();
                    hdout.Free();
                    break;
                }

                case DataAndFreq.NB_DATA_MODE.NB_MODE_AM:
                case DataAndFreq.NB_DATA_MODE.NB_MODE_USB:
                case DataAndFreq.NB_DATA_MODE.NB_MODE_CW:
                {
                    for (int k = outData.Length / 2 - 1; k >= 0; k--)
                    {
                        t.m_Data[2 * k]     = t.m_Data[k];
                        t.m_Data[2 * k + 1] = 0;
                    }
                    hdin  = GCHandle.Alloc(t.m_Data, GCHandleType.Pinned);
                    hdout = GCHandle.Alloc(outData, GCHandleType.Pinned);
                    dplan = fftw.dft_1d(t.m_Data.Length / 2, hdin.AddrOfPinnedObject(), hdout.AddrOfPinnedObject(), fftw_direction.Forward, fftw_flags.Measure);
                    fftw.execute(dplan);
                    fftw.destroy_plan(dplan);
                    hdin.Free();
                    hdout.Free();
                    break;
                }

                case DataAndFreq.NB_DATA_MODE.NB_MODE_LSB:
                {
                    for (int k = outData.Length / 2 - 1; k >= 0; k--)
                    {
                        t.m_Data[2 * k + 1] = t.m_Data[k];
                        t.m_Data[2 * k]     = 0;
                    }
                    hdin  = GCHandle.Alloc(t.m_Data, GCHandleType.Pinned);
                    hdout = GCHandle.Alloc(outData, GCHandleType.Pinned);
                    dplan = fftw.dft_1d(t.m_Data.Length / 2, hdin.AddrOfPinnedObject(), hdout.AddrOfPinnedObject(), fftw_direction.Forward, fftw_flags.Measure);
                    fftw.execute(dplan);
                    fftw.destroy_plan(dplan);
                    hdin.Free();
                    hdout.Free();
                    break;
                }

                default: break;
                }
                for (int k = 0; k < outData.Length / 2; k++)
                {
                    IQdata[k][SmoothIndex] = Math.Pow(Math.Pow(outData[k * 2], 2.0) + Math.Pow(outData[k * 2 + 1], 2.0), 0.5);
                }

                int Resolution_Offset = (int)(6 * (Math.Log(t.m_Data.Length, 2) - 10));
                if (t.Type == 2)
                {
                    offset = 133 - 7 + Resolution_Offset;
                }
                else if (t.Type == 1)
                {
                    offset = 133 - 3.14 + Resolution_Offset;
                }
            }

            double[] power = null;

            if (t.Type == 3)
            {
                power = new double[outData.Length];
                for (int i = 0; i < outData.Length; i++)
                {
                    double sum = 0;
                    for (int j = 0; j < mm_SmoothNum; j++)
                    {
                        sum += IQdata[i][j];
                    }
                    sum          /= mm_SmoothNum;
                    m_DigitalGain = 0; //Convert.ToInt32(t.Digital_Gain[i * 57 / outData.Length]);
                    m_RFGain      = 0; // Convert.ToInt32(t.RF_Gain[i / outData.Length]);
                    power[i]      = sum / 10 - offset;
                }
            }
            else if (t.Type == 2)
            {
                power = new double[outData.Length / 2];
                for (int i = 0; i < outData.Length / 2; i++)
                {
                    double sum = 0;
                    for (int j = 0; j < mm_SmoothNum; j++)
                    {
                        sum += IQdata[i][j];
                    }
                    sum          /= mm_SmoothNum;
                    m_DigitalGain = Convert.ToInt32(t.Digital_Gain[i * 40 / outData.Length]);
                    m_RFGain      = Convert.ToInt32(t.RF_Gain[0]);
                    power[i]      = Math.Log10(sum) * 20 - offset + m_DigitalGain + m_RFGain;
                }
            }
            else
            {
                power = new double[outData.Length / 2];
                for (int i = 0; i < outData.Length / 2; i++)
                {
                    double sum = 0;
                    for (int j = 0; j < mm_SmoothNum; j++)
                    {
                        sum += IQdata[i][j];
                    }
                    sum     /= mm_SmoothNum;
                    power[i] = Math.Log10(sum) * 20 - offset;
                }
            }

            //平滑处理
            if (++SmoothIndex >= mm_SmoothNum)
            {
                SmoothIndex = 0;
            }

            //数据传递
            PowerAndFreq nPowerAndFreq = new PowerAndFreq();

            power.Reverse <double>();//倒谱处理
            long powerLength = power.Length / 2;

            if (t.Type == 3)
            {
                nPowerAndFreq.Power = power;
            }
            else
            {
                nPowerAndFreq.Power = new double[power.Length];
                Array.Copy(power, powerLength, nPowerAndFreq.Power, 0, powerLength);
                Array.Copy(power, 0, nPowerAndFreq.Power, powerLength, powerLength);
            }

            switch (t.Type)
            {
            case 1:
            {
                nPowerAndFreq.StartFreq = t.StartFreq;
                nPowerAndFreq.StopFreq  = t.StopFreq;
                break;
            }

            case 2:
            {
                nPowerAndFreq.StartFreq = t.StartFreq - 0.07 - 0.640 / power.Length;
                nPowerAndFreq.StopFreq  = t.StopFreq + 0.07;
                break;
            }

            case 3:
            {
                nPowerAndFreq.StartFreq = t.StartFreq;
                nPowerAndFreq.StopFreq  = t.StopFreq;
                break;
            }
            }
            SaveFrequencySpectrum(nPowerAndFreq.Power);
            if (passPowerAndFreq != null)
            {
                passPowerAndFreq(nPowerAndFreq);
            }
        }
Example #6
0
        void m_queue_TEvent(IQDataAndFreq t)
        {
            double[] outData      = new double[t.Data.Length];
            int      mm_SmoothNum = m_SmoothNum;
            double   offset       = 0;
            int      m_RFGain;
            int      m_DigitalGain;

            if (t.Type == 3)
            {
                Array.Copy(t.Data, 0, outData, 0, t.Data.Length);
                for (int k = 0; k < outData.Length; k++)
                {
                    IQdata[k][SmoothIndex] = outData[k];
                }

                offset = 133 - 11.85;
            }
            else
            {
                hdin  = GCHandle.Alloc(t.Data, GCHandleType.Pinned);
                hdout = GCHandle.Alloc(outData, GCHandleType.Pinned);
                dplan = fftw.dft_1d(t.Data.Length / 2, hdin.AddrOfPinnedObject(), hdout.AddrOfPinnedObject(), fftw_direction.Forward, fftw_flags.Measure);
                fftw.execute(dplan);
                fftw.destroy_plan(dplan);
                hdin.Free();
                hdout.Free();
                for (int k = 0; k < outData.Length / 2; k++)
                {
                    double dou1 = Math.Pow(outData[k * 2], 2.0);
                    double dou2 = Math.Pow(outData[k * 2 + 1], 2.0);
                    double dou3 = dou1 + dou2;
                    IQdata[k][SmoothIndex] = Math.Pow(dou3, 0.5);
                }
                int Resolution_Offset = (int)(6 * (Math.Log(t.Data.Length, 2) - 10));
                if (t.Type == 2)
                {
                    offset = 133 - 7 + Resolution_Offset;
                }
                else if (t.Type == 1)
                {
                    offset = 133 + 8.63 + Resolution_Offset + (m_DataProcessing.DigitialGain_24db ? 24 : 0) + (m_DataProcessing.LowNoise ? 12 : 0);
                }
            }

            double[] power = null;

            if (t.Type == 3)
            {
                power = new double[outData.Length];
                for (int i = 0; i < outData.Length; i++)
                {
                    double sum = 0;
                    for (int j = 0; j < mm_SmoothNum; j++)
                    {
                        sum += IQdata[i][j];
                    }
                    sum          /= mm_SmoothNum;
                    m_DigitalGain = Convert.ToInt32(t.Digital_Gain[i * 57 / outData.Length]);
                    m_RFGain      = Convert.ToInt32(t.RF_Gain[i / outData.Length]);
                    power[i]      = sum / 10 - offset + m_DigitalGain + m_RFGain;
                }
            }
            else if (t.Type == 2)
            {
                power = new double[outData.Length / 2];
                for (int i = 0; i < outData.Length / 2; i++)
                {
                    double sum = 0;
                    for (int j = 0; j < mm_SmoothNum; j++)
                    {
                        sum += IQdata[i][j];
                    }
                    sum          /= mm_SmoothNum;
                    m_DigitalGain = Convert.ToInt32(t.Digital_Gain[i * 40 / outData.Length]);
                    m_RFGain      = Convert.ToInt32(t.RF_Gain[0]);
                    power[i]      = Math.Log10(sum) * 20 - offset + m_DigitalGain + m_RFGain;
                }
            }
            else
            {
                power = new double[outData.Length / 2];
                for (int i = 0; i < outData.Length / 2; i++)
                {
                    double sum = 0;
                    for (int j = 0; j < mm_SmoothNum; j++)
                    {
                        sum += IQdata[i][j];
                    }
                    sum     /= mm_SmoothNum;
                    power[i] = Math.Log10(sum) * 20 - offset;
                }
            }

            //平滑处理
            if (++SmoothIndex >= mm_SmoothNum)
            {
                SmoothIndex = 0;
            }

            //数据传递
            PowerAndFreq nPowerAndFreq = new PowerAndFreq();

            power.Reverse <double>();//倒谱处理
            long powerLength = power.Length / 2;

            if (t.Type == 3)
            {
                nPowerAndFreq.Power = power;
            }
            else
            {
                nPowerAndFreq.Power = new double[power.Length];
                Array.Copy(power, powerLength, nPowerAndFreq.Power, 0, powerLength);
                Array.Copy(power, 0, nPowerAndFreq.Power, powerLength, powerLength);
            }

            switch (t.Type)
            {
            case 1:
            {
                if (m_DataProcessing.nbddcbandwidth >= 1 && m_DataProcessing.nbddcbandwidth <= 6)
                {
                    double off = 0.00425 - (m_DataProcessing.nbddcbandwidth - 1) * 10 * 0.00005;
                    nPowerAndFreq.StartFreq = t.StartFreq - off;
                    nPowerAndFreq.StopFreq  = t.StopFreq + off;
                }
                else if (m_DataProcessing.nbddcbandwidth >= 9 && m_DataProcessing.nbddcbandwidth <= 15)
                {
                    double off = 0.005 - (m_DataProcessing.nbddcbandwidth - 9) * 0.0005;
                    nPowerAndFreq.StartFreq = t.StartFreq - off;
                    nPowerAndFreq.StopFreq  = t.StopFreq + off;
                }
                else if (m_DataProcessing.nbddcbandwidth == 30)
                {
                    nPowerAndFreq.StartFreq = t.StartFreq - 0.0089;
                    nPowerAndFreq.StopFreq  = t.StopFreq + 0.0089;
                }
                else if (m_DataProcessing.nbddcbandwidth == 50)
                {
                    nPowerAndFreq.StartFreq = t.StartFreq - 0.0228;
                    nPowerAndFreq.StopFreq  = t.StopFreq + 0.0228;
                }
                break;
            }

            case 2:
            {
                nPowerAndFreq.StartFreq = t.StartFreq - 0.07 - 0.640 / power.Length;
                nPowerAndFreq.StopFreq  = t.StopFreq + 0.07;
                break;
            }

            case 3:
            {
                nPowerAndFreq.StartFreq = t.StartFreq;
                nPowerAndFreq.StopFreq  = t.StopFreq;
                break;
            }
            }
            SaveFrequencySpectrum(nPowerAndFreq.Power);
            if (passPowerAndFreq != null)
            {
                passPowerAndFreq(nPowerAndFreq);
            }
        }