Esempio n. 1
0
        public void Run()
        {
            #region Create Sessions
            NIRfsg       nIRfsg = new NIRfsg(resourceName, false, false);
            RFmxInstrMX  instr  = new RFmxInstrMX(resourceName, "");
            RFmxSpecAnMX specAn = instr.GetSpecAnSignalConfiguration(signalStringSpecan);
            RFmxLteMX    lte    = instr.GetLteSignalConfiguration(signalStringLte);
            #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.RFmxLTE.ConfigureCommon(lte, saCommonConfig);
            SA.RFmxLTE.ConfigureStandard(lte, StandardConfigLte);
            #endregion

            #region Configure and Measure DPD
            if (EnableDpd)
            {
                Methods.RFmxDPD.ConfigureCommon(specAn, CommonConfigurationDpd, waveform);
                Methods.RFmxDPD.ConfigureMemoryPolynomial(specAn, MemoryPolynomialConfiguration);
                Methods.RFmxDPD.ConfigureApplyDpdCrestFactorReduction(specAn, applyDpdCrestFactorReductionConfig);

                Console.WriteLine("\n--------------- Measurement Results with DPD --------------\n");
                specAn.SelectMeasurements("", RFmxSpecAnMXMeasurementTypes.Dpd, true);
                Methods.RFmxDPD.PerformMemoryPolynomial(specAn, nIRfsg, MemoryPolynomialConfiguration, waveform);
            }
            else
            {
                Console.WriteLine("\n------------- Measurement Results without DPD -------------\n");
            }
            #endregion

            #region Measure
            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();

            ConfigureAcp(lte, AcpConfigLte);
            RFmxLteMXMeasurementTypes[] lteMeasurements = new RFmxLteMXMeasurementTypes[1] {
                RFmxLteMXMeasurementTypes.Acp
            };
            SA.RFmxLTE.SelectAndInitiateMeasurements(lte, lteMeasurements, saAutolevelConfig, false, "", resultStringLte);
            AcpResultsLte = FetchAcp(lte, RFmxLteMX.BuildResultString(resultStringLte));
            PrintACPResults();

            ConfigureModAcc(lte, ModaccConfigLte);
            lteMeasurements[0] = RFmxLteMXMeasurementTypes.ModAcc;
            SA.RFmxLTE.SelectAndInitiateMeasurements(lte, lteMeasurements, saAutolevelConfig, false, "", resultStringLte);
            ModaccResultsLte = FetchModAcc(lte, RFmxLteMX.BuildResultString(resultStringLte));
            PrintModAccResults();
            #endregion

            specAn.Dispose();
            specAn = null;
            lte.Dispose();
            instr.Close();

            AbortGeneration(nIRfsg);
            CloseInstrument(nIRfsg);
        }
Esempio n. 2
0
        public void Run()
        {
            #region Create Sessions
            NIRfsg       nIRfsg = new NIRfsg(resourceName, false, false);
            RFmxInstrMX  instr  = new RFmxInstrMX(resourceName, "");
            RFmxSpecAnMX specAn = instr.GetSpecAnSignalConfiguration(signalStringSpecan);
            RFmxWlanMX   wlan   = instr.GetWlanSignalConfiguration(signalStringWlan);
            #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);

            var waveformLength_s = waveform.Data.SampleCount / waveform.SampleRate;

            nIRfsg.Initiate();
            #endregion

            #region configure Analyzer
            saAutolevelConfig.MeasurementInterval_s = waveform.BurstLength_s;

            SA.RFmxInstr.ConfigureInstrument(instr, saInstrConfig);
            SA.RFmxSpecAn.ConfigureCommon(specAn, saCommonConfig);
            SA.RFmxWLAN.ConfigureCommon(wlan, saCommonConfig);
            #endregion

            #region Configure SpecAn
            ampmConfigurationSpecAn.ReferenceWaveform        = waveform;
            ampmConfigurationSpecAn.DutAverageInputPower_dBm = sgInstrConfig.DutAverageInputPower_dBm;
            SA.RFmxSpecAn.ConfigureAmpm(specAn, ampmConfigurationSpecAn);
            #endregion

            #region Configure WLAN Measurement
            SA.RFmxWLAN.ConfigureStandard(wlan, wlanStandardConfig);
            SA.RFmxWLAN.ConfigureOFDMModAcc(wlan, modAccConfig);
            SA.RFmxWLAN.ConfigureSEM(wlan, semConfig);
            #endregion

            #region Configure and Measure DPD
            if (EnableDpd)
            {
                Methods.RFmxDPD.ConfigureCommon(specAn, commonConfigurationDpd, waveform);
                Methods.RFmxDPD.ConfigureMemoryPolynomial(specAn, memoryPolynomialConfiguration);
                Methods.RFmxDPD.ConfigureApplyDpdCrestFactorReduction(specAn, applyDpdCrestFactorReductionConfig);

                Console.WriteLine("\n------------------------ Perform DPD ----------------------\n");

                specAn.SelectMeasurements("", RFmxSpecAnMXMeasurementTypes.Dpd, true);
                Methods.RFmxDPD.PerformMemoryPolynomial(specAn, nIRfsg, memoryPolynomialConfiguration, waveform);
                Console.WriteLine("\n------------------------ DPD done --------------------------\n");
            }
            #endregion

            #region Measure SpecAn
            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();
            #endregion

            #region measure and results
            RFmxWlanMXMeasurementTypes[] wlanMeasurements = new RFmxWlanMXMeasurementTypes[1] {
                RFmxWlanMXMeasurementTypes.OfdmModAcc
            };
            SA.RFmxWLAN.SelectAndInitiateMeasurements(wlan, wlanMeasurements, saAutolevelConfig, false, "", resultStringWlan);
            modAccResults = SA.RFmxWLAN.FetchOFDMModAcc(wlan, RFmxWlanMX.BuildResultString(resultStringWlan));
            PrintModAccResults();

            wlanMeasurements[0] = RFmxWlanMXMeasurementTypes.Sem;
            SA.RFmxWLAN.SelectAndInitiateMeasurements(wlan, wlanMeasurements, saAutolevelConfig, false, "", resultStringWlan);
            semResults = SA.RFmxWLAN.FetchSEM(wlan, RFmxWlanMX.BuildResultString(resultStringWlan));
            PrintSemResults();
            #endregion

            AbortGeneration(nIRfsg);
            CloseInstrument(nIRfsg);
            wlan.Dispose();
            wlan = null;
            instr.Close();
            instr = null;
        }
Esempio n. 3
0
 /// <summary>Configures common measurement settings for the personality.</summary>
 /// <param name="specAnSignal">Specifies the SpecAn signal to configure.</param>
 /// <param name="commonConfig">Specifies the common settings to apply.</param>
 /// <param name="selectorString">Pass an empty string. The signal name that is passed when creating the signal configuration is used.
 /// See the RFmx help for more documention of this parameter.</param>
 public static void ConfigureCommon(RFmxSpecAnMX specAnSignal, CommonConfiguration commonConfig, string selectorString = "")
 {
     specAnSignal.SetSelectedPorts(selectorString, commonConfig.SelectedPorts);
     specAnSignal.ConfigureRF(selectorString, commonConfig.CenterFrequency_Hz, commonConfig.ReferenceLevel_dBm, commonConfig.ExternalAttenuation_dB);
     specAnSignal.ConfigureDigitalEdgeTrigger(selectorString, commonConfig.DigitalTriggerSource, RFmxSpecAnMXDigitalEdgeTriggerEdge.Rising, commonConfig.TriggerDelay_s, commonConfig.TriggerEnabled);
 }
        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();
                }
            }
        }