Example #1
0
        private void OnNewData(object sender, ElapsedEventArgs e)
        {
            //var data = _dataSource.GetVoltageSeries(1000);

            // Append data to series.
            // _dataSeries0.Append(data.XData, data.YData);

            double y1 = 3.0 * Math.Sin(((2 * Math.PI) * 1.4) * t) + _random.NextDouble() * 0.5;

            //AtHydrphone ath = new AtHydrphone();

            //for (int i = 0; i < VoltageValues.Count; i++)
            //{
            //    data.Samples[i].Value

            //    VoltageDataSeries.Append(t, VoltageValues[i]);

            //    t += dt;
            //}

            VoltageDataSeries.Append(t, y1); // This plots the voltage graoh you need to pass voltage values to y1
            var db = 20 * Math.Log10(y1) - 120;

            AmplitudeDataSeries.Append(t, db);

            // Increment current time
            t += dt;
        }
        private void OnNewData(object sender, ElapsedEventArgs e)
        {
            //var data = _dataSource.GetVoltageSeries(1000);

            // Append data to series.
            //_dataSeries0.Append(data.XData, data.YData);

            //double y1 = 3.0 * Math.Sin(((2 * Math.PI) * 1.4) * t) + _random.NextDouble() * 0.5;
            double y1 = 0.0005 * Math.Sin(((2 * Math.PI) * 1.4) * t) + _random.NextDouble() * 0.00005;

            //ATHydrophone ath = new ATHydrophone();

            //for (int i = 0; i < VoltageValues.Count; i++)
            //{
            //    data.Samples[i].Value;

            //    VoltageDataSeries.Append(t, VoltageValues[i]);

            //    t += dt;
            //}

            VoltageDataSeries.Append(t, y1); // This plots the voltage graph you need to pass voltage values to y1

            //Following calculates an RMS value over the value of RMSSamples of the acquired voltages.
            if (RMSCount == RMSSamples - 1)
            {
                double RMSVoltage = Math.Sqrt(RMSTally / RMSSamples);

                double referenceVoltage = Math.Pow(10, (sensitivity / 20));

                double db = 20 * Math.Log10(RMSVoltage / referenceVoltage);

                AmplitudeDataSeries.Append(t, db);
                RMSTally = 0.0;
                RMSCount = 0;
            }
            else
            {
                RMSTally += y1 * y1;
                RMSCount++;
            }

            UpdateData(); // updates the FFT chart

            //var db = 20 * Math.Log10(y1) - 120;
            //AmplitudeDataSeries.Append(t, db);

            // Increment current time
            t += dt;
        }