Ejemplo n.º 1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     data   = ScottPlot.DataGen.RandomWalk(rand, 10_000_000);
     signal = scottPlotUC1.plt.PlotSignalConst(data);
     scottPlotUC1.plt.Benchmark();
     scottPlotUC1.Render();
 }
Ejemplo n.º 2
0
        public FormIncomingData()
        {
            InitializeComponent();

            int dataPoints = 100 * 60 * 60; // 1hr of 100Hz data

            dataValues = new double[dataPoints];
            signal     = formsPlot1.plt.PlotSignal(dataValues, 100);
            formsPlot1.plt.Axis(-2, 35, -100, 300);
        }
Ejemplo n.º 3
0
        private void chart_pid_Load(object sender, EventArgs e)
        {
            this.plt_setpoint = this.chart_pid.plt.PlotSignal(this.plt_data_setpoint, label: "Setpoint");
            this.plt_feedback = this.chart_pid.plt.PlotSignal(this.plt_data_feedback, label: "Feedback");
            this.plt_setpoint.maxRenderIndex = 0;
            this.plt_feedback.maxRenderIndex = 0;

            this.chart_pid.plt.XLabel("Step (times)");
            this.chart_pid.plt.YLabel("Process Value");
            this.chart_pid.plt.Legend(location: ScottPlot.legendLocation.lowerLeft);
        }
Ejemplo n.º 4
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (lastBuffer is null)
            {
                return;
            }

            double[] window     = FftSharp.Window.Hanning(lastBuffer.Length);
            double[] windowed   = FftSharp.Window.Apply(window, lastBuffer);
            double[] zeroPadded = FftSharp.Pad.ZeroPad(windowed);
            double[] fftPower   = cbDecibel.Checked ?
                                  FftSharp.Transform.FFTpower(zeroPadded) :
                                  FftSharp.Transform.FFTmagnitude(zeroPadded);
            double[] fftFreq = FftSharp.Transform.FFTfreq(SAMPLE_RATE, fftPower.Length);

            // determine peak frequency
            double peakFreq  = 0;
            double peakPower = 0;

            for (int i = 0; i < fftPower.Length; i++)
            {
                if (fftPower[i] > peakPower)
                {
                    peakPower = fftPower[i];
                    peakFreq  = fftFreq[i];
                }
            }
            lblPeak.Text = $"Peak Frequency: {peakFreq:N0} Hz";

            formsPlot1.plt.XLabel("Frequency Hz");

            // make the plot for the first time, otherwise update the existing plot
            if (formsPlot1.plt.GetPlottables().Count == 0)
            {
                signalPlot = formsPlot1.plt.PlotSignal(fftPower, 2.0 * fftPower.Length / SAMPLE_RATE);
                peakLine   = formsPlot1.plt.PlotVLine(peakFreq, ColorTranslator.FromHtml("#66FF0000"), 2);
            }
            else
            {
                signalPlot.ys     = fftPower;
                peakLine.position = peakFreq;
                peakLine.visible  = cbPeak.Checked;
            }

            if (cbAutoAxis.Checked)
            {
                formsPlot1.plt.AxisAuto(horizontalMargin: 0);
            }

            formsPlot1.Render();
        }
Ejemplo n.º 5
0
        // ---------------------------------

        private void FormMain_Load(object sender, EventArgs e)
        {
            // --------------------------------------------
            // init chart_signal style
            // --------------------------------------------
            double[] sin_swppe = ScottPlot.DataGen.SinSweep(10000, 10);
            this.plt_signal = this.chart_signal.plt.PlotSignal(sin_swppe, 1000);
            this.chart_signal.Render();
            // -------------------------------------------
            sin_swppe    = ScottPlot.DataGen.SinSweep(10000, 20);
            this.plt_fft = this.chart_fft.plt.PlotSignal(sin_swppe, 1000);
            this.chart_fft.Render();
            // --------------------------------------------
        }
Ejemplo n.º 6
0
        public FormGui()
        {
            InitializeComponent();

            Random rand = new Random(0);

            sig = formsPlot1.plt.PlotSignal(
                ys: ScottPlot.DataGen.RandomWalk(rand, 10_000_000),
                label: "Signal (10M)");

            sigConst = formsPlot1.plt.PlotSignalConst(
                ys: ScottPlot.DataGen.RandomWalk(rand, 10_000_000),
                label: "SignalConst (10M)");

            scat = formsPlot1.plt.PlotScatter(
                xs: ScottPlot.DataGen.Consecutive(1_000, spacing: 10_000),
                ys: ScottPlot.DataGen.RandomWalk(rand, 1_000, 20),
                label: "Scatter (1k)");;

            formsPlot1.plt.Legend();
            formsPlot1.plt.Axis();
            formsPlot1.Render();
        }