Ejemplo n.º 1
0
        //* Need to give path to where source is located
        private static void Main(string[] args)
        {
            Console.Clear();
            // string projectPath = @"D:\Miguel\Documents\Projetos\CSVReader\";
            string projectPath;

            if (args == null)
            {
                throw new Exception("No path given");
            }
            else
            {
                projectPath = args[0];
            }


            string csvPath = string.Concat(projectPath, "scr.csv");

            SignalProcessing processor = new SignalProcessing(csvPath);
            ProjectRunner    runner    = new ProjectRunner(projectPath);

            Console.WriteLine("There are {0} values to process",
                              processor.XValues.Length);

            // runner.TestPeaks(processor);
            runner.TestMovingAverage(processor);
        }
Ejemplo n.º 2
0
        public void TestPeaks(SignalProcessing processor)
        {
            Console.WriteLine("Testing Peaks Method");
            Console.Write("\nInput the search window: ");

            _window = AskForInt();

            Console.WriteLine("Press a key to find peaks...");
            Console.ReadKey();

            processor.FindPeaks(_window);

            Console.Clear();
            Console.WriteLine("There are {0} peaks, with a window range of {1}",
                              processor.ListOfMaximums.Count, _window);

            foreach (Tuple <float, float> maximum in processor.ListOfMaximums)
            {
                System.Console.WriteLine(
                    "Peak {0} and position {1}", maximum.Item2, maximum.Item1);
            }

            Console.WriteLine("There are {0} minimums, with a window range of {1}",
                              processor.ListOfMinimus.Count, _window);

            Console.WriteLine();

            foreach (Tuple <float, float> minimums in processor.ListOfMinimus)
            {
                Console.WriteLine("Minimum {0} and position {1}",
                                  minimums.Item2, minimums.Item1);
            }

            SaveToCSV(processor);
        }
Ejemplo n.º 3
0
        private void SaveToCSV(SignalProcessing processor)
        {
            Console.Write("\n Want to write values to CSV? ");

            _answer = AskForYesOrNo();

            if (_answer == "y")
            {
                string fileName;
                Console.Write("Please enter file name: ");

                do
                {
                    fileName = Console.ReadLine();
                } while (fileName == null);

                _resultPath = string.Concat(_projectPath, fileName, ".csv");

                FileStream fs = new FileStream(_resultPath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                using (StreamWriter file = new StreamWriter(fs))
                {
                    file.WriteLine("# Maximum values");
                    for (int i = 0; i < processor.ListOfMaximums.Count; i++)
                    {
                        file.WriteLine("{0}\t{1}",
                                       processor.ListOfMaximums[i].Item1,
                                       processor.ListOfMaximums[i].Item2);
                    }

                    file.WriteLine("# Minimum values");
                    for (int i = 0; i < processor.ListOfMinimus.Count; i++)
                    {
                        file.WriteLine("{0}\t{1}",
                                       processor.ListOfMinimus[i].Item1,
                                       processor.ListOfMinimus[i].Item2);
                    }

                    file.WriteLine("# Moving Average");
                    for (int i = 0; i < processor.Averages.Count; i++)
                    {
                        file.WriteLine(processor.Averages[i]);
                    }
                }
                fs.Close();
            }
        }
Ejemplo n.º 4
0
        public void TestMovingAverage(SignalProcessing processor)
        {
            Console.WriteLine("Testing Moving Average Method");
            Console.Write("\nInput the search window: ");

            _window = AskForInt();

            Console.WriteLine("Press a key to get the moving average...");
            Console.ReadKey();

            processor.GetMovingAverage(_window);

            System.Console.WriteLine("The values are...");


            for (int i = 0; i < processor.Averages.Count; i++)
            {
                System.Console.WriteLine(processor.Averages[i]);
            }

            SaveToCSV(processor);
        }