Exemplo n.º 1
0
        public void SaveAs(FRAFileType fileType, string path)
        {
            switch (fileType)
            {
            case FRAFileType.FRA4PicoScope:
                WriteFile(path, FRATableFormat.CSV_FRA4PicoScope);
                m_FilePath = path;
                UpdateSerieNames();
                break;

            case FRAFileType.Keysight:
                WriteFile(path, FRATableFormat.CSV_Keysight);
                m_FilePath = path;
                UpdateSerieNames();
                break;

            case FRAFileType.RhodeSchwarz:
                WriteFile(path, FRATableFormat.CSV_RhodeSchwarz);
                m_FilePath = path;
                UpdateSerieNames();
                break;

            default:
                logService.Warn("No file could be created for fileType" + fileType.ToString());
                break;
            }
        }
Exemplo n.º 2
0
        private void AddResults()
        {
            using (TextFieldParser parser = new TextFieldParser(FilePath))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");

                // Parse header
                int firstRows = 0;
                if (FRAFileType == FRAFileType.FRA4PicoScope)
                {
                    firstRows = 1;
                }
                if (FRAFileType == FRAFileType.Keysight)
                {
                    firstRows = 1;
                }
                if (FRAFileType == FRAFileType.RhodeSchwarz)
                {
                    firstRows = 1;
                }
                while (firstRows != 0)
                {
                    parser.ReadFields();
                    firstRows -= 1;
                }

                while (!parser.EndOfData)
                {
                    //Process row
                    string[] fields = parser.ReadFields();
                    logService.Debug("Opening file:" + FilePath);
                    logService.Debug("File:" + FRAFileType.ToString());
                    logService.Debug("LogFreq:" + fields[0] + " DbGain:" + fields[1] + " Phase:" + fields[2]);

                    CultureInfo culturFRA4PicoScope = CultureInfo.InvariantCulture;
                    CultureInfo culturKeysight      = CultureInfo.InvariantCulture;
                    CultureInfo culturRhodeSwchwarz = CultureInfo.InvariantCulture;
                    double      frequencyHz         = 0;
                    if (FRAFileType == FRAFileType.FRA4PicoScope)
                    {
                        frequencyHz = Math.Pow(10, Convert.ToDouble(fields[0], culturFRA4PicoScope));
                    }
                    if (FRAFileType == FRAFileType.Keysight)
                    {
                        frequencyHz = Convert.ToDouble(fields[1], culturKeysight);
                    }
                    if (FRAFileType == FRAFileType.RhodeSchwarz)
                    {
                        frequencyHz = Convert.ToDouble(fields[1], culturRhodeSwchwarz);
                    }
                    double gainDB = 0;
                    if (FRAFileType == FRAFileType.FRA4PicoScope)
                    {
                        gainDB = Convert.ToDouble(fields[1], culturFRA4PicoScope);
                    }
                    if (FRAFileType == FRAFileType.Keysight)
                    {
                        gainDB = Convert.ToDouble(fields[3], culturKeysight);
                    }
                    if (FRAFileType == FRAFileType.RhodeSchwarz)
                    {
                        gainDB = Convert.ToDouble(fields[2], culturRhodeSwchwarz);
                    }
                    double phaseDegrees = 0;
                    if (FRAFileType == FRAFileType.FRA4PicoScope)
                    {
                        phaseDegrees = Convert.ToDouble(fields[2], culturFRA4PicoScope);
                    }
                    if (FRAFileType == FRAFileType.Keysight)
                    {
                        phaseDegrees = Convert.ToDouble(fields[4], culturKeysight);
                    }
                    if (FRAFileType == FRAFileType.RhodeSchwarz)
                    {
                        phaseDegrees = Convert.ToDouble(fields[3], culturRhodeSwchwarz);
                    }

                    AddResult(new FRAResult(frequencyHz, gainDB, phaseDegrees, ReferenceResistorOhms));
                }
            }
            m_FRAResults.Sort();
        }