예제 #1
0
 private RFmxNRMX GetNRSignalConfiguration(RFmxInstrMX instr, string signalName)
 {
     if (string.IsNullOrEmpty(signalName))
     {
         return(instr.GetNRSignalConfiguration());
     }
     return(instr.GetNRSignalConfiguration(signalName));
 }
        void ConfigureNR()
        {
            NR = instrSession.GetNRSignalConfiguration();  /* Create a new RFmx Session */
            instrSession.ConfigureFrequencyReference("", frequencyReferenceSource, frequencyReferenceFrequency);
            NR.SetSelectedPorts("", selectedPorts);
            NR.ConfigureRF("", centerFrequency, referenceLevel, externalAttenuation);
            NR.ConfigureDigitalEdgeTrigger("", digitalEdgeSource, digitalEdge, triggerDelay, enableTrigger);

            NR.SetLinkDirection("", RFmxNRMXLinkDirection.Uplink);
            NR.SetFrequencyRange("", frequencyRange);
            NR.SetBand("", band);
            NR.ComponentCarrier.SetBandwidth("", carrierBandwidth);
            NR.ComponentCarrier.SetCellID("", cellID);
            NR.ComponentCarrier.SetBandwidthPartSubcarrierSpacing("", subcarrierSpacing);
            NR.SetAutoResourceBlockDetectionEnabled("", autoResourceBlockDetectionEnabled);

            NR.ComponentCarrier.SetPdschModulationType("", pdschModulationType);
            NR.ComponentCarrier.SetPdschSlotAllocation("", pdschSlotAllocation);
            NR.ComponentCarrier.SetPdschSymbolAllocation("", pdschSymbolAllocation);

            NR.ComponentCarrier.SetPdschNumberOfResourceBlockClusters("", NumberOfResourceBlockClusters);

            subblockString      = RFmxNRMX.BuildSubblockString("", 0);
            carrierString       = RFmxNRMX.BuildCarrierString(subblockString, 0);
            bandwidthPartString = RFmxNRMX.BuildBandwidthPartString(carrierString, 0);
            userString          = RFmxNRMX.BuildUserString(bandwidthPartString, 0);
            pdschConfigString   = RFmxNRMX.BuildPdschConfigString(userString, 0);
            for (int i = 0; i < NumberOfResourceBlockClusters; i++)
            {
                pdschClusterString = RFmxNRMX.BuildPdschClusterString(pdschConfigString, i);
                NR.ComponentCarrier.SetPdschResourceBlockOffset(pdschClusterString, pdschResourceBlockOffset[i]);
                NR.ComponentCarrier.SetPdschNumberOfResourceBlocks(pdschClusterString, pdschNumberOfResourceBlocks[i]);
            }

            NR.ComponentCarrier.SetPdschDmrsPowerMode("", pdschDmrsPowerMode);
            NR.ComponentCarrier.SetPdschDmrsPower("", pdschDmrsPower);
            NR.ComponentCarrier.SetPdschDmrsConfigurationType("", pdschDmrsConfigurationType);
            NR.ComponentCarrier.SetPdschMappingType("", pdschMappingType);
            NR.ComponentCarrier.SetPdschDmrsTypeAPosition("", pdschDmrsTypeAPosition);
            NR.ComponentCarrier.SetPdschDmrsDuration("", pdschDmrsDuration);
            NR.ComponentCarrier.SetPdschDmrsAdditionalPositions("", pdschDmrsAdditionalPositions);

            NR.ComponentCarrier.SetSsbEnabled("", ssbEnabled);
            NR.ComponentCarrier.SetSsbCrbOffset("", ssbCrbOffset);
            NR.ComponentCarrier.SetSsbSubcarrierOffset("", ssbSubcarrierOffset);
            NR.ComponentCarrier.SetSsbPattern("", ssbPattern);

            NR.SelectMeasurements("", RFmxNRMXMeasurementTypes.ModAcc, true);

            NR.ModAcc.Configuration.SetSynchronizationMode("", synchronizationMode);
            NR.ModAcc.Configuration.SetAveragingEnabled("", averagingEnabled);
            NR.ModAcc.Configuration.SetAveragingCount("", averagingCount);

            NR.ModAcc.Configuration.SetMeasurementLengthUnit("", measurementLengthUnit);
            NR.ModAcc.Configuration.SetMeasurementOffset("", measurementOffset);
            NR.ModAcc.Configuration.SetMeasurementLength("", measurementLength);

            NR.Initiate("", "");
        }
        /// <summary>
        /// Creates an NR signal configuration by serializing the data in <paramref name="objectToSerialize"/>.
        /// </summary>
        public static RFmxNRMX CreateNRSignalConfigurationFromObject(this RFmxInstrMX instr, object objectToSerialize, string signalName, string baseSelectorString = "")
        {
            RFmxNRMX signal;

            if (string.IsNullOrEmpty(signalName))
            {
                signal = instr.GetNRSignalConfiguration();
            }
            else
            {
                signal = instr.GetNRSignalConfiguration(signalName);
            }
            NrRFmxSerializer mapper = new NrRFmxSerializer();

            mapper.Serialize(signal, baseSelectorString, objectToSerialize);
            return(signal);
        }
예제 #4
0
        public void ConfigureNR(ComplexWaveform <ComplexSingle> niFormattedData)
        {
            NR = instrSession.GetNRSignalConfiguration();     /* Create a new RFmx Session */
            instrSession.ConfigureRFAttenuation("", RFmxInstrMXRFAttenuationAuto.True, 20);
            instrSession.ConfigureFrequencyReference("", RFmxInstrMXConstants.OnboardClock, 10e6);
            //instrSession.SetTriggerExportOutputTerminal("", "");
            NR.ConfigureDigitalEdgeTrigger("", "PXI_Trig2", RFmxNRMXDigitalEdgeTriggerEdge.Rising, 0, true);
            NR.SelectMeasurements("", RFmxNRMXMeasurementTypes.ModAcc, true);
            NR.ModAcc.Configuration.SetMeasurementEnabled("", true);
            NR.ModAcc.Configuration.SetAveragingEnabled("", averagingEnabled);
            NR.ModAcc.Configuration.SetAveragingCount("", averagingCount);
            //
            NR.SetBand("", band);
            // Signal COnfiguration
            NR.SetLinkDirection("", lnkDirection);
            // Carrier Definition
            NR.ComponentCarrier.SetNumberOfComponentCarriers("", 1);



#if false
            //***************************************************************
            //-------------DEVELOPMENT OF MULTI_CARRIER----------------------
            //***************************************************************

            // 2-CC
            // Carrier Definition
            string[] arrCC = new string[2];
            NR.ComponentCarrier.SetNumberOfComponentCarriers("", 2);

            for (int i = 0; i < arrCC.Length; i++)
            {
                arrCC[i] = RFmxNRMX.BuildCarrierString("", i);

                NR.ComponentCarrier.SetCellID(arrCC[i], cellID);
                NR.ComponentCarrier.SetBandwidth(arrCC[i], componentCarrierBandwidth);
                NR.ComponentCarrier.SetNumberOfBandwidthParts(arrCC[i], 1);
                NR.ComponentCarrier.SetBandwidthPartSubcarrierSpacing(arrCC[i], subcarrierSpacing);
                NR.SetAutoResourceBlockDetectionEnabled(arrCC[i], RFmxNRMXAutoResourceBlockDetectionEnabled.False);
                NR.ComponentCarrier.SetPuschResourceBlockOffset(arrCC[i], puschRBOffset);
                NR.ComponentCarrier.SetPuschNumberOfResourceBlocks(arrCC[i], puschNumberOfRBs);
            }

            //***************************************************************
#endif


            NR.ComponentCarrier.SetCellID("", cellID);
            NR.ComponentCarrier.SetBandwidth("", componentCarrierBandwidth);
            // BWP Setup
            NR.ComponentCarrier.SetNumberOfBandwidthParts("", 1);
            NR.ComponentCarrier.SetBandwidthPartSubcarrierSpacing("", subcarrierSpacing);
            NR.SetAutoResourceBlockDetectionEnabled("", RFmxNRMXAutoResourceBlockDetectionEnabled.False);
            NR.ComponentCarrier.SetPuschResourceBlockOffset("", puschRBOffset);
            NR.ComponentCarrier.SetPuschNumberOfResourceBlocks("", puschNumberOfRBs);
            // PUSCH Setup
            NR.ComponentCarrier.SetNumberOfPuschConfigurations("", 1);
            NR.ComponentCarrier.SetPuschSymbolAllocation("", puschSymbolAllocation);
            NR.ComponentCarrier.SetPuschSlotAllocation("", puschSlotAllocation);
            NR.ComponentCarrier.SetPuschNumberOfResourceBlockClusters("", puschNumberOfRBClusters);

            //int maxRBs = 0, offsetRBs = 0;
            //NR.ComponentCarrier.GetPuschResourceBlockOffset("", out offsetRBs);
            //NR.ComponentCarrier.GetPuschNumberOfResourceBlocks("", out maxRBs);

            // PUSCH Allocations
            //NR.ComponentCarrier.SetResourceBlockAlignmentMode("", RFmxNRMXResourceBlockAlignmentMode.Disabled);
            //for (int i = 0; i < NumberOfSubblocks; i++)
            //{
            //    subblockString = RFmxNRMX.BuildSubblockString("", 0);
            //    carrierString = RFmxNRMX.BuildCarrierString(subblockString, 0);
            //    puschClusterString = RFmxNRMX.BuildPuschClusterString(carrierString, i);
            //    NR.ComponentCarrier.SetPuschResourceBlockOffset(puschClusterString, puschRBOffset);
            //    NR.ComponentCarrier.SetPuschNumberOfResourceBlocks(puschClusterString, puschNumberOfRBs);
            //}

            NR.ComponentCarrier.SetPuschModulationType("", puschModulationType);
            NR.ComponentCarrier.SetPuschTransformPrecodingEnabled("", puschTransformPrecodingEnabled);
            // Missing DataScramblingIDMode Methods
            NR.ComponentCarrier.SetPuschDmrsScramblingIDMode("", RFmxNRMXPuschDmrsScramblingIDMode.CellID);
            NR.ComponentCarrier.SetPuschDmrsScramblingID("", 0);

            NR.ComponentCarrier.SetPuschMappingType("", puschDmrsMappingType);
            // PUSCH DM-RS
            NR.ComponentCarrier.SetPuschDmrsScramblingIDMode("", RFmxNRMXPuschDmrsScramblingIDMode.CellID);
            NR.ComponentCarrier.SetPuschDmrsScramblingID("", 0);
            // PUSCH---DMRS

            //I would like to add the following DMRS settings to the user configured EVM measurement:
            //DMRS Config type,
            //DMRS Mapping type,
            //DMRS Type A Position,
            //DMRS Duration,
            //DMRS Additional Positions,
            //Number of CDM Groups
            //*** DMRS Power only available if CP-OFDM

            NR.ComponentCarrier.SetPuschDmrsPowerMode("", puschDmrsPowerMode);
            if (puschDmrsPowerMode == RFmxNRMXPuschDmrsPowerMode.CdmGroups)
            {
                NR.ComponentCarrier.SetPuschDmrsPower("", 0);
                NR.ComponentCarrier.SetPuschDmrsConfigurationType("", RFmxNRMXPuschDmrsConfigurationType.Type1);
            }
            else
            {
                NR.ComponentCarrier.SetPuschDmrsPower("", puschDmrsPower);
            }

            if (puschTransformPrecodingEnabled == RFmxNRMXPuschTransformPrecodingEnabled.False)
            {
                NR.ComponentCarrier.SetPuschDmrsConfigurationType("", puschDmrsConfigurationType);
            }


            NR.ComponentCarrier.SetPuschDmrsDuration("", puschDmrsDuration);
            NR.ComponentCarrier.SetPuschDmrsTypeAPosition("", puschDmrsTypeAPosition);
            NR.ComponentCarrier.SetPuschDmrsAdditionalPositions("", puschDmrsAdditionalPositions);

            NR.ComponentCarrier.SetPuschMappingType("", puschDmrsMappingType);

            if (puschTransformPrecodingEnabled == RFmxNRMXPuschTransformPrecodingEnabled.True)
            {
                NR.ComponentCarrier.SetPuschDmrsNumberOfCdmGroups("", 2);
            }
            else
            {
                if (puschDmrsConfigurationType == RFmxNRMXPuschDmrsConfigurationType.Type1)
                {
                    NR.ComponentCarrier.SetPuschDmrsNumberOfCdmGroups("", MathHelper.Clamp <int>(puschDmrsNumCdmGroups, 1, 2));
                }
                else
                {
                    NR.ComponentCarrier.SetPuschDmrsNumberOfCdmGroups("", MathHelper.Clamp <int>(puschDmrsNumCdmGroups, 1, 3));
                }
            }

            // Why String???
            NR.ComponentCarrier.SetPuschDmrsAntennaPorts("", 0.ToString());

            if (puschTransformPrecodingEnabled == RFmxNRMXPuschTransformPrecodingEnabled.True)
            {
                NR.ComponentCarrier.SetPuschDmrsScramblingIDMode("", RFmxNRMXPuschDmrsScramblingIDMode.CellID);
                NR.ComponentCarrier.SetPuschDmrsScramblingID("", 0);
                NR.ComponentCarrier.SetPdschDmrsnScid("", 0);
            }

            NR.ComponentCarrier.SetPuschDmrsPuschIDMode("", RFmxNRMXPuschDmrsPuschIDMode.CellID);
            NR.ComponentCarrier.SetPuschDmrsPuschID("", 0);

            //NR.ModAcc.Configuration.SetFftWindowLength("", 10e-3);
            if (this.duplexScheme == frmRFmxSettings.RFmxDuplexMode.TDD)
            {
                NR.ModAcc.Configuration.SetMeasurementLengthUnit("", RFmxNRMXModAccMeasurementLengthUnit.Time);
                NR.ModAcc.Configuration.SetMeasurementOffset("", 0);
                NR.ModAcc.Configuration.SetMeasurementLength("", 1e-3);
            }
            else
            {
                NR.ModAcc.Configuration.SetMeasurementLengthUnit("", measurementLengthUnit);
                NR.ModAcc.Configuration.SetMeasurementOffset("", measurementOffset);
                NR.ModAcc.Configuration.SetMeasurementLength("", measurementLength);
            }

            NR.ModAcc.Configuration.SetEvmUnit("", evmUnit);

            //NR.ModAcc.Configuration.SetSynchronizationMode("", RFmxNRMXModAccSynchronizationMode.HalfSubframe);
            //NR.Initiate("", "");

            NR.Commit("");

            #region Run Analysis

            bool averagingDone;

            double recommendedPreTriggerTime;

            RFmxInstrMXRecommendedAcquisitionType recType;
            instrSession.GetRecommendedAcquisitionType("", out recType);
            double acquisitionTime;
            instrSession.GetRecommendedIQAcquisitionTime("", out acquisitionTime);
            int numberOfRecords;
            instrSession.GetRecommendedNumberOfRecords("", out numberOfRecords);
            //instrSession.GetRecommendedSpectralAcquisitionSpan("", out spectralAcquisitionSpan);
            double minimumSampleRate;
            instrSession.GetRecommendedIQMinimumSampleRate("", out minimumSampleRate);
            instrSession.GetRecommendedIQPreTriggerTime("", out recommendedPreTriggerTime);

            Console.WriteLine("Rec pre-trigger time = " + recommendedPreTriggerTime.ToString());

            //ComplexWaveform<ComplexSingle> niFormattedData;

            //if (!RIFileType)
            //    niFormattedData = ConvertIqDataToNiComplexFormat(traceData);
            //else
            //    niFormattedData = RIData;

            #endregion Run Analysis

            ///AnalyzeIQ reset must be true for for last or single AnalyzeIQ call.
            ///Note: averaging in offline mode is done in MXA (IQ data in this module has been averaged).
            NR.AnalyzeIQ("", "", niFormattedData, true, out averagingDone);
            //int err = NR.Initiate("", "");
            NR.WaitForMeasurementComplete("", 10);
        }
예제 #5
0
        public void Run()
        {
            #region Create Sessions
            NIRfsg       nIRfsg = new NIRfsg(resourceName, false, false);
            RFmxInstrMX  instr  = new RFmxInstrMX(resourceName, "");
            RFmxSpecAnMX specAn = instr.GetSpecAnSignalConfiguration(signalStringSpecan);
            RFmxNRMX     nr     = instr.GetNRSignalConfiguration(signalStringNr);
            #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.RFmxNR.ConfigureCommon(nr, saCommonConfig);
            SA.RFmxNR.ConfigureStandard(nr, StandardConfigNR);
            #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(nr, AcpConfigNR);
            RFmxNRMXMeasurementTypes[] nrMeasurements = new RFmxNRMXMeasurementTypes[1] {
                RFmxNRMXMeasurementTypes.Acp
            };
            SA.RFmxNR.SelectAndInitiateMeasurements(nr, nrMeasurements, saAutolevelConfig, false, "", resultStringNr);
            AcpResultsNR = FetchAcp(nr, RFmxNRMX.BuildResultString(resultStringNr));
            PrintACPResults();

            ConfigureModacc(nr, ModaccConfigNR);
            nrMeasurements[0] = RFmxNRMXMeasurementTypes.ModAcc;
            SA.RFmxNR.SelectAndInitiateMeasurements(nr, nrMeasurements, saAutolevelConfig, false, "", resultStringNr);
            ModaccResultsNR = FetchModAcc(nr, RFmxNRMX.BuildResultString(resultStringNr));
            PrintModAccResults();
            #endregion

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

            AbortGeneration(nIRfsg);
            CloseInstrument(nIRfsg);
        }
        /// <summary>
        /// This example illustrates how to use the RFmxNR APIs to configure the analyzer to perform a ModAcc measurement.
        /// You can use the Generator Basic example to generate the NR signal before running this example.
        /// </summary>
        static void Main(string[] args)
        {
            Console.WriteLine("\n----------------------- 5GNR Analyzer Example -----------------------\n");
            double centerFrequency = 3.5e9; //Hz
            string resourceName    = "5840";
            string signalString    = "Signal0";
            string resultString    = "Result0";

            SA.RFmxInstr.InstrumentConfiguration saInstrConfig;
            SA.CommonConfiguration          saCommonConfig;
            SA.AutoLevelConfiguration       saAutolevelConfig;
            SA.RFmxNR.StandardConfiguration StandardConfigNR;
            SA.RFmxNR.ModAccConfiguration   ModaccConfigNR;
            SA.RFmxNR.ModAccResults         ModaccResultsNR = new ModAccResults();

            //Analyzer Configuration
            Console.WriteLine("Configure...\n");
            saInstrConfig  = SA.RFmxInstr.InstrumentConfiguration.GetDefault();
            saCommonConfig = saCommonConfig = SA.CommonConfiguration.GetDefault();
            saCommonConfig.ExternalAttenuation_dB = 0;
            saCommonConfig.CenterFrequency_Hz     = centerFrequency;
            saCommonConfig.ReferenceLevel_dBm     = 0.0;
            saAutolevelConfig         = SA.AutoLevelConfiguration.GetDefault();
            saAutolevelConfig.Enabled = true;
            StandardConfigNR          = SA.RFmxNR.StandardConfiguration.GetDefault();
            StandardConfigNR.ComponentCarrierConfigurations[0].PuschModulationType = RFmxNRMXPuschModulationType.Qpsk;
            ModaccConfigNR = SA.RFmxNR.ModAccConfiguration.GetDefault();

            #region Configure Analyzer
            saAutolevelConfig.MeasurementInterval_s = 0.001;
            RFmxInstrMX instr = new RFmxInstrMX(resourceName, "");
            SA.RFmxInstr.ConfigureInstrument(instr, saInstrConfig);
            RFmxNRMX nr = instr.GetNRSignalConfiguration(signalString);
            SA.RFmxNR.ConfigureCommon(nr, saCommonConfig);
            SA.RFmxNR.ConfigureStandard(nr, StandardConfigNR);
            #endregion

            #region Measure
            Console.WriteLine("Measure...\n");
            ConfigureModacc(nr, ModaccConfigNR);
            RFmxNRMXMeasurementTypes[] nrMeasurements = new RFmxNRMXMeasurementTypes[1] {
                RFmxNRMXMeasurementTypes.ModAcc
            };
            SA.RFmxNR.SelectAndInitiateMeasurements(nr, nrMeasurements, saAutolevelConfig, false, "", resultString);
            ModaccResultsNR = FetchModAcc(nr, RFmxNRMX.BuildResultString(resultString));
            //print Results
            for (int i = 0; i < ModaccResultsNR.ComponentCarrierResults.Length; i++)
            {
                Console.WriteLine("----------------------- EVM Results CC {0} -----------------------\n", i);
                Console.WriteLine("Composite RMS EVM Mean (% or dB)               : {0:0.000}", ModaccResultsNR.ComponentCarrierResults[i].MeanRmsCompositeEvm);
                Console.WriteLine("Composite Peak EVM Maximum (% or dB)           : {0:0.000}", ModaccResultsNR.ComponentCarrierResults[i].MaxPeakCompositeEvm);
                Console.WriteLine("Composite Peak EVM Slot Index                  : {0}", ModaccResultsNR.ComponentCarrierResults[i].PeakCompositeEvmSlotIndex);
                Console.WriteLine("Composite Peak EVM Symbol Index                : {0}", ModaccResultsNR.ComponentCarrierResults[i].PeakCompositeEvmSymbolIndex);
                Console.WriteLine("Composite Peak EVM Subcarrier Index            : {0}", ModaccResultsNR.ComponentCarrierResults[i].PeakCompositeEvmSubcarrierIndex);
                Console.WriteLine("Component Carrier Frequency Error Mean (Hz)    : {0:0.000}", ModaccResultsNR.ComponentCarrierResults[i].MeanFrequencyError_Hz);
            }
            #endregion
            nr.Dispose();
            instr.Close();
            Console.WriteLine("Please press any key to close the application.\n");
            Console.ReadKey();
        }
        private void ConfigureNR()
        {
            watch.Start();

            NR_offsets = instrSession.GetNRSignalConfiguration("signal::offsets");
            NR_carrier = instrSession.GetNRSignalConfiguration("signal::carrier");

            instrSession.ConfigureFrequencyReference("", frequencyReferenceSource, frequencyReferenceFrequency);
            instrSession.SetDownconverterFrequencyOffset("signal::carrier", 256e6);

            //Configure offset measurements
            NR_offsets.SetSelectedPorts("", selectedPorts);
            NR_offsets.ConfigureRF("", centerFrequency, referenceLevel, externalAttenuation);
            NR_offsets.ConfigureDigitalEdgeTrigger("", digitalEdgeSource, digitalEdge, triggerDelay, enableTrigger);
            NR_offsets.SetLinkDirection("", linkDirection);
            NR_offsets.SetFrequencyRange("", frequencyRange);
            NR_offsets.SetBand("", modaccBand);
            NR_offsets.ComponentCarrier.SetBandwidth("", carrierBandwidth);
            NR_offsets.ComponentCarrier.SetBandwidthPartSubcarrierSpacing("", subcarrierSpacing);
            NR_offsets.SelectMeasurements("", RFmxNRMXMeasurementTypes.Acp | RFmxNRMXMeasurementTypes.Sem, true);


            //Configure carrier measurements
            NR_carrier.SetSelectedPorts("", selectedPorts);
            NR_carrier.ConfigureRF("", centerFrequency, referenceLevel, externalAttenuation);
            NR_carrier.ConfigureDigitalEdgeTrigger("", digitalEdgeSource, digitalEdge, triggerDelay, enableTrigger);
            NR_carrier.SetLinkDirection("", linkDirection);
            NR_carrier.SetFrequencyRange("", frequencyRange);
            NR_carrier.SetBand("", modaccBand);
            NR_carrier.ComponentCarrier.SetBandwidth("", carrierBandwidth);
            NR_carrier.ComponentCarrier.SetBandwidthPartSubcarrierSpacing("", subcarrierSpacing);
            NR_carrier.SelectMeasurements("", RFmxNRMXMeasurementTypes.ModAcc | RFmxNRMXMeasurementTypes.Chp | RFmxNRMXMeasurementTypes.Obw, true);

            NR_offsets.Acp.Configuration.ConfigureSweepTime("", RFmxNRMXAcpSweepTimeAuto.True, sweepTimeInterval);

            NR_offsets.Chp.Configuration.ConfigureSweepTime("", RFmxNRMXChpSweepTimeAuto.True, sweepTimeInterval);

            NR_offsets.Obw.Configuration.ConfigureSweepTime("", RFmxNRMXObwSweepTimeAuto.True, sweepTimeInterval);

            NR_offsets.Sem.Configuration.ConfigureSweepTime("", RFmxNRMXSemSweepTimeAuto.True, sweepTimeInterval);

            NR_carrier.ModAcc.Configuration.SetAveragingEnabled("", RFmxNRMXModAccAveragingEnabled.False);
            NR_carrier.ModAcc.Configuration.SetAveragingCount("", averagingCount);

            NR_offsets.Acp.Configuration.ConfigureAveraging("", RFmxNRMXAcpAveragingEnabled.False, averagingCount,
                                                            RFmxNRMXAcpAveragingType.Rms);

            NR_carrier.Chp.Configuration.ConfigureAveraging("", RFmxNRMXChpAveragingEnabled.False, averagingCount,
                                                            RFmxNRMXChpAveragingType.Rms);

            NR_carrier.Obw.Configuration.ConfigureAveraging("", RFmxNRMXObwAveragingEnabled.False, averagingCount,
                                                            RFmxNRMXObwAveragingType.Rms);

            NR_offsets.Sem.Configuration.ConfigureAveraging("", RFmxNRMXSemAveragingEnabled.False, averagingCount,
                                                            RFmxNRMXSemAveragingType.Rms);

            NR_carrier.ModAcc.Configuration.SetMeasurementLengthUnit("", measurementLengthUnit);
            NR_carrier.ModAcc.Configuration.SetMeasurementOffset("", measurementOffset);
            NR_carrier.ModAcc.Configuration.SetMeasurementLength("", measurementLength);

            if (linkDirection == RFmxNRMXLinkDirection.Uplink)
            {
                NR_offsets.Sem.Configuration.ConfigureUplinkMaskType("", uplinkMaskType);
            }
            else
            {
                NR_offsets.ConfiguregNodeBCategory("", gNodeBCategory);
                NR_offsets.Sem.Configuration.SetDownlinkMaskType("", downlinkMaskType);
                NR_offsets.Sem.Configuration.SetDeltaFMaximum("", deltaFMaximum);
                NR_offsets.Sem.Configuration.ComponentCarrier.ConfigureRatedOutputPower("", componentCarrierRatedOutputPower);
            }
            NR_offsets.Commit("");
            NR_carrier.Commit("");
            offsetResults  = RFmxNRMX.BuildResultString("offsetResults");
            carrierResults = RFmxNRMX.BuildResultString("carrierResults");
            NR_carrier.Initiate("", "carrierResults");
            instrSession.WaitForAcquisitionComplete(timeout);
            NR_offsets.Initiate("", "offsetResults");
            //NR_offsets.WaitForMeasurementComplete("", timeout);
//            NR_carrier.Initiate("", "");
        }
        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();
                }
            }
        }