Exemplo n.º 1
0
        /// <summary>Configures common instrument settings for generation.</summary>
        /// <param name="rfsgHandle">The open RFSG session to configure.</param>
        /// <param name="instrConfig">The common instrument settings to configure.</param>
        public static void ConfigureInstrument(NIRfsg rfsgHandle, InstrumentConfiguration instrConfig)
        {
            rfsgHandle.SignalPath.SelectedPorts = instrConfig.SelectedPorts;
            rfsgHandle.RF.ExternalGain          = -instrConfig.ExternalAttenuation_dB;
            rfsgHandle.RF.Configure(instrConfig.CarrierFrequency_Hz, instrConfig.DutAverageInputPower_dBm);

            rfsgHandle.FrequencyReference.Source = RfsgFrequencyReferenceSource.FromString(instrConfig.ReferenceClockSource);

            // Only configure LO settings on supported VSTs
            if (Regex.IsMatch(rfsgHandle.Identity.InstrumentModel, "NI PXIe-58[34].")) // Matches 583x and 584x VST families
            {
                IntPtr rfsgPtr = rfsgHandle.GetInstrumentHandle().DangerousGetHandle();
                NIRfsgPlayback.RetrieveAutomaticSGSASharedLO(rfsgPtr, "", out RfsgPlaybackAutomaticSGSASharedLO currentMode);
                if (instrConfig.LOSharingMode == LocalOscillatorSharingMode.None && currentMode != RfsgPlaybackAutomaticSGSASharedLO.Disabled)
                {
                    //Setting this property resets other settings, which can create issues. Hence, it is only set if the value
                    //is different than the current mode.
                    NIRfsgPlayback.StoreAutomaticSGSASharedLO(rfsgPtr, "", RfsgPlaybackAutomaticSGSASharedLO.Disabled);
                }
                else if (instrConfig.LOSharingMode == LocalOscillatorSharingMode.Automatic && currentMode != RfsgPlaybackAutomaticSGSASharedLO.Enabled)
                {
                    //Setting this property resets other settings, which can create issues. Hence, it is only set if the value
                    //is different than the current mode.
                    NIRfsgPlayback.StoreAutomaticSGSASharedLO(rfsgPtr, "", RfsgPlaybackAutomaticSGSASharedLO.Enabled);
                }
            }
            //Do nothing; any configuration for LOs with standalone VSGs should be configured manually.
            //Baseband instruments don't have LOs. Unsupported VSTs must be configured manually.
        }