public static void CableTest() { //TEST PARAMETER DEFINITIONS int[] amplitudes = new int[1] { -20 }; //Hard coded values for amplitude settings SwpParamStruct param = new SwpParamStruct(2000, 4000, amplitudes[0], 12); //Hard coded values, Initialize param structure string[] seriesName = new string[amplitudes.Length]; double[] data = new double[param.numSteps]; double[] freqAxis = new double[param.numSteps]; double[,] freqAmplitudeData = new double[param.numSteps, amplitudes.Length + 1]; //Always a 2D array //MEASUREMENT EQUIPMENT SETUP NumberStyles style = NumberStyles.AllowExponent | NumberStyles.Number; ///ESG Setup SG_AgilentESG esg = new SG_AgilentESG(ESGAddress); Console.WriteLine(esg.Identify()); //PXA Setup Console.WriteLine("--PXA TEST STARTED--"); SA_AgilentPXA pxa = new SA_AgilentPXA(PXAAddress); Console.WriteLine("--CABLE TEST STARTED--"); for (int j = 0; j < amplitudes.Length; j++) { param.amplitude = amplitudes[j]; string seriesLabel = "Input Amplitude " + amplitudes[j] + "dBm"; seriesName[j] = seriesLabel; //set init values on ESG esg.SetFrequency(param.freqMin); esg.SetAmplitude(param.amplitude); esg.SetRfOutput(true); for (int i = 0; i < param.numSteps; i++) { double test_freq = param.freqMin + i * (param.freqMax - param.freqMin) / param.numSteps; esg.SetFrequency(test_freq); pxa.SetCenterSpan(test_freq, 100, 0); //MHz pxa.SetAtten(10); pxa.SetRefLevel(-10); pxa.SetMarker(1, test_freq); //Sets marker to frequency of interest pxa.HoldAverage(); System.Threading.Thread.Sleep(500); data[i] = Double.Parse(pxa.GetMarker(1), style); //Rewrite this... it's verbose freqAxis[i] = test_freq; freqAmplitudeData[i, 0] = test_freq; freqAmplitudeData[i, j + 1] = Double.Parse(pxa.GetMarker(1), style); } } // PRINT OUTPUT FILES string path = @"..\..\..\TestResults\CableTest"; //Sends output data to the TestOutputs folder //Output Data to a text file //Output Charts to a pdf file var doc1 = new Document(); string[] chartLabels = new string[] { "Received ESG Amplitude on PXA (Cable Test)", "ESG Frequency (MHz)", "Amplitude (dBm)", "ESG Amplitude (dBm): " + amplitudes[0] }; string[] headerStrings = new string[] { "Cable Test Output Graph", "Mykonos API Regression Testing Development", Helper.GetTimestamp() }; iTextSharp.text.Image[] container = new iTextSharp.text.Image[1]; container[0] = Helper.MakeChartObject(freqAmplitudeData, chartLabels, path + ".pdf"); Helper.AddAllChartsToPdf(container, path + ".pdf", headerStrings); //Open Result pdf System.Diagnostics.Process.Start(path + ".pdf"); }
public static void TxAttenuationSweep([Values(Mykonos.TXCHANNEL.TX1, Mykonos.TXCHANNEL.TX2)] Mykonos.TXCHANNEL channel) { int atten = 0; int backoff = 0; //Retrieve Profile Information, samplingFreq_Hz, ProfileBW, LO Frequency Information double[] profileInfo = new double[3]; profileInfo[0] = settings.txProfileData.IqRate_kHz; profileInfo[1] = settings.txPllLoFreq_Hz; profileInfo[2] = settings.txProfileData.PrimarySigBw_Hz; double txIqDataRate_kHz = profileInfo[0]; double profileBandwidth_MHz = profileInfo[2] / 1000000; Console.WriteLine("IQ Data Rate (kHz): " + txIqDataRate_kHz); Console.WriteLine("Profile Bandwdith (MHz): " + profileBandwidth_MHz); double freqTxLo_MHz = profileInfo[1] / 1000000; Console.WriteLine("Tx LO Frequency (MHz): " + freqTxLo_MHz); //Configure Tone Generator //10MHz offset tone generation double offsetFreq_Hz = 10000000; double[,] fundAmpXY = new double[42, 2]; Helper.GenerateTxTone(Mykonos.TXCHANNEL.TX1_TX2, profileInfo, offsetFreq_Hz, backoff); //Connect to Signal Analyser //The span is fixed to 50MHz NumberStyles style = NumberStyles.AllowExponent | NumberStyles.Number; SA_AgilentPXA pxa = new SA_AgilentPXA(measEquipment.PXAAddress); pxa.SetCenterSpan(freqTxLo_MHz, 50, 0); pxa.SetAtten(20); pxa.SetRefLevel(10); pxa.SetMarker(1, freqTxLo_MHz + 10); //Fundemental Amplitued Marker pxa.SetMarker(2, freqTxLo_MHz); //LO Leakage Marker pxa.SetMarker(3, freqTxLo_MHz - (offsetFreq_Hz / 1000000)); //Image Amplitude marker //Config and Enable Mykonos with Test Specific Settings AdiCommandServerClient Link = AdiCommandServerClient.Instance; Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port); Link.Mykonos.radioOn(); //Test Sequence //Iterate Thru Tx Attenuation Settings //Measure Amplitude of the fundamental //TODO: 0 to 41950 int step = 0; double fundAmp_dB = 0; double minAttnVal_dB = 0; double maxAttnVal_dB = 41.95; for (double attenVal_dB = minAttnVal_dB; (attenVal_dB < maxAttnVal_dB); attenVal_dB += 1) { try { if (channel == Mykonos.TXCHANNEL.TX1) { Link.Mykonos.setTx1Attenuation(attenVal_dB); } if (channel == Mykonos.TXCHANNEL.TX2) { Link.Mykonos.setTx2Attenuation(attenVal_dB); } } catch (Exception e) { Console.WriteLine(e); break; } pxa.HoldAverage(); System.Threading.Thread.Sleep(500); fundAmp_dB = Double.Parse(pxa.GetMarker(1), style); fundAmpXY[step, 1] = fundAmp_dB; fundAmpXY[step, 0] = attenVal_dB; step++; #if WR_RES_TO_CONSOLE Console.WriteLine("Fundamental Amplitude, Attenuation Value " + attenVal_dB + ": " + fundAmp_dB); #endif } Link.Disconnect(); #if WR_RES_TO_PDF //Graph Data and Save in PDF Form var doc1 = new Document(); string path = TxRfTests.ResPath + "TxAttenuationSweep"; string[] pcbInfo; iTextSharp.text.Image[] container = new iTextSharp.text.Image[1]; string[] fundAmpLabels = new string[] { "Fundamental Amplitude Versus Offset Tone Frequency (from LO)", "setTxAtten Argument", "Amplitude (dBm)", "Trace Amplitude" }; pcbInfo = Helper.PcbInfo((settings.txPllLoFreq_Hz / 1000000.0).ToString(), (settings.rxPllLoFreq_Hz / 1000000.0).ToString(), settings.mykSettings.txProfileName, settings.mykSettings.rxProfileName, backoff.ToString(), atten.ToString()); container[0] = Helper.MakeChartObject(fundAmpXY, fundAmpLabels, path); TxRfTests instance = new TxRfTests(); Helper.AddAllChartsToPdf(container, path + ".pdf", pcbInfo); //Open Result PDF System.Diagnostics.Process.Start(path + ".pdf"); #endif }