protected override void Execute()
        {
            double dt = 1.0 / GlobalInfo.SampleRate;
            double fundmentalFrequency = 0, thd = 0;
            int    index;

            _configForm.GetChannelIndex(out index);
            if (index < 0)
            {
                DetailValues[0] = Utility.GetShowValue(Constants.NotAvailable, 0);
                DetailValues[1] = Utility.GetShowValue(Constants.NotAvailable, 0);
                return;
            }
            int harmonicLevel = _configForm.GetHarmonicLevel();

            if (_harmonicLevel?.Length != harmonicLevel + 1)
            {
                _harmonicLevel = new double[harmonicLevel + 1];
            }
            double[] waveform = this.DataBuf[index];
            HarmonicAnalyzer.ToneAnalysis(waveform, dt, out fundmentalFrequency, out thd, ref _harmonicLevel,
                                          harmonicLevel);

            DetailValues[0] = Utility.GetShowValue(thd, 0);
            DetailValues[1] = Utility.GetShowValue(fundmentalFrequency, 0);
        }
Esempio n. 2
0
        protected override void Execute()
        {
            int    samplesPerView = GlobalInfo.SamplesInChart;
            double dt = 1.0 / GlobalInfo.SampleRate;
            double fundmentalFrequency = 0, thd = 0;
            int    index;

            _configForm.GetChannelIndex(out index);
            if (index < 0)
            {
                return;
            }
            int harmonicLevel = _configForm.GetHarmonicLevel();

            if (_harmonicLevel?.Length != harmonicLevel)
            {
                _harmonicLevel = new double[harmonicLevel];
            }
            double[] waveform = DataBuf.GetRange(samplesPerView * index, samplesPerView).ToArray();
            HarmonicAnalyzer.ToneAnalysis(waveform, dt, out fundmentalFrequency, out thd, ref _harmonicLevel,
                                          harmonicLevel);

            DetailValues[0] = thd.ToString();
            DetailValues[1] = fundmentalFrequency.ToString();
        }
Esempio n. 3
0
 protected override void Execute()
 {
     for (int i = 0; i < DetailValues.Length; i++)
     {
         DetailValues[i] = "";
     }
     for (int i = 0; i < this.DataBuf.Count; i++)
     {
         ToneAnalysisResult result = HarmonicAnalyzer.ToneAnalysis(
             this.DataBuf[i], 1.0 / GlobalInfo.SampleRate);
         DetailValues[0] += Utility.GetShowValue(result.THD, i);
         DetailValues[1] += Utility.GetShowValue(result.THDplusN, i);
         DetailValues[2] += Utility.GetShowValue(result.SINAD, i);
         DetailValues[3] += Utility.GetShowValue(result.SNR, i);
         DetailValues[4] += Utility.GetShowValue(result.NoiseFloor, i);
         DetailValues[5] += Utility.GetShowValue(result.ENOB, i);
     }
 }