Beispiel #1
0
        // DATA EXPORTING //

        /****************************************************************************
        *  ExportWaveForm
        *  defines the lorentzian function with an additional vertical shift
        ****************************************************************************/
        public void ExportWaveForm(ref PlottableData plottableData, ExportSettings exportSettings)
        {
            //string contFileName = GetFileName(exportSettings.fileSavePath + exportSettings.fileNamePrefix + "cont_");
            string waveFileName = GetFileName(exportSettings.fileNamePrefix + exportSettings.fileNamePrefix + "wave_");

            TextWriter waveWriter = new StreamWriter(waveFileName, false);

            //TextWriter contWriter = new StreamWriter(contFileName, false);

            //wave export
            if (exportSettings.isWaveForm)
            {
                waveWriter.Write("Time,");
                waveWriter.Write("Amplitude,");
            }

            if (exportSettings.isFFT)
            {
                waveWriter.Write("FFT_frequency,");
                waveWriter.Write("FFT_mag,");
            }

            if (exportSettings.isLorentzian)
            {
                waveWriter.Write("Lorentz_frequency,");
                waveWriter.Write("Lorentz_mag,");
            }



            waveWriter.WriteLine();

            for (int i = 0; i < plottableData.WaveFormData.time.Length; i++)
            {
                if (exportSettings.isWaveForm)
                {
                    waveWriter.Write(plottableData.WaveFormData.time[i].ToString() + ",");
                    waveWriter.Write(plottableData.WaveFormData.amp[i].ToString() + ",");
                }

                if (exportSettings.isFFT & i < plottableData.fftData.freq.Length)
                {
                    waveWriter.Write(plottableData.fftData.freq[i].ToString() + ",");
                    waveWriter.Write(plottableData.fftData.fft[i].ToString() + ",");
                }

                if (exportSettings.isLorentzian & (plottableData.lorentzFftData == null || i < plottableData.lorentzFftData.freq.Length))
                {
                    waveWriter.Write(plottableData.lorentzFftData.freq[i].ToString() + ",");
                    waveWriter.Write(plottableData.lorentzFftData.fft[i].ToString() + ",");
                }

                waveWriter.WriteLine();


                //cont writer
            }

            waveWriter.Close();
        }
Beispiel #2
0
        /****************************************************************************
        * GetPlottableData
        *  this function demonstrates how to collect a single block of data
        *  from the unit (start collecting immediately)
        ****************************************************************************/
        public PlottableData GetPlottableData(short handle, Pico.ChannelSettings[] channelSettings, FFTSettings fftSettings, double[] lastfft, ref ProcessTimes processTimes, ref System.Windows.Forms.Timer WaveFormTimer, int SampleCount, bool isChanelB)
        {
            Stopwatch sw = new Stopwatch();


            //sw.Start();
            WaveFormData waveFormData = new WaveFormData();

            // Method that communicates with Pico to get blocked data
            HandlePicoBlockData(0, channelSettings, handle, ref waveFormData, ref processTimes, ref WaveFormTimer, SampleCount, isChanelB);
            //sw.Stop();

            //return if it's chanel B
            if (isChanelB)
            {
                return new PlottableData {
                           fftData = new FFTData(), WaveFormData = waveFormData
                }
            }
            ;

            // calculate fft data if is not chanel B
            sw.Restart();
            PlottableData plottableData = new PlottableData {
                fftData = GetFFT(waveFormData.amp, waveFormData.time, fftSettings, lastfft, SampleCount), WaveFormData = waveFormData
            };

            sw.Stop();

            processTimes.fftTime = sw.Elapsed;

            return(plottableData);
        }
    public void GetParticles_WithRealDataAndPropertiesSet_DoesntThrowException()
    {
        PlottableData data = new PlottableData(dummyData);

        // Set custom indices for the data.
        int xSpatialFieldIndex = 3;
        int ySpatialFieldIndex = 2;
        int zSpatialFieldIndex = 1;

        data.XSpatialFieldIndex = xSpatialFieldIndex;
        data.YSpatialFieldIndex = ySpatialFieldIndex;
        data.ZSpatialFieldIndex = zSpatialFieldIndex;

        // Get the particles.
        ParticleSystem.Particle[] particles = data.GetParticles();
        Assert.AreEqual(dummyData.Length, particles.Length);

        // Ensure that the particles are properly generated.
        for (int i = 0; i < particles.Length; i++)
        {
            Assert.AreEqual(dummyData[i][xSpatialFieldIndex], particles[i].position.x);
            Assert.AreEqual(dummyData[i][ySpatialFieldIndex], particles[i].position.y);
            Assert.AreEqual(dummyData[i][zSpatialFieldIndex], particles[i].position.z);
        }
    }
    public void GetParticles_WithRealDataAndNoPropertiesSet_DoesntThrowException()
    {
        PlottableData data = new PlottableData(dummyData);

        // Get the particles.
        ParticleSystem.Particle[] particles = data.GetParticles();
        Assert.AreEqual(dummyData.Length, particles.Length);
    }
    public void GetParticles_WithEmptyData_DoesntThrowException()
    {
        // Generate the empty data.
        float[][]     emptyData = new float[0][];
        PlottableData data      = new PlottableData(emptyData);

        // Make sure that getting the particles doesn't throw an exception.
        ParticleSystem.Particle[] particles = data.GetParticles();
        Assert.AreEqual(particles.Length, 0);
    }