Exemplo n.º 1
0
        private void plot1_GLLoaded(object sender, EventArgs e)
        {
            line = new DataLine1D("Line 1", 2 * Samplerate / 2, Samplerate)
            {
                LineColor = Color.Blue
            };
            line2 = new DataLine1D("Line 2", 2 * Samplerate, Samplerate / 2)
            {
                LineColor = Color.Green
            };

            var data  = new NodeSystemLib2.FormatData1D.TimeLocatedBuffer1D <double>(2 * Samplerate / 2, Samplerate);
            var data2 = new NodeSystemLib2.FormatData1D.TimeLocatedBuffer1D <double>(2 * Samplerate, Samplerate / 2);

            for (int i = 0; i < data.Capacity; i++)
            {
                data.Data[i] = (float)Math.Sin(2 * Math.PI * 10 / Samplerate * i);
            }

            for (int i = 0; i < data2.Capacity; i++)
            {
                data2.Data[i] = (float)Math.Cos(2 * Math.PI * 20 / Samplerate * i);
            }

            data.SetWritten(data.Capacity);
            data2.SetWritten(data2.Capacity);
            line.Add(data);
            line2.Add(data2);

            set = new TimeDataSet {
                SamplesPerSecond = Samplerate,
                Milliseconds     = 2000
            };

            set.AxisX.VisibleMinimum = 0;
            set.AxisX.VisibleMaximum = 2000;
            set.AxisY.VisibleMinimum = -2;
            set.AxisY.VisibleMaximum = 2;

            set.Data.Add(line);
            set.Data.Add(line2);

            plot1.Set = set;
            plot1.CreateLegend();
        }
Exemplo n.º 2
0
        private void FillVBO(double phaseFactor)
        {
            var task1 = Task.Run(() => {
                var w1      = 2 * Math.PI * 20 / _lines1.SamplesPerSecond;
                var p1      = phaseFactor;
                var samples = data.Data;
                for (int i = 0; i < data.Capacity; i++)
                {
                    samples[i] = (float)Math.Sin(p1 += w1);
                }
                data.SetWritten(data.Capacity);
                _lines1.Add(data);
            });

            var task2 = Task.Run(() => {
                var w2      = 2 * Math.PI * 1 / _lines2.SamplesPerSecond;
                var p2      = phaseFactor;
                var samples = data2.Data;
                for (int i = 0; i < data2.Capacity; i++)
                {
                    samples[i] = (float)Math.Cos(p2 += w2);
                }
                data2.SetWritten(data2.Capacity);
                _lines2.Add(data2);
            });

            var task3 = Task.Run(() => {
                var w3      = 2 * Math.PI * 20 / _lines3.SamplesPerSecond;
                var p3      = phaseFactor;
                var samples = data3.Data;
                for (int i = 0; i < data3.Capacity; i++)
                {
                    samples[i] = (float)Math.Cos(p3 += w3);
                }
                data3.SetWritten(data3.Capacity);
                _lines3.Add(data3);
            });

            Task.WaitAll(task1, task2, task3);

            _dataSet.SetTimeOffset(data.Time);
            _dataSet.SetTimeOffset(data2.Time);
            _dataSet.SetTimeOffset(data3.Time);
        }