Пример #1
0
        public double filter(double x0, IIRFilter iirfilter)
        {
            double y = iirfilter.a0 * x0 + iirfilter.a1 * iirfilter.x1 + iirfilter.a2 * iirfilter.x2 + iirfilter.b1 * iirfilter.y1 + iirfilter.b2 * iirfilter.y2;

            iirfilter.x2 = iirfilter.x1;
            iirfilter.x1 = x0;
            iirfilter.y2 = iirfilter.y1;
            iirfilter.y1 = y;

            return(y);
        }
Пример #2
0
        private void btnConectionPort_Click(object sender, EventArgs e)
        {
            //if (this.logger is null)
            //{
            //    string comPort = this.cmbComPort.SelectedItem.ToString();
            //    this.logger = new SerialDataLogger(comPort, channelCount: 1);
            //    this.btnConectionPort.Text = "Close";
            //}
            //else
            //{
            //    this.logger.Dispose();
            //    this.logger = null;
            //    this.cmbComPort.Text = "Open";
            //}
#if DEBUG
            if (this.btnConectionPort.Text == "Open")
            {
                string comPort = this.cmbComPort.SelectedItem.ToString();
                this.ssd = new SerialSignalData(comPort, baudRate: 115200);
                this.btnConectionPort.Text             = "Close";
                this.tmrTimeSeriesGraphRender.Enabled  = true;
                this.tmrSpectrogramGraphRender.Enabled = true;

                this.Notch50 = new IIRFilter(int.Parse(this.cmbSampleRate.SelectedItem.ToString()), 50, 5);

                this.spectrogram          = new Spectrogram.Spectrogram(128, 128, 25);
                this.pbSpectrogram.Height = this.spectrogram.Height;

                this.pbScaleVert.Image?.Dispose();
                this.pbScaleVert.Image  = this.spectrogram.GetVerticalScale(this.pbScaleVert.Width);
                this.pbScaleVert.Height = this.spectrogram.Height;
            }
            else
            {
                this.btnConectionPort.Text             = "Open";
                this.tmrTimeSeriesGraphRender.Enabled  = false;
                this.tmrSpectrogramGraphRender.Enabled = false;
            }
#else
            Console.WriteLine("Mode=Other");
#endif
        }