Esempio n. 1
0
        public void TestFilter()
        {
            TextReader rdr = File.OpenText("/Temp/source2.txt");
            Parser     p   = new Parser(rdr);

            values = p.ReadFloats();
            rdr.Close();

            // send through moving average
            //avg = Filter.AvgFilter(ref values, 5);
            //compressed = Filter.Compress(ref avg, 5, 10);
            fft = values;
            // fft
            Fourier.FFT(ref fft, (ulong)fft.Length, 1);
            MessageBox.Show("done");
        }
Esempio n. 2
0
        private void mnuSaveToDatabase_Click(object sender, EventArgs e)
        {
            /*
             * double[] result;
             * // generate a filtered/compressed signal for all of the measurements
             * // in the current set, and then add it to the database
             * Queue<double>[] Data = new Queue<double>[NumStarts];
             * for (int i = 0; i < NumStarts; i++)
             * {
             *      Data[i] = new Queue<double>();
             * }
             *
             * int MeasureNum = 0, shortestMeasurement = 100000, tmpNum;
             * bool firstZero = false;
             * for (int i = 0; i < NumStarts; i++)
             * {
             *      while (true)
             *      {
             *              if (Measurements.Count > 0)
             *                      tmpNum = Measurements.Dequeue();
             *              else
             *                      break;
             *              // see if it's a transition between measurements
             *              if (tmpNum == 0)
             *              {
             *                      if (!firstZero)
             *                              firstZero = true;
             *                      else
             *                      {
             *                              MeasureNum++;
             *                              break;
             *                      }
             *              }
             *              else
             *                      Data[MeasureNum].Enqueue(tmpNum);
             *      }
             *      // determine longest measurement on the way
             *      if (Data[MeasureNum - 1].Count < shortestMeasurement)
             *              shortestMeasurement = Data[MeasureNum - 1].Count;
             * }
             *
             * // generate one averaged dataset for all the measurements
             * result = new double[shortestMeasurement];
             * for (int i = 0; i < shortestMeasurement; i++)
             * {
             *      double avg = 0.0;
             *      for (int j = 0; j < NumStarts; j++)
             *      {
             *              avg += Data[j].Dequeue();
             *      }
             *      avg /= NumStarts;
             *      result[i] = avg;
             * }
             *
             * // perform running average, compression and fft
             * result = Filter.AvgFilter(ref result, AvgLookAhead);
             * result = Filter.Compress(ref result, CompLookAhead, CompThreshold);
             */
            int numSamples;

            double[] result = GenerateSignature(out numSamples);
            double[] fft    = result;
            Fourier.FFT(ref fft, (ulong)fft.Length, 1);

            // add to database
            uint temp = Measurements.Peek().Temp;
            byte batt = Measurements.Peek().Life;

            dataBase.AddEntry(txtBaseName.Text, result, fft, numSamples, temp, batt);
            //dataBase.AddEntry(txtBaseName.Text, result, fft, numSamples);
        }