Exemple #1
0
        public static void Main()
        {
            const string inFile = @"C:\Users\Rik.Essenius\source\spikes\PeakDetector\PeakDetector\0801-2-meas.txt";

            using var reader = new StreamReader(inFile);
            var measureOutFile = Path.GetFileNameWithoutExtension(inFile);
            var summaryOutfile = measureOutFile + "_s.csv";

            measureOutFile += "_m.csv";
            var measureReader = new MeasurementReader(reader);

            using var measureStreamWriter = new StreamWriter(measureOutFile);
            using var summaryStreamWriter = new StreamWriter(summaryOutfile);

            var flowMeter     = new FlowMeter();
            var summaryWriter = new SummaryWriter(summaryStreamWriter);
            var measureWriter = new MeasurementWriter(measureStreamWriter);

            summaryWriter.WriteHeader();
            measureWriter.WriteHeader();
            while (measureReader.HasNext())
            {
                var measurement = measureReader.NextMeasurement();
                flowMeter.AddMeasurement(measurement);
                summaryWriter.AddMeasurement(measurement, flowMeter);
                summaryWriter.PrepareWrite();
                if (!measureWriter.Write(measurement) || measureWriter.FlushRate == 1 || summaryWriter.FlushRate == 1)
                {
                    summaryWriter.Write();
                }
            }
            measureWriter.Flush();
            summaryWriter.Flush();
            reader.Close();
            measureStreamWriter.Close();
            summaryStreamWriter.Close();
        }