예제 #1
0
        public TemperMeasurment parseTemperartureFile()
        {
            if (!File.Exists(strTemperFilePath))
            {
                return(null);
            }

            String[] lines = File.ReadAllLines(strTemperFilePath);

            if (lines.Length == 0)
            {
                return(null);
            }

            TemperMeasurment temperatur = new TemperMeasurment(lines.Length);

            // fTimeTemper = new float[lines.Length];
            // fTemper = new float[lines.Length];
            int j = 0;

            for (int i = 0; i < lines.Length; i++)
            {
                String[] parameters = lines[i].Split(' ');
                if (parameters.Length != 2)
                {
                    continue;
                }
                try
                {
                    temperatur.fTimeTemper[j] = float.Parse(parameters[0], System.Globalization.CultureInfo.InvariantCulture);
                    temperatur.fTemper[j]     = float.Parse(parameters[1], System.Globalization.CultureInfo.InvariantCulture);
                }
                catch (Exception e)
                {// TODO: fix problem with wrong tepmerature
                }
                j++;
            }

            Console.WriteLine("Found: " + temperatur.fTimeTemper.Length + " Temperature measurements");
            return(temperatur);
        }
예제 #2
0
        public void parseFiles(String fileName)
        {
            FileParser parser = new FileParser();

            parser.setFileNames(fileName);

            DacMeasurement dacMeasur = parser.parseDacFile();

            if (dacMeasur != null)
            {
                for (int i = 0; i < dacMeasur.fDAC.Length; i++)
                {
                    AddDacToGraph(dacMeasur.fTime[i], dacMeasur.fDAC[i]);
                }
            }

            fPhase = parser.parsePhaseFile();
            if (fPhase != null)
            {
                fPhaseAvg      = new float[fPhase.Length];
                fPhaseDerivAvg = new float[fPhase.Length];

                for (int i = 0; i < fPhase.Length; i++)
                {
                    if (i == 11693)
                    {
                        i = i;
                    }
                    AddPhaseToGraph(dacMeasur.fTime[0] + i, fPhase[i] * 1000000000);   //Phase is measured each second (?). Use DAC first time as start point. Phase is in [ns]

                    fPhaseAvg[i] = phaseAvg.calculateAvg(fPhase[i]);
                    if (fPhaseAvg[i] < -180)
                    {
                        fPhaseAvg[i] = fPhaseAvg[i];
                    }

                    AddPhaseAvgToGraph(dacMeasur.fTime[0] + i, fPhaseAvg[i] * 1000000000);//* 1000000000);
                }

                for (int i = 20; i < fPhase.Length; i++)
                {
                    float fPhaseDeriv = calculatePhaseFirstDerivation(i);
                    AddPhaseFirstDeviationToGraph(dacMeasur.fTime[0] + i, fPhaseDeriv);
                    fPhaseDerivAvg[i] = phaseDevAvg.calculateAvg(fPhaseDeriv);
                    AddPhaseSecondDeviationToGraph(dacMeasur.fTime[0] + i, calculatePhaseSecondDerivation(i));
                }
            }

            TemperMeasurment temper = parser.parseTemperartureFile();

            if (temper != null)
            {
                for (int i = 0; i < temper.fTemper.Length; i++)
                {
                    AddTemperatureToGraph(temper.fTimeTemper[i], temper.fTemper[i]);
                }
            }


            /*  graphPainter.autozoom(0);
             * graphPainter.autozoom(3);
             * graphPainter.autozoom(4);
             * graphPainter.autozoom(5);
             */
            Console.WriteLine("finished reading");
        }