Ejemplo n.º 1
0
        public void Run()
        {
            #region Create Sessions
            FocusITunerBroker iTuner = new FocusITunerBroker();
            iTuner.Initialize(tunerAddress, false, true);
            NIRfsg       nIRfsg = new NIRfsg(resourceName, false, false);
            RFmxInstrMX  instr  = new RFmxInstrMX(resourceName, "");
            RFmxSpecAnMX specAn = instr.GetSpecAnSignalConfiguration(signalStringSpecan);
            #endregion

            #region Configure Tuner
            FocusTuner.ConfigureCommon(iTuner, commonConfiguration);
            #endregion

            #region Configure Generation
            ConfigureInstrument(nIRfsg, sgInstrConfig);
            Waveform waveform = LoadWaveformFromTDMS(filePath);
            DownloadWaveform(nIRfsg, waveform);
            ConfigureContinuousGeneration(nIRfsg, waveform);
            nIRfsg.Initiate();
            #endregion

            #region Configure Analyzer
            saAutolevelConfig.MeasurementInterval_s = waveform.BurstLength_s;
            RFmxInstr.ConfigureInstrument(instr, saInstrConfig);
            RFmxSpecAn.ConfigureCommon(specAn, saCommonConfig);
            RFmxSpecAn.ConfigureTxp(specAn, txpConfigurationSpecAn);
            #endregion

            #region Measure
            foreach (var gamma in gammaSweep)
            {
                Console.WriteLine("\n--------------------- Tuning --------------------\n");
                currentGamma = FocusTuner.MoveTunerPerGamma(iTuner, gamma)[0];
                PrintTuneResults();

                Console.WriteLine("\n--------------------- Results --------------------\n");
                RFmxSpecAnMXMeasurementTypes[] specanMeasurements = new RFmxSpecAnMXMeasurementTypes[1] {
                    RFmxSpecAnMXMeasurementTypes.Txp
                };
                RFmxSpecAn.SelectAndInitiateMeasurements(specAn, specanMeasurements, saAutolevelConfig, waveform.SignalBandwidth_Hz, false, "", resultStringSpecan);
                txpResultsSpecAn = RFmxSpecAn.FetchTxp(specAn, RFmxSpecAnMX.BuildResultString(resultStringSpecan));
                PrintTxPResults();
            }
            #endregion

            AbortGeneration(nIRfsg);
            CloseInstrument(nIRfsg);
            FocusTuner.CloseTuner(iTuner);
            specAn.Dispose();
            specAn = null;
            instr.Close();
            instr = null;
        }
Ejemplo n.º 2
0
        private void CloseSession()
        {
            try
            {
                if (specAn != null)
                {
                    specAn.Dispose();
                    specAn = null;
                }

                if (instrSession != null)
                {
                    instrSession.Close();
                    instrSession = null;
                }
            }
            catch (Exception ex)
            {
                DisplayError(ex);
            }
        }
Ejemplo n.º 3
0
        public void Run()
        {
            #region Create Sessions
            NIRfsg       nIRfsg = new NIRfsg(resourceName, false, false);
            RFmxInstrMX  instr  = new RFmxInstrMX(resourceName, "");
            RFmxSpecAnMX specAn = instr.GetSpecAnSignalConfiguration(signalStringSpecan);
            #endregion

            #region Configure Generation
            ConfigureInstrument(nIRfsg, SgInstrConfig);
            Waveform waveform = LoadWaveformFromTDMS(filePath);

            // Apply CRF to the waveform if it is enabled
            waveform = Methods.RFmxDPD.ConfigurePreDpdCrestFactorReduction(specAn, waveform, preDpdCrestFactorReductionConfig);

            DownloadWaveform(nIRfsg, waveform);
            ConfigureContinuousGeneration(nIRfsg, waveform);
            nIRfsg.Initiate();
            #endregion

            #region Configure Analyzer
            saAutolevelConfig.MeasurementInterval_s = waveform.BurstLength_s;
            SA.RFmxInstr.ConfigureInstrument(instr, saInstrConfig);
            SA.RFmxSpecAn.ConfigureCommon(specAn, saCommonConfig);

            AmpmConfigurationSpecAn.ReferenceWaveform        = waveform;
            AmpmConfigurationSpecAn.DutAverageInputPower_dBm = SgInstrConfig.DutAverageInputPower_dBm;
            SA.RFmxSpecAn.ConfigureAmpm(specAn, AmpmConfigurationSpecAn);

            SA.RFmxSpecAn.ConfigureTxp(specAn, TxpConfigurationSpecAn);
            SA.RFmxSpecAn.ConfigureAcp(specAn, AcpConfigurationSpecAn, "");

            if (EnableDpd)
            {
                Methods.RFmxDPD.ConfigureCommon(specAn, CommonConfigurationDpd, waveform);
                Methods.RFmxDPD.ConfigureMemoryPolynomial(specAn, MemoryPolynomialConfiguration);
                Methods.RFmxDPD.ConfigureApplyDpdCrestFactorReduction(specAn, applyDpdCrestFactorReductionConfig);
            }
            #endregion

            #region Measure

            Console.WriteLine("\n--------------------- Results --------------------\n");
            if (EnableDpd)
            {
                specAn.SelectMeasurements("", RFmxSpecAnMXMeasurementTypes.Dpd, true);
                Methods.RFmxDPD.PerformMemoryPolynomial(specAn, nIRfsg, MemoryPolynomialConfiguration, waveform);
            }
            RFmxSpecAnMXMeasurementTypes[] specanMeasurements = new RFmxSpecAnMXMeasurementTypes[1] {
                RFmxSpecAnMXMeasurementTypes.Ampm
            };
            SA.RFmxSpecAn.SelectAndInitiateMeasurements(specAn, specanMeasurements, saAutolevelConfig, waveform.SignalBandwidth_Hz, false, "", resultStringSpecan);
            AmpmResultsSpecAn = SA.RFmxSpecAn.FetchAmpm(specAn, RFmxSpecAnMX.BuildResultString(resultStringSpecan));
            PrintAMPMResults();

            specanMeasurements[0] = RFmxSpecAnMXMeasurementTypes.Txp;
            SA.RFmxSpecAn.SelectAndInitiateMeasurements(specAn, specanMeasurements, saAutolevelConfig, waveform.SignalBandwidth_Hz, false, "", resultStringSpecan);
            TxpResultsSpecAn = SA.RFmxSpecAn.FetchTxp(specAn, RFmxSpecAnMX.BuildResultString(resultStringSpecan));
            PrintTxPResults();

            specanMeasurements[0] = RFmxSpecAnMXMeasurementTypes.Acp;
            SA.RFmxSpecAn.SelectAndInitiateMeasurements(specAn, specanMeasurements, saAutolevelConfig, waveform.SignalBandwidth_Hz, false, "", resultStringSpecan);
            AcpResultsSpecAn = SA.RFmxSpecAn.FetchAcp(specAn, RFmxSpecAnMX.BuildResultString(resultStringSpecan));
            PrintACPResults();
            #endregion

            AbortGeneration(nIRfsg);
            CloseInstrument(nIRfsg);
            specAn.Dispose();
            specAn = null;
            instr.Close();
            instr = null;
        }
        static void LoadAndRunMeasurements(string instrName, string inputPath, string outputPath)
        {
            inputPath = Path.GetFullPath(inputPath);
            RFmxInstrMX instr = null;
            NIRfsa      rfsa  = null;
            IntPtr      rfsaHandle;

            try
            {
                Console.WriteLine($"Initializing RFmx session with instrument \"{instrName}\"...");
                instr = new RFmxInstrMX(instrName, "");

                Console.WriteLine($"Loading configuration from \"{Path.GetFileName(inputPath)}\"...");
                instr.LoadAllConfigurations(inputPath, true);
                instr.DangerousGetNIRfsaHandle(out rfsaHandle);
                rfsa = new NIRfsa(rfsaHandle);

                string[] signalNames = new string[0];
                RFmxInstrMXPersonalities[] personalities = new RFmxInstrMXPersonalities[0];

                Console.WriteLine("Configuration loaded successfully.");

                instr.GetSignalConfigurationNames("", RFmxInstrMXPersonalities.All, ref signalNames, ref personalities);
                for (int i = 0; i < signalNames.Length; i++)
                {
                    Console.WriteLine("");
                    ConsoleKeyInfo info;
                    switch (personalities[i])
                    {
                    case RFmxInstrMXPersonalities.BT:
                        RFmxBTMX bt = instr.GetBTSignalConfiguration(signalNames[i]);
                        Console.WriteLine($"Enter 'y' to initiate acquisition for RFmx Bluetooth with signal \"{signalNames[i]}\"; any other key to skip.");
                        info = Console.ReadKey();
                        Console.WriteLine();
                        if (info.KeyChar == 'y')
                        {
                            bt.Initiate("", "");
                            bt.WaitForMeasurementComplete("", 10);
                            FetchAndLog(rfsa, personalities[i], signalNames[i], outputPath);
                        }
                        bt.Dispose();
                        break;

                    case RFmxInstrMXPersonalities.Wlan:
                        RFmxWlanMX wlan = instr.GetWlanSignalConfiguration(signalNames[i]);
                        Console.WriteLine($"Enter 'y' to initiate acquisition for RFmx WLAN with signal \"{signalNames[i]}\"; any other key to skip.");
                        info = Console.ReadKey();
                        Console.WriteLine();
                        if (info.KeyChar == 'y')
                        {
                            wlan.Initiate("", "");
                            wlan.WaitForMeasurementComplete("", 10);
                            FetchAndLog(rfsa, personalities[i], signalNames[i], outputPath);
                        }
                        wlan.Dispose();
                        break;

                    case RFmxInstrMXPersonalities.SpecAn:
                        RFmxSpecAnMX specAn = instr.GetSpecAnSignalConfiguration(signalNames[i]);
                        Console.WriteLine($"Enter 'y' to initiate acquisition for RFmx SpecAn with signal \"{signalNames[i]}\"; any other key to skip.");
                        info = Console.ReadKey();
                        Console.WriteLine();
                        if (info.KeyChar == 'y')
                        {
                            specAn.Initiate("", "");
                            specAn.WaitForMeasurementComplete("", 10);
                            FetchAndLog(rfsa, personalities[i], signalNames[i], outputPath);
                        }
                        specAn.Dispose();
                        break;

                    case RFmxInstrMXPersonalities.NR:
                        RFmxNRMX nr = instr.GetNRSignalConfiguration(signalNames[i]);
                        Console.WriteLine($"Enter 'y' to initiate acquisition for RFmx NR with signal \"{signalNames[i]}\"; any other key to skip.");
                        info = Console.ReadKey();
                        Console.WriteLine();
                        if (info.KeyChar == 'y')
                        {
                            nr.Initiate("", "");
                            nr.WaitForMeasurementComplete("", 10);
                            FetchAndLog(rfsa, personalities[i], signalNames[i], outputPath);
                        }
                        nr.Dispose();
                        break;

                    case RFmxInstrMXPersonalities.Lte:
                        RFmxLteMX lte = instr.GetLteSignalConfiguration(signalNames[i]);
                        Console.WriteLine($"Enter 'y' to initiate acquisition for RFmx LTE with signal \"{signalNames[i]}\"; any other key to skip.");
                        info = Console.ReadKey();
                        Console.WriteLine();
                        if (info.KeyChar == 'y')
                        {
                            lte.Initiate("", "");
                            lte.WaitForMeasurementComplete("", 10);
                            FetchAndLog(rfsa, personalities[i], signalNames[i], outputPath);
                        }
                        lte.Dispose();
                        break;

                    default:
                        throw new System.NotImplementedException($"The \"{personalities[i].ToString()}\" personality has not been implemented.");
                    }
                }
                Console.WriteLine("All measurements complete.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception occurred: " + ex.Message);
                Console.WriteLine("Location: " + ex.StackTrace);
            }
            finally
            {
                if (instr != null)
                {
                    instr.Dispose();
                }
            }
        }