예제 #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;
            }
        }
예제 #2
0
 public FRAFile(FRAFileType fileType, double[] frequenciesLogHz, double[] gainsDB, double[] phasesDegrees, double referenceResistorOhms)
 {
     logService = new FileLogService(typeof(FRAFile));
     logService.Debug("Creating FRASeries from arrays ");
     m_FRAResults        = new List <FRAResult>();
     m_FilePath          = "";
     m_ReferenceResistor = referenceResistorOhms;
     m_FRAFileType       = fileType;
     m_DateTimeCreated   = DateTime.Now;
     AddResults(frequenciesLogHz, gainsDB, phasesDegrees);
     CreateLineSeries();
 }
예제 #3
0
 public FRAFile(string path, FRAFileType fileType, double referenceResistor)
 {
     logService = new FileLogService(typeof(FRAFile));
     logService.Debug("Creating FRASeries from file " + path);
     m_FRAResults        = new List <FRAResult>();
     m_FilePath          = path;
     m_ReferenceResistor = referenceResistor;
     m_FRAFileType       = fileType;
     m_DateTimeCreated   = DateTime.Now;
     AddResults();
     CreateLineSeries();
 }
예제 #4
0
 public bool OpenFile(string path, FRAFileType fileType, double referenceResistor)
 {
     logService.Info("Open file: " + path);
     if (!ContainsFile(path))
     {
         this.Add(new FRAFile(path, fileType, referenceResistor));
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #5
0
 public void NewFile(string path, FRAFileType fileType, double referenceResistor)
 {
     logService.Info("New file: " + path);
     this.Clear();
     this.Add(new FRAFile(path, fileType, referenceResistor));
 }
예제 #6
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();
        }