public CWKeyer2(Console c) { console = c; if (console.CurrentModel == Model.SDR1000) { hw = console.Hdw; } siolisten = console.Siolisten; Thread.Sleep(50); DttSP.NewKeyer(600.0f, true, 0.0f, 3.0f, 25.0f, (float)Audio.SampleRate1); RadioDSP.KeyerIambicMode = 0; Thread.Sleep(50); threads_running = true; cw_tone_thread = new Thread(new ThreadStart(DttSP.KeyerSoundThread)); cw_tone_thread.Name = "CW Sound Thread"; cw_tone_thread.Priority = ThreadPriority.Highest; cw_tone_thread.IsBackground = true; cw_tone_thread.Start(); keyer_thread = new Thread(new ThreadStart(KeyThread)); keyer_thread.Name = "CW KeyThread"; keyer_thread.Priority = ThreadPriority.Highest; keyer_thread.IsBackground = true; keyer_thread.Start(); timer = new HiPerfTimer(); }
public void RunCalFWCRXLevel() { double vfoa = console.VFOAFreq; double vfob = console.VFOBFreq; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M }; float[] band_freqs = { 1.85f, 3.75f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f }; for (int i = 0; i < band_freqs.Length; i++) { bool do_band = false; switch (bands[i]) { case Band.B160M: do_band = chk160.Checked; break; case Band.B80M: do_band = chk80.Checked; break; case Band.B60M: do_band = chk60.Checked; break; case Band.B40M: do_band = chk40.Checked; break; case Band.B30M: do_band = chk30.Checked; break; case Band.B20M: do_band = chk20.Checked; break; case Band.B17M: do_band = chk17.Checked; break; case Band.B15M: do_band = chk15.Checked; break; case Band.B12M: do_band = chk12.Checked; break; case Band.B10M: do_band = chk10.Checked; break; case Band.B6M: do_band = chk6.Checked; break; } if (do_band) { progress.SetPercent(0.0f); Invoke(new MethodInvoker(progress.Show)); Application.DoEvents(); console.VFOAFreq = band_freqs[i]; console.VFOBFreq = band_freqs[i]; console.CalibrateLevel(-24.0f, band_freqs[i], progress); if (progress.Text == "") { break; } Thread.Sleep(500); } } console.VFOAFreq = vfoa; console.VFOBFreq = vfob; btnCalRXLevelAllBands.BackColor = SystemColors.Control; grpAllBands.Enabled = true; t1.Stop(); Debug.WriteLine("RX Level Timer: " + t1.Duration); }
public CWKeyer2(Console c) { console = c; hw = console.Hdw; siolisten = console.Siolisten; Thread.Sleep(50); DttSP.NewKeyer(600.0f, true, 0.0f, 3.0f, 25.0f, (float)Audio.SampleRate1); RadioDSP.KeyerIambicMode = 0; Thread.Sleep(50); CWTone = new Thread(new ThreadStart(DttSP.KeyerSoundThread)); CWTone.Name = "CW Sound Thread"; CWTone.Priority = ThreadPriority.Highest; CWTone.IsBackground = true; CWTone.Start(); Keyer = new Thread(new ThreadStart(KeyThread)); Keyer.Name = "CW KeyThread"; Keyer.Priority = ThreadPriority.Highest; Keyer.IsBackground = true; Keyer.Start(); timer = new HiPerfTimer(); }
unsafe public CWKeyer2(Console c) { console = c; siolisten = console.Siolisten; Thread.Sleep(50); DttSP.NewKeyer(600.0f, true, 0.0f, 3.0f, 25.0f, (float)Audio.SampleRate1); DttSP.SetKeyerMode(0); Thread.Sleep(50); CWTone = new Thread(new ThreadStart(DttSP.KeyerSoundThread)); CWTone.Name = "CW Sound Thread"; CWTone.Priority = ThreadPriority.Highest; CWTone.IsBackground = true; CWTone.Start(); Monitor = new Thread(new ThreadStart(DttSP.KeyerMonitorThread)); Monitor.Name = "CW Monitor Thread"; Monitor.Priority = ThreadPriority.Highest; Monitor.IsBackground = true; Monitor.Start(); Thread.Sleep(100); timer = new HiPerfTimer(); }
private void btnEEWrite_Click(object sender, EventArgs e) { ushort offset = ushort.Parse(txtOffset.Text, NumberStyles.HexNumber); byte num_bytes = byte.Parse(txtNumBytes.Text, NumberStyles.HexNumber); if (num_bytes > txtData.Text.Length / 2) { MessageBox.Show("Error: Not enough data"); return; } byte[] data = new byte[num_bytes]; for (int i = 0; i < num_bytes; i++) { data[i] = byte.Parse(txtData.Text.Substring(i * 2, 2), NumberStyles.HexNumber); } HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val; //fixed(byte* ptr = &data[0]) val = Flex1500.WriteEEPROM(offset, data); t1.Stop(); Debug.WriteLine("EEWrite: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); }
} // btneepromread1_click private void btnTune_Click(object sender, EventArgs e) { if (txtTune.Text == "") { return; } double freq; bool b = double.TryParse(txtTune.Text, out freq); if (!b) { return; } uint ftw = (uint)(Math.Pow(2.0, 32) * freq * 2 / 384.0); HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val = USBHID.SetFreqTW(ftw); t1.Stop(); Debug.WriteLine("Tune: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); }
private void btnEERead_Click(object sender, EventArgs e) { ushort offset = ushort.Parse(txtOffset.Text, NumberStyles.HexNumber); byte num_bytes = byte.Parse(txtNumBytes.Text, NumberStyles.HexNumber); byte[] data; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val; val = Flex1500.ReadEEPROM(offset, num_bytes, out data); t1.Stop(); txtEERead.Text = ""; for (int i = 0; i < num_bytes; i++) { txtEERead.Text += data[i].ToString("X").PadLeft(2, '0'); } Debug.WriteLine("EERead: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); }
private void CalFWCPABridge() { double vfoa = console.VFOAFreq; double vfob = console.VFOBFreq; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M }; float[] band_freqs = { 1.85f, 3.75f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f }; for (int i = 0; i < band_freqs.Length; i++) { bool do_band = false; switch (bands[i]) { case Band.B160M: do_band = chk160.Checked; break; case Band.B80M: do_band = chk80.Checked; break; case Band.B60M: do_band = chk60.Checked; break; case Band.B40M: do_band = chk40.Checked; break; case Band.B30M: do_band = chk30.Checked; break; case Band.B20M: do_band = chk20.Checked; break; case Band.B17M: do_band = chk17.Checked; break; case Band.B15M: do_band = chk15.Checked; break; case Band.B12M: do_band = chk12.Checked; break; case Band.B10M: do_band = chk10.Checked; break; case Band.B6M: do_band = chk6.Checked; break; } if (do_band) { console.VFOAFreq = band_freqs[i]; console.CalibratePABridge(progress); if (progress.Text == "") { break; } Thread.Sleep(500); } } console.VFOAFreq = vfoa; console.VFOBFreq = vfob; btnCalPABridge.BackColor = SystemColors.Control; grpAllBands.Enabled = true; btnCalPABridge.Enabled = true; }
private void btnGPIOWrite3_Click(object sender, EventArgs e) { HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); byte b; int val = USBHID.ReadGPIO(out b); t1.Stop(); Debug.WriteLine("GPIO3: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); txtGPIOResult.Text = b.ToString("X"); }
private void btnGPIOWrite1_Click(object sender, EventArgs e) { byte b = byte.Parse(txtGPIOByte.Text, NumberStyles.HexNumber); HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val = USBHID.WriteGPIO(b); t1.Stop(); Debug.WriteLine("GPIO1: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); }
/*private bool WriteTWBoundary(double freq, bool xref, uint ee_offset) * { * double clock = 384.0; * if(xref) clock = 400.0; * * uint tw = (uint)(Math.Pow(2.0, 32) * freq * 2 / clock); * tw = SwapBytes(tw); * * uint check_tw = 0; * int count = 0; * do * { * count++; * Flex1500.WriteTRXEEPROMUint(ee_offset, tw); * Thread.Sleep(10); * Flex1500.ReadTRXEEPROMUint(ee_offset, out check_tw); * } while(check_tw != tw && count < 10); * * if(count == 10) return false; * else return true; * }*/ private void btnI2CWrite1_Click(object sender, EventArgs e) { byte addr = byte.Parse(txtI2CAddr.Text, NumberStyles.HexNumber); byte b1 = byte.Parse(txtI2CByte1.Text, NumberStyles.HexNumber); HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val = USBHID.WriteI2CValue(addr, b1); t1.Stop(); Debug.WriteLine("I2C1: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); }
/* * private void PTT(bool state) * { * if (state) * { * butPTT.BackColor = Color.GreenYellow; * } * else * { * butPTT.BackColor = SystemColors.Control; * } * } * * private void FlexPTT(bool state) * { * if (state) * { * butFlexPTT.BackColor = Color.GreenYellow; * } * else * { * butFlexPTT.BackColor = SystemColors.Control; * } * } * * private void Dash(bool state) * { * if (state) * { * butDash.BackColor = Color.GreenYellow; * } * else * { * butDash.BackColor = SystemColors.Control; * } * ToggleTones(); * } * * private void Dot(bool state) * { * if (state) * { * butDot.BackColor = Color.GreenYellow; * } * else * { * butDot.BackColor = SystemColors.Control; * } * ToggleTones(); * } * * private void ToggleTones() * { * if (tone1 == 350.0f) * { * tone1 = 941.0f; * tone2 = 1209.0f; * } * else * { * tone1 = 350.0f; * tone2 = 440.0f; * } * } */ private void btnWrite_Click(object sender, EventArgs e) { uint op = uint.Parse(txtOpcode.Text); uint p1 = uint.Parse(txtParam1.Text, NumberStyles.HexNumber); uint p2 = uint.Parse(txtParam2.Text, NumberStyles.HexNumber); HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val = Flex1500.WriteOp((USBHID.Opcode)op, p1, p2); t1.Stop(); Debug.WriteLine("WriteOp: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); }
private void btnI2CRead_Click(object sender, EventArgs e) { byte addr = byte.Parse(txtI2CAddr.Text, NumberStyles.HexNumber); byte b1 = byte.Parse(txtI2CByte1.Text, NumberStyles.HexNumber); byte b2; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val = USBHID.ReadI2CValue(addr, b1, out b2); t1.Stop(); Debug.WriteLine("I2C Read: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); txtI2CResult.Text = b2.ToString("X").PadLeft(2, '0'); }
private void btnEEReadFloat_Click(object sender, EventArgs e) { ushort offset = ushort.Parse(txtOffset.Text, NumberStyles.HexNumber); //byte num_bytes = 4; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val; byte[] temp = new byte[4]; val = Flex1500.ReadEEPROM((ushort)offset, 4, out temp); float f = BitConverter.ToSingle(temp, 0); t1.Stop(); txtEERead.Text = f.ToString("f6"); Debug.WriteLine("EERead Float: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); }
private void IORunAll() { HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); if (btnIOExtRef.Visible && btnIOExtRef.Enabled) { Invoke(new MethodInvoker(btnIOExtRef.PerformClick)); Thread.Sleep(2000); } if (btnIOPwrSpkr.Visible && btnIOPwrSpkr.Enabled) { Invoke(new MethodInvoker(btnIOPwrSpkr.PerformClick)); Thread.Sleep(3500); } if (btnIORCAInOut.Visible && btnIORCAInOut.Enabled) { Invoke(new MethodInvoker(btnIORCAInOut.PerformClick)); Thread.Sleep(3000); } if (btnIOFWInOut.Visible && btnIOFWInOut.Enabled) { Invoke(new MethodInvoker(btnIOFWInOut.PerformClick)); Thread.Sleep(5000); } if (btnIOHeadphone.Visible && btnIOHeadphone.Enabled) { Invoke(new MethodInvoker(btnIOHeadphone.PerformClick)); Thread.Sleep(5000); } if (btnIODot.Visible && btnIODot.Enabled) { Invoke(new MethodInvoker(btnIODot.PerformClick)); Thread.Sleep(2000); } if (btnIODash.Visible && btnIODash.Enabled) { Invoke(new MethodInvoker(btnIODash.PerformClick)); Thread.Sleep(2000); } if (btnIORCAPTT.Visible && btnIORCAPTT.Enabled) { Invoke(new MethodInvoker(btnIORCAPTT.PerformClick)); Thread.Sleep(1000); } if (btnIOFWPTT.Visible && btnIOFWPTT.Enabled) { Invoke(new MethodInvoker(btnIOFWPTT.PerformClick)); Thread.Sleep(1000); } if (btnIOMicPTT.Visible && btnIOMicPTT.Enabled) { Invoke(new MethodInvoker(btnIOMicPTT.PerformClick)); Thread.Sleep(1000); } if (btnIOMicUp.Visible && btnIOMicUp.Enabled) { Invoke(new MethodInvoker(btnIOMicUp.PerformClick)); Thread.Sleep(1000); } if (btnIOMicDown.Visible && btnIOMicDown.Enabled) { Invoke(new MethodInvoker(btnIOMicDown.PerformClick)); Thread.Sleep(1000); } if (btnIOMicFast.Visible && btnIOMicFast.Enabled) { Invoke(new MethodInvoker(btnIOMicFast.PerformClick)); Thread.Sleep(1000); } btnIORunAll.BackColor = SystemColors.Control; btnIORunAll.Enabled = true; t1.Stop(); MessageBox.Show("Run All Tests Time: " + ((int)(t1.Duration / 60)).ToString() + ":" + (((int)t1.Duration) % 60).ToString("00")); }
private void RunSelectedTests() { bool rx2 = console.RX2Enabled; console.RX2Enabled = false; console.VFOSplit = false; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); string start_bands = GetStringFromBands(); #region Gen // run all general tests if(ckTestGenPLL.Checked) { Invoke(new MethodInvoker(btnPLL.PerformClick)); Thread.Sleep(1000); } if(ckTestGenBal.Checked) { Invoke(new MethodInvoker(btnGenBal.PerformClick)); Thread.Sleep(3000); } if(ckTestGenNoise.Checked) { Invoke(new MethodInvoker(btnNoise.PerformClick)); Thread.Sleep(3000); } if(ckTestGenImpulse.Checked) { Invoke(new MethodInvoker(btnImpulse.PerformClick)); Thread.Sleep(3000); } if(ckTestGenPreamp.Checked) { Invoke(new MethodInvoker(btnGenPreamp.PerformClick)); Thread.Sleep(3000); } // re-run any Gen tests that failed if(ckTestGenPLL.Checked && btnPLL.BackColor != Color.Green) { Invoke(new MethodInvoker(btnPLL.PerformClick)); Thread.Sleep(1000); } if(ckTestGenBal.Checked && btnGenBal.BackColor != Color.Green) { Invoke(new MethodInvoker(btnGenBal.PerformClick)); Thread.Sleep(3000); } if(ckTestGenNoise.Checked && btnNoise.BackColor != Color.Green) { Invoke(new MethodInvoker(btnNoise.PerformClick)); Thread.Sleep(3000); } if(ckTestGenImpulse.Checked && btnImpulse.BackColor != Color.Green) { Invoke(new MethodInvoker(btnImpulse.PerformClick)); Thread.Sleep(3000); } if(ckTestGenPreamp.Checked && btnGenPreamp.BackColor != Color.Green) { Invoke(new MethodInvoker(btnGenPreamp.PerformClick)); Thread.Sleep(3000); } if((ckTestGenPLL.Checked && btnPLL.BackColor != Color.Green) || (ckTestGenBal.Checked && btnGenBal.BackColor != Color.Green) || (ckTestGenPreamp.Checked && btnGenPreamp.BackColor != Color.Green)) goto end; #endregion #region RX // run all RX tests if(ckTestRXFilter.Checked) { Invoke(new MethodInvoker(btnRXFilter.PerformClick)); while(true) { while(p.Visible) Thread.Sleep(2000); Thread.Sleep(2000); if(!p.Visible) break; } if(p.Text == "") goto end; } if(ckTestRXLevel.Checked) { Invoke(new MethodInvoker(btnRXLevel.PerformClick)); while(true) { while(!btnRXLevel.Enabled) Thread.Sleep(2000); Thread.Sleep(2000); if(btnRXLevel.Enabled) break; } if(p.Text == "") goto end; } if(ckTestRXImage.Checked) { Invoke(new MethodInvoker(btnRXImage.PerformClick)); while(true) { while(!btnRXImage.Enabled) Thread.Sleep(2000); Thread.Sleep(2000); if(btnRXImage.Enabled) break; } if(p.Text == "") goto end; } // re-run any RX tests that failed if(ckTestRXFilter.Checked && btnRXFilter.BackColor != Color.Green) { SetBandFromString(toolTip1.GetToolTip(btnRXFilter)); Invoke(new MethodInvoker(btnRXFilter.PerformClick)); while(true) { while(p.Visible) Thread.Sleep(2000); Thread.Sleep(2000); if(!p.Visible) break; } if(p.Text == "") goto end; } if(ckTestRXLevel.Checked && btnRXLevel.BackColor != Color.Green) { SetBandFromString(toolTip1.GetToolTip(btnRXLevel)); Invoke(new MethodInvoker(btnRXLevel.PerformClick)); while(true) { while(!btnRXLevel.Enabled) Thread.Sleep(2000); Thread.Sleep(2000); if(btnRXLevel.Enabled) break; } if(p.Text == "") goto end; } if(ckTestRXImage.Checked && btnRXImage.BackColor != Color.Green) { SetBandFromString(toolTip1.GetToolTip(btnRXImage)); Invoke(new MethodInvoker(btnRXImage.PerformClick)); while(true) { while(!btnRXImage.Enabled) Thread.Sleep(2000); Thread.Sleep(2000); if(btnRXImage.Enabled) break; } if(p.Text == "") goto end; } // reset bands back to start SetBandFromString(start_bands); /*if((ckTestRXFilter.Checked && btnRXFilter.BackColor != Color.Green) || (ckTestRXLevel.Checked && btnRXLevel.BackColor != Color.Green) || (ckTestRXImage.Checked && btnRXImage.BackColor != Color.Green) || (ckTestRXMDS.Checked && btnRXMDS.BackColor != Color.Green)) goto end;*/ #endregion #region TX // run all TX tests if(ckTestTXFilter.Checked) { Invoke(new MethodInvoker(btnTXFilter.PerformClick)); while(true) { while(p.Visible) Thread.Sleep(2000); Thread.Sleep(2000); if(!p.Visible) break; } if(p.Text == "") goto end; } if(ckTestTXImage.Checked) { Invoke(new MethodInvoker(btnTXImage.PerformClick)); while(true) { while(!btnTXImage.Enabled) Thread.Sleep(2000); Thread.Sleep(2000); if(btnTXImage.Enabled) break; } if(p.Text == "") goto end; } if(ckTestTXCarrier.Checked) { Invoke(new MethodInvoker(btnTXCarrier.PerformClick)); while(true) { while(!btnTXCarrier.Enabled) Thread.Sleep(2000); Thread.Sleep(2000); if(btnTXCarrier.Enabled) break; } if(p.Text == "") goto end; } // re-run any TX tests that failed if(ckTestTXFilter.Checked && btnTXFilter.BackColor != Color.Green) { SetBandFromString(toolTip1.GetToolTip(btnTXFilter)); Invoke(new MethodInvoker(btnTXFilter.PerformClick)); while(true) { while(p.Visible) Thread.Sleep(2000); Thread.Sleep(2000); if(!p.Visible) break; } if(p.Text == "") goto end; } if(ckTestTXImage.Checked && btnTXImage.BackColor != Color.Green) { SetBandFromString(toolTip1.GetToolTip(btnTXImage)); Invoke(new MethodInvoker(btnTXImage.PerformClick)); while(true) { while(!btnTXImage.Enabled) Thread.Sleep(2000); Thread.Sleep(2000); if(btnTXImage.Enabled) break; } if(p.Text == "") goto end; } if(ckTestTXCarrier.Checked && btnTXCarrier.BackColor != Color.Green) { SetBandFromString(toolTip1.GetToolTip(btnTXCarrier)); Invoke(new MethodInvoker(btnTXCarrier.PerformClick)); while(true) { while(!btnTXCarrier.Enabled) Thread.Sleep(2000); Thread.Sleep(2000); if(btnTXCarrier.Enabled) break; } if(p.Text == "") goto end; } SetBandFromString(start_bands); #endregion end: btnRunSelectedTests.BackColor = SystemColors.Control; btnRunSelectedTests.Enabled = true; console.RX2Enabled = rx2; t1.Stop(); MessageBox.Show("Run All Tests Time: "+((int)(t1.Duration/60)).ToString()+":"+(((int)t1.Duration)%60).ToString("00")); }
public void RunCalFWCTXCarrier() { float tol = -105.0f; test_tx_carrier = "TX Carrier Test: Passed"; double vfoa = console.VFOAFreq; double vfob = console.VFOBFreq; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M }; float[] band_freqs = { 1.85f, 3.75f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f}; for(int i=0; i<band_freqs.Length; i++) { bool do_band = false; switch(bands[i]) { case Band.B160M: do_band = ck160.Checked; break; case Band.B80M: do_band = ck80.Checked; break; case Band.B60M: do_band = ck60.Checked; break; case Band.B40M: do_band = ck40.Checked; break; case Band.B30M: do_band = ck30.Checked; break; case Band.B20M: do_band = ck20.Checked; break; case Band.B17M: do_band = ck17.Checked; break; case Band.B15M: do_band = ck15.Checked; break; case Band.B12M: do_band = ck12.Checked; break; case Band.B10M: do_band = ck10.Checked; break; case Band.B6M: do_band = ck6.Checked; break; } if(do_band) { p.SetPercent(0.0f); Invoke(new MethodInvoker(p.Show)); Application.DoEvents(); console.VFOAFreq = band_freqs[i]; console.VFOBFreq = band_freqs[i]; console.CalibrateTXCarrier(band_freqs[i], p, true); //if(console.min_tx_carrier[(int)bands[i]] > tol) // try again // console.CalibrateTXCarrier(band_freqs[i], p, true); if(p.Text == "") break; if(console.min_tx_carrier[(int)bands[i]] > tol) { if(!test_tx_carrier.StartsWith("TX Carrier Test: Failed (")) test_tx_carrier = "TX Carrier Test: Failed ("; test_tx_carrier += BandToString(bands[i])+", "; btnTXCarrier.BackColor = Color.Red; lstDebug.Items.Insert(0, "TX Carrier - "+BandToString(bands[i])+": Failed (" +console.min_tx_carrier[(int)bands[i]].ToString("f1")+")"); } else { lstDebug.Items.Insert(0, "TX Carrier - "+BandToString(bands[i])+": Passed (" +console.min_tx_carrier[(int)bands[i]].ToString("f1")+")"); } Thread.Sleep(500); } } console.VFOAFreq = vfoa; console.VFOBFreq = vfob; if(test_tx_carrier.StartsWith("TX Carrier Test: Failed (")) test_tx_carrier = test_tx_carrier.Substring(0, test_tx_carrier.Length-2)+")"; toolTip1.SetToolTip(btnTXCarrier, test_tx_carrier); t1.Stop(); Debug.WriteLine("TX Carrier Timer: "+t1.Duration); string path = Application.StartupPath+"\\Tests"; if(!Directory.Exists(path)) Directory.CreateDirectory(path); bool file_exists = File.Exists(path+"\\tx_carrier.csv"); StreamWriter writer = new StreamWriter(path+"\\tx_carrier.csv", true); if(!file_exists) writer.WriteLine("Serial Num, Date/Time, Version, " +"160m C0, 160m C1, 160m C2, 160m C3, 160m From Noise, " +"80m C0, 80m C1, 80m C2, 80m C3, 80m From Noise, " +"60m C0, 60m C1, 60m C2, 60m C3, 60m From Noise, " +"40m C0, 40m C1, 40m C2, 40m C3, 40m From Noise, " +"30m C0, 30m C1, 30m C2, 30m C3, 30m From Noise, " +"20m C0, 20m C1, 20m C2, 20m C3, 20m From Noise, " +"17m C0, 17m C1, 17m C2, 17m C3, 17m From Noise, " +"15m C0, 15m C1, 15m C2, 15m C3, 15m From Noise, " +"12m C0, 12m C1, 12m C2, 12m C3, 12m From Noise, " +"10m C0, 10m C1, 10m C2, 10m C3, 10m From Noise, " +"6m C0, 6m C1, 6m C2, 6m C3, 6m From Noise"); writer.Write(FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial)+"," +DateTime.Now.ToShortDateString()+" "+DateTime.Now.ToShortTimeString()+"," +console.Text+","); for(int i=0; i<bands.Length; i++) { for(int j=0; j<4; j++) writer.Write(console.tx_carrier_table[(int)bands[i]][j].ToString()+","); writer.Write(console.min_tx_carrier[(int)bands[i]].ToString("f1")+","); } writer.WriteLine(""); writer.Close(); path += "\\TX Carrier"; if(!Directory.Exists(path)) Directory.CreateDirectory(path); writer = new StreamWriter(path+"\\tx_carrier_"+FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial)+".csv"); writer.WriteLine("Band, C0, C1, C2, C3, From Noise"); for(int i=0; i<bands.Length; i++) { writer.Write(BandToString(bands[i])+","); for(int j=0; j<4; j++) writer.Write(console.tx_carrier_table[(int)bands[i]][j].ToString()+","); writer.WriteLine(console.min_tx_carrier[(int)bands[i]].ToString("f1")); } writer.Close(); lstDebug.Items.Insert(0, "Saving Carrier data to EEPROM..."); FWCEEPROM.WriteTXCarrier(console.tx_carrier_table); console.FLEX5000SyncCalDateTime(); lstDebug.Items[0] = "Saving Carrier data to EEPROM...done"; grpGeneral.Enabled = true; grpReceiver.Enabled = true; grpTransmitter.Enabled = true; }
private void PostFenceTest() { if(!console.PowerOn) { p.Hide(); MessageBox.Show("Power must be on to run this test.", "Power not on", MessageBoxButtons.OK, MessageBoxIcon.Error); grpGeneral.Enabled = true; grpReceiver.Enabled = true; grpTransmitter.Enabled = true; btnPostFence.Enabled = true; return; } HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); test_post_fence = "Post Fence: "; console.VFOSplit = false; btnPLL_Click(this, EventArgs.Empty); Thread.Sleep(1000); btnGenBal_Click(this, EventArgs.Empty); Thread.Sleep(3000); btnGenPreamp_Click(this, EventArgs.Empty); Thread.Sleep(3000); btnCheckAll_Click(this, EventArgs.Empty); btnRXFilter_Click(this, EventArgs.Empty); while(true) { while(p.Visible) Thread.Sleep(2000); Thread.Sleep(2000); if(!p.Visible) break; } if(p.Text == "") goto end; btnClearAll_Click(this, EventArgs.Empty); ck20.Checked = true; btnTXImage_Click(this, EventArgs.Empty); while(true) { while(!btnTXImage.Enabled) Thread.Sleep(2000); Thread.Sleep(2000); if(btnTXImage.Enabled) break; } if(p.Text == "") goto end; if(btnPLL.BackColor == Color.Green && btnGenBal.BackColor == Color.Green && btnRXFilter.BackColor == Color.Green && btnTXImage.BackColor == Color.Green) { btnPostFence.BackColor = Color.Green; test_post_fence += "Passed"; } else { btnPostFence.BackColor = Color.Red; test_post_fence += "Failed"; } end: p.Hide(); FWC.SetFullDuplex(false); Thread.Sleep(50); grpGeneral.Enabled = true; grpReceiver.Enabled = true; grpTransmitter.Enabled = true; btnPostFence.Enabled = true; t1.Stop(); MessageBox.Show("Post Fence Time: "+((int)(t1.Duration/60)).ToString()+":"+(((int)t1.Duration)%60).ToString("00")); /*string test_verify_rx_level = ""; string test_verify_rx_image = ""; string test_verify_tx_image = ""; string test_verify_tx_carrier = ""; bool pass_rx_level = false; bool pass_rx_image = false; bool pass_tx_image = false; bool pass_tx_carrier = false; Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M }; float[] band_freqs = { 1.85f, 3.75f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f}; float[] a = new float[Display.BUFFER_SIZE]; int counter = 0; bool spur_red = console.SpurReduction; console.SpurReduction = false; string display = console.DisplayModeText; console.DisplayModeText = "Spectrum"; PreampMode preamp = console.RX1PreampMode; DSPMode dsp_mode = console.RX1DSPMode; Filter filter = console.RX1Filter; int rx_filt_high = console.RX1FilterHigh; int rx_filt_low = console.RX1FilterLow; int tx_filt_high = console.SetupForm.TXFilterHigh; int tx_filt_low = console.SetupForm.TXFilterLow; bool rit_on = console.RITOn; console.RITOn = false; bool xit_on = console.XITOn; console.XITOn = false; bool split = console.VFOSplit; int dsp_buf_size = console.SetupForm.DSPRXBufferSize; // save current DSP buffer size console.SetupForm.DSPRXBufferSize = 4096; // set DSP Buffer Size to 2048 bool polyphase = console.SetupForm.Polyphase; // save current polyphase setting console.SetupForm.Polyphase = false; // disable polyphase int num_bands = 0; for(int i=0; i<band_freqs.Length; i++) { bool do_band = false; switch(bands[i]) { case Band.B160M: do_band = ck160.Checked; break; case Band.B80M: do_band = ck80.Checked; break; case Band.B60M: do_band = ck60.Checked; break; case Band.B40M: do_band = ck40.Checked; break; case Band.B30M: do_band = ck30.Checked; break; case Band.B20M: do_band = ck20.Checked; break; case Band.B17M: do_band = ck17.Checked; break; case Band.B15M: do_band = ck15.Checked; break; case Band.B12M: do_band = ck12.Checked; break; case Band.B10M: do_band = ck10.Checked; break; case Band.B6M: do_band = ck6.Checked; break; } if(do_band) num_bands++; } int total_counts = num_bands*(10+10+10+5); for(int i=0; i<bands.Length; i++) { bool do_band = false; switch(bands[i]) { case Band.B160M: do_band = ck160.Checked; break; case Band.B80M: do_band = ck80.Checked; break; case Band.B60M: do_band = ck60.Checked; break; case Band.B40M: do_band = ck40.Checked; break; case Band.B30M: do_band = ck30.Checked; break; case Band.B20M: do_band = ck20.Checked; break; case Band.B17M: do_band = ck17.Checked; break; case Band.B15M: do_band = ck15.Checked; break; case Band.B12M: do_band = ck12.Checked; break; case Band.B10M: do_band = ck10.Checked; break; case Band.B6M: do_band = ck6.Checked; break; } if(do_band) { // verify RX Level FWC.SetTest(true); FWC.SetSig(true); FWC.SetGen(true); FWC.SetTXMon(false); FWC.SetFullDuplex(true); console.VFOAFreq = band_freqs[i]; Thread.Sleep(50); console.VFOBFreq = band_freqs[i]; console.RX1PreampMode = PreampMode.HIGH; console.RX1DSPMode = DSPMode.DSB; console.RX1Filter = Filter.VAR1; console.RX1FilterLow = -500; console.RX1FilterHigh = 500; Thread.Sleep(750); int peak_bin = -1; console.calibration_mutex.WaitOne(); fixed(float* ptr = &a[0]) DttSP.GetSpectrum(0, ptr); console.calibration_mutex.ReleaseMutex(); float max = float.MinValue; for(int j=0; j<Display.BUFFER_SIZE; j++) { if(a[j] > max) { max = a[j]; peak_bin = j; } } float sum_d = 0.0f; for(int j=0; j<5; j++) { console.calibration_mutex.WaitOne(); fixed(float* ptr = &a[0]) DttSP.GetSpectrum(0, ptr); console.calibration_mutex.ReleaseMutex(); sum_d += a[peak_bin]; if(j != 4) Thread.Sleep(100); if(!p.Visible) { p.Text = ""; goto end; } p.SetPercent(++counter/(float)total_counts); } sum_d /= 5; sum_d = sum_d + Display.DisplayCalOffset + Display.PreampOffset; float sum_m = 0.0f; DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH); Thread.Sleep(50); for(int j=0; j<5; j++) { sum_m += DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH); if(j != 4) Thread.Sleep(50); if(!p.Visible) { p.Text = ""; goto end; } p.SetPercent(++counter/(float)total_counts); } sum_m /= 5; sum_m = sum_m + console.MultiMeterCalOffset + console.PreampOffset + console.RXPathOffset; pass_rx_level = (Math.Abs(-25.0 - sum_d) < 1.0f) && (Math.Abs(-25.0 - sum_m) < 1.0f); if(pass_rx_level) { lstDebug.Items.Insert(0, "Verify RX Level "+BandToString(bands[i])+": Passed ("+sum_d.ToString("f1")+", "+sum_m.ToString("f1")+")"); } else { lstDebug.Items.Insert(0, "Verify RX Level "+BandToString(bands[i])+": Failed ("+sum_d.ToString("f1")+", "+sum_m.ToString("f1")+")"); if(!test_verify_rx_level.StartsWith("RX Level Failed (")) test_verify_rx_level = "RX Level Failed ("; test_verify_rx_level += BandToString(bands[i])+", "; if(btnPostFence.BackColor != Color.Red) btnPostFence.BackColor = Color.Red; } // verify RX Image console.VFOSplit = true; FWC.SetQSE(false); console.VFOAFreq = band_freqs[i]; Thread.Sleep(50); console.VFOBFreq = band_freqs[i]; Thread.Sleep(750); float fundamental = 0.0f; DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH); Thread.Sleep(50); for(int j=0; j<5; j++) { fundamental += DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH); if(j != 4) Thread.Sleep(50); if(!p.Visible) { p.Text = ""; goto end; } p.SetPercent(++counter/(float)total_counts); } fundamental /= 5; fundamental = fundamental + console.MultiMeterCalOffset + console.PreampOffset + console.RXPathOffset; console.VFOAFreq = band_freqs[i]+2*console.IFFreq; Thread.Sleep(500); float image = 0.0f; DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH); Thread.Sleep(50); for(int j=0; j<5; j++) { image += DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH); if(j != 4) Thread.Sleep(50); if(!p.Visible) { p.Text = ""; goto end; } p.SetPercent(++counter/(float)total_counts); } image /= 5; image = image + console.MultiMeterCalOffset + console.PreampOffset + console.RXPathOffset; float rejection = fundamental - image; pass_rx_image = (rejection >= 60.0f); if(pass_rx_image) { lstDebug.Items.Insert(0, "Verify RX Image "+BandToString(bands[i])+": Passed ("+fundamental.ToString("f1")+", "+image.ToString("f1")+", "+rejection.ToString("f1")+")"); } else { lstDebug.Items.Insert(0, "Verify RX Image "+BandToString(bands[i])+": Failed ("+fundamental.ToString("f1")+", "+image.ToString("f1")+", "+rejection.ToString("f1")+")"); if(!test_verify_rx_image.StartsWith("RX Image Failed (")) test_verify_rx_image = "RX Image Failed ("; test_verify_rx_image += BandToString(bands[i])+", "; if(btnPostFence.BackColor != Color.Red) btnPostFence.BackColor = Color.Red; } console.VFOSplit = false; // verify TX Image console.FullDuplex = true; Audio.TXInputSignal = Audio.SignalSource.SINE; double last_scale = Audio.SourceScale; // saved audio scale Audio.SourceScale = 1.0; double tone_freq = Audio.SineFreq1; // save tone freq Audio.SineFreq1 = 1500.0; // set freq int pwr = console.PWR; console.PWR = 100; Audio.RadioVolume = 0.200; FWC.SetQSD(true); FWC.SetQSE(true); FWC.SetTR(true); FWC.SetSig(true); FWC.SetGen(false); FWC.SetTest(true); FWC.SetTXMon(false); console.SetupForm.TXFilterLow = 300; console.SetupForm.TXFilterHigh = 3000; console.VFOAFreq = band_freqs[i]; Thread.Sleep(50); console.VFOBFreq = band_freqs[i]; console.RX1DSPMode = DSPMode.USB; console.UpdateFilters(300, 3000); Thread.Sleep(750); fundamental = 0.0f; DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH); Thread.Sleep(50); for(int j=0; j<5; j++) { fundamental += DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH); if(j != 4) Thread.Sleep(50); if(!p.Visible) { p.Text = ""; goto end; } p.SetPercent(++counter/(float)total_counts); } fundamental /= 5; fundamental = fundamental + console.MultiMeterCalOffset + console.PreampOffset + console.RXPathOffset; console.UpdateFilters(-1550, -1450); Thread.Sleep(500); image = 0.0f; DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH); Thread.Sleep(50); for(int j=0; j<5; j++) { image += DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH); if(j != 4) Thread.Sleep(50); if(!p.Visible) { p.Text = ""; goto end; } p.SetPercent(++counter/(float)total_counts); } image /= 5; image = image + console.MultiMeterCalOffset + console.PreampOffset + console.RXPathOffset; rejection = fundamental - image; pass_tx_image = (rejection >= 60.0); if(pass_tx_image) { lstDebug.Items.Insert(0, "Verify TX Image "+BandToString(bands[i])+": Passed ("+fundamental.ToString("f1")+", "+image.ToString("f1")+", "+rejection.ToString("f1")+")"); } else { lstDebug.Items.Insert(0, "Verify TX Image "+BandToString(bands[i])+": Failed ("+fundamental.ToString("f1")+", "+image.ToString("f1")+", "+rejection.ToString("f1")+")"); if(!test_verify_tx_image.StartsWith("TX Image Failed (")) test_verify_tx_image = "TX Image Failed ("; test_verify_tx_image += BandToString(bands[i])+", "; if(btnPostFence.BackColor != Color.Red) btnPostFence.BackColor = Color.Red; } Audio.TXInputSignal = Audio.SignalSource.RADIO; Audio.SourceScale = last_scale; // recall tone scale Audio.SineFreq1 = tone_freq; // recall tone freq console.PWR = pwr; FWC.SetTR(false); // verify TX Carrier FWC.SetQSD(true); FWC.SetQSE(true); FWC.SetSig(true); FWC.SetGen(false); FWC.SetTest(true); FWC.SetTXMon(false); Audio.TXInputSignal = Audio.SignalSource.SILENCE; console.VFOAFreq = band_freqs[i]; console.VFOBFreq = band_freqs[i]; console.RX1DSPMode = DSPMode.DSB; console.UpdateFilters(-500, 500); Thread.Sleep(500); float carrier = 0.0f; DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH); Thread.Sleep(50); for(int j=0; j<5; j++) { carrier += DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH); if(j != 4) Thread.Sleep(50); if(!p.Visible) { p.Text = ""; goto end; } p.SetPercent(++counter/(float)total_counts); } carrier /= 5; carrier = carrier + console.MultiMeterCalOffset + console.PreampOffset + console.RXPathOffset; pass_tx_carrier = (carrier <= -105.0); if(pass_tx_carrier) { lstDebug.Items.Insert(0, "Verify TX Carrier "+BandToString(bands[i])+": Passed ("+carrier.ToString("f1")+")"); } else { lstDebug.Items.Insert(0, "Verify TX Carrier "+BandToString(bands[i])+": Failed ("+carrier.ToString("f1")+")"); if(!test_verify_tx_carrier.StartsWith("TX Carrier Failed (")) test_verify_tx_carrier = "TX Carrier Failed ("; test_verify_tx_carrier += BandToString(bands[i])+", "; if(btnPostFence.BackColor != Color.Red) btnPostFence.BackColor = Color.Red; } Audio.TXInputSignal = Audio.SignalSource.RADIO; } } if(!test_verify_rx_level.StartsWith("RX Level Failed (")) test_verify_rx_level = "RX Level Passed\n"; else test_verify_rx_level = test_verify_rx_level.Substring(0, test_verify_rx_level.Length-2)+")\n"; if(!test_verify_rx_image.StartsWith("RX Image Failed (")) test_verify_rx_image = "RX Image Passed\n"; else test_verify_rx_image = test_verify_rx_image.Substring(0, test_verify_rx_image.Length-2)+")\n"; if(!test_verify_tx_image.StartsWith("TX Image Failed (")) test_verify_tx_image = "TX Image Passed\n"; else test_verify_tx_image = test_verify_tx_image.Substring(0, test_verify_tx_image.Length-2)+")\n"; if(!test_verify_tx_carrier.StartsWith("TX Carrier Failed (")) test_verify_tx_carrier = "TX Carrier Passed\n"; else test_verify_tx_carrier = test_verify_tx_carrier.Substring(0, test_verify_tx_carrier.Length-2)+")"; test_post_fence = test_verify_rx_level + test_verify_rx_image + test_verify_tx_image + test_verify_tx_carrier; end: FWC.SetTest(false); FWC.SetTR(false); FWC.SetGen(false); FWC.SetSig(false); FWC.SetTXMon(false); FWC.SetFullDuplex(false); console.FullDuplex = false; console.SpurReduction = spur_red; console.DisplayModeText = display; console.RX1PreampMode = preamp; console.RX1DSPMode = dsp_mode; console.RX1Filter = filter; if(filter == Filter.VAR1 || filter == Filter.VAR2) { console.RX1FilterHigh = rx_filt_high; console.RX1FilterLow = rx_filt_low; } console.RITOn = rit_on; console.XITOn = xit_on; console.VFOSplit = split; console.SetupForm.DSPRXBufferSize = dsp_buf_size; // set DSP Buffer Size to 2048 console.SetupForm.Polyphase = polyphase; // disable polyphase toolTip1.SetToolTip(btnPostFence, test_post_fence); p.Hide(); FWC.SetFullDuplex(false); grpGeneral.Enabled = true; grpReceiver.Enabled = true; grpTransmitter.Enabled = true; btnPostFence.Enabled = true; t1.Stop(); MessageBox.Show("Verify Time: "+((int)(t1.Duration/60)).ToString()+":"+(((int)t1.Duration)%60).ToString("00")); */ }
public void RunCalFWCRXLevel() { float[] offset_avg = {-59.3f, -60.5f, -61.1f, -61.4f, -60.8f, -60.5f, -60.0f, -59.5f, -59.5f, -59.5f, -59.6f}; float[] preamp_avg = {-13.4f, -7.0f, -13.3f, -13.6f, -14.0f, -14.0f, -14.0f, -13.8f, -13.8f, -13.8f, -13.7f}; float offset_tol = 2.5f; // maximum distance from the average value float preamp_tol = 1.5f; test_rx_level = "RX Level Test: Passed"; double vfoa = console.VFOAFreq; double vfob = console.VFOBFreq; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); Band[] bands = { Band.B6M, Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M }; float[] band_freqs = { 50.11f, 1.85f, 3.75f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f }; for(int i=0; i<band_freqs.Length; i++) { bool do_band = false; switch(bands[i]) { case Band.B160M: do_band = ck160.Checked; break; case Band.B80M: do_band = ck80.Checked; break; case Band.B60M: do_band = ck60.Checked; break; case Band.B40M: do_band = ck40.Checked; break; case Band.B30M: do_band = ck30.Checked; break; case Band.B20M: do_band = ck20.Checked; break; case Band.B17M: do_band = ck17.Checked; break; case Band.B15M: do_band = ck15.Checked; break; case Band.B12M: do_band = ck12.Checked; break; case Band.B10M: do_band = ck10.Checked; break; case Band.B6M: do_band = ck6.Checked; break; } if(do_band) { p.SetPercent(0.0f); Invoke(new MethodInvoker(p.Show)); Application.DoEvents(); console.VFOAFreq = band_freqs[i]; console.VFOBFreq = band_freqs[i]; console.CalibrateLevel(-24.0f, band_freqs[i], p, true); if(p.Text == "") break; if(Math.Abs(console.GetRX1Level(bands[i], 0)-offset_avg[i]) > offset_tol || Math.Abs(console.GetRX1Level(bands[i], 1)-preamp_avg[i]) > preamp_tol) { btnRXLevel.BackColor = Color.Red; if(!test_rx_level.StartsWith("RX Level Test: Failed (")) test_rx_level = "RX Level Test: Failed ("; test_rx_level += BandToString(bands[i])+", "; lstDebug.Items.Insert(0, "RX Level Test - "+BandToString(bands[i])+": Failed (" +console.GetRX1Level(bands[i], 0).ToString("f1")+", " +console.GetRX1Level(bands[i], 1).ToString("f1")+", " +console.GetRX1Level(bands[i], 2).ToString("f1")+")"); } else { lstDebug.Items.Insert(0, "RX Level Test - "+BandToString(bands[i])+": Passed (" +console.GetRX1Level(bands[i], 0).ToString("f1")+", " +console.GetRX1Level(bands[i], 1).ToString("f1")+", " +console.GetRX1Level(bands[i], 2).ToString("f1")+")"); } Thread.Sleep(500); } } if(test_rx_level.StartsWith("RX Level Test: Failed (")) test_rx_level = test_rx_level.Substring(0, test_rx_level.Length-2)+")"; toolTip1.SetToolTip(btnRXLevel, test_rx_level); console.VFOAFreq = vfoa; console.VFOBFreq = vfob; t1.Stop(); Debug.WriteLine("RX Level Timer: "+t1.Duration); string path = Application.StartupPath+"\\Tests"; if(!Directory.Exists(path)) Directory.CreateDirectory(path); bool file_exists = File.Exists(path+"\\rx_level.csv"); StreamWriter writer = new StreamWriter(path+"\\rx_level.csv", true); if(!file_exists) writer.WriteLine("Serial Num, Date/Time, Version, " +"6m display offset, 6m preamp offset, 6m multimeter offset, " +"160m display offset, 160m preamp offset, 160m multimeter offset, " +"80m display offset, 80m preamp offset, 80m multimeter offset, " +"60m display offset, 60m preamp offset, 60m multimeter offset, " +"40m display offset, 40m preamp offset, 40m multimeter offset, " +"30m display offset, 30m preamp offset, 30m multimeter offset, " +"20m display offset, 20m preamp offset, 20m multimeter offset, " +"17m display offset, 17m preamp offset, 17m multimeter offset, " +"15m display offset, 15m preamp offset, 15m multimeter offset, " +"12m display offset, 12m preamp offset, 12m multimeter offset, " +"10m display offset, 10m preamp offset, 10m multimeter offset"); writer.Write(FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial)+"," +DateTime.Now.ToShortDateString()+" "+DateTime.Now.ToShortTimeString()+"," +console.Text+","); for(int i=0; i<bands.Length; i++) { for(int j=0; j<3; j++) { writer.Write(console.GetRX1Level(bands[i], j).ToString("f1")); if(i!=bands.Length-1 || j!=2) writer.Write(","); } } writer.WriteLine(""); writer.Close(); path += "\\RX Level"; if(!Directory.Exists(path)) Directory.CreateDirectory(path); writer = new StreamWriter(path+"\\rx_level_"+FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial)+".csv"); writer.WriteLine("Band, Display Offset, Preamp Offset, Multimeter Offset"); for(int i=0; i<bands.Length; i++) { writer.Write(BandToString(bands[i])+","); writer.Write(console.GetRX1Level(bands[i], 0).ToString("f1")+","); writer.Write(console.GetRX1Level(bands[i], 1).ToString("f1")+","); writer.WriteLine(console.GetRX1Level(bands[i], 2).ToString("f1")); } writer.Close(); lstDebug.Items.Insert(0, "Saving Level data to EEPROM..."); FWCEEPROM.WriteRXLevel(console.rx1_level_table); console.FLEX5000SyncCalDateTime(); lstDebug.Items[0] = "Saving Level data to EEPROM...done"; grpGeneral.Enabled = true; grpReceiver.Enabled = true; grpTransmitter.Enabled = true; }
public void RunCalFWCTXImage() { float tol = -55.0f; test_tx_image = "TX Image Test: Passed"; if (!console.PowerOn) { console.PowerOn = true; Thread.Sleep(500); } if (console.VFOSync) console.VFOSync = false; double vfoa = console.VFOAFreq; double vfob = console.VFOBFreq; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M }; float[] band_freqs = { 1.85f, 3.75f, 5.357f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f }; for (int i = 0; i < band_freqs.Length; i++) { bool do_band = false; switch (bands[i]) { case Band.B160M: do_band = ck160.Checked; break; case Band.B80M: do_band = ck80.Checked; break; case Band.B60M: { if (console.CurrentRegion == FRSRegion.US) { do_band = ck60.Checked; break; } else { lstDebug.Items.Insert(0, "TX Image - " + BandToString(bands[i]) + ": Result OK"); continue; } } case Band.B40M: do_band = ck40.Checked; break; case Band.B30M: do_band = ck30.Checked; break; case Band.B20M: do_band = ck20.Checked; break; case Band.B17M: do_band = ck17.Checked; break; case Band.B15M: do_band = ck15.Checked; break; case Band.B12M: do_band = ck12.Checked; break; case Band.B10M: do_band = ck10.Checked; break; case Band.B6M: do_band = ck6.Checked; break; } if (do_band) { p.SetPercent(0.0f); Invoke(new MethodInvoker(p.Show)); Application.DoEvents(); console.VFOAFreq = band_freqs[i]; console.VFOBFreq = band_freqs[i]; console.CalibrateTXImage(band_freqs[i], p, true); if (p.Text == "") break; if (console.tx_image_rejection[(int)bands[i]] > tol) { if (!test_tx_image.StartsWith("TX Image Test: Failed (")) test_tx_image = "TX Image Test: Failed ("; test_tx_image += BandToString(bands[i]) + ","; btnTXImage.BackColor = Color.Red; lstDebug.Items.Insert(0, "TX Image - " + BandToString(bands[i]) + ": Failed (" + console.tx_image_rejection[(int)bands[i]].ToString("f1") + ")"); } else { lstDebug.Items.Insert(0, "TX Image - " + BandToString(bands[i]) + ": Passed (" + console.tx_image_rejection[(int)bands[i]].ToString("f1") + ")"); } Thread.Sleep(500); } } console.VFOAFreq = vfoa; console.VFOBFreq = vfob; t1.Stop(); Debug.WriteLine("TX Image Timer: " + t1.Duration); if (test_tx_image.StartsWith("TX Image Test: Failed (")) test_tx_image = test_tx_image.Substring(0, test_tx_image.Length - 1) + ")"; toolTip1.SetToolTip(btnTXImage, test_tx_image); string path = console.AppDataPath + "\\Tests"; if (!Directory.Exists(path)) Directory.CreateDirectory(path); bool file_exists = File.Exists(path + "\\tx_image.csv"); StreamWriter writer = new StreamWriter(path + "\\tx_image.csv", true); string serial = ""; switch (console.CurrentModel) { case Model.FLEX5000: case Model.FLEX3000: serial = FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial); break; case Model.FLEX1500: serial = HIDEEPROM.SerialToString(HIDEEPROM.SerialNumber); break; } if (!file_exists) writer.WriteLine("Model, Serial Num, Date/Time, Version, " + "160m gain, 160m phase, 160m rejection, " + "80m gain, 80m phase, 80m rejection, " + "60m gain, 60m phase, 60m rejection, " + "40m gain, 40m phase, 40m rejection, " + "30m gain, 30m phase, 30m rejection, " + "20m gain, 20m phase, 20m rejection, " + "17m gain, 17m phase, 17m rejection, " + "15m gain, 15m phase, 15m rejection, " + "12m gain, 12m phase, 12m rejection, " + "10m gain, 10m phase, 10m rejection, " + "6m gain, 6m phase, 6m rejection, "); writer.Write(console.CurrentModel.ToString() + "," + serial + "," + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "," + console.Text + ","); for (int i = 0; i < bands.Length; i++) { writer.Write(console.tx_image_gain_table[(int)bands[i]].ToString("f3") + ","); writer.Write(console.tx_image_phase_table[(int)bands[i]].ToString("f3") + ","); writer.Write(console.tx_image_rejection[(int)bands[i]].ToString("f1") + ","); } writer.WriteLine(""); writer.Close(); path += "\\TX Image"; if (!Directory.Exists(path)) Directory.CreateDirectory(path); string model = ""; switch (console.CurrentModel) { case Model.FLEX3000: model = "F3K"; break; case Model.FLEX5000: model = "F5K"; break; case Model.FLEX1500: model = "F1.5K"; break; } writer = new StreamWriter(path + "\\tx_image_" + model + "_" + serial + ".csv"); writer.WriteLine("Band, Gain, Phase, Rejection dBc"); for (int i = 0; i < bands.Length; i++) { writer.Write(BandToString(bands[i]) + ","); writer.Write(console.tx_image_gain_table[(int)bands[i]].ToString("f3") + ","); writer.Write(console.tx_image_phase_table[(int)bands[i]].ToString("f3") + ","); writer.WriteLine(console.tx_image_rejection[(int)bands[i]].ToString("f1")); } writer.Close(); lstDebug.Items.Insert(0, "Saving TX Image data to EEPROM..."); byte gain_sum = 0, phase_sum = 0; switch (console.CurrentModel) { case Model.FLEX5000: case Model.FLEX3000: FWCEEPROM.WriteTXImage(console.tx_image_gain_table, console.tx_image_phase_table, out gain_sum, out phase_sum); break; case Model.FLEX1500: HIDEEPROM.WriteTXImage(console.tx_image_gain_table, console.tx_image_phase_table, out gain_sum, out phase_sum); break; } console.tx_image_gain_checksum = gain_sum; console.tx_image_phase_checksum = phase_sum; console.SyncCalDateTime(); lstDebug.Items[0] = "Saving TX Image data to EEPROM...done"; grpGeneral.Enabled = true; grpReceiver.Enabled = true; grpTransmitter.Enabled = true; grpIO.Enabled = true; }
private void btnEEWrite_Click(object sender, EventArgs e) { ushort offset = ushort.Parse(txtOffset.Text, NumberStyles.HexNumber); byte num_bytes = byte.Parse(txtNumBytes.Text, NumberStyles.HexNumber); if (num_bytes > txtData.Text.Length / 2) { MessageBox.Show("Error: Not enough data"); return; } byte[] data = new byte[num_bytes]; for(int i=0; i<num_bytes; i++) data[i] = byte.Parse(txtData.Text.Substring(i*2, 2), NumberStyles.HexNumber); HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val; //fixed(byte* ptr = &data[0]) val = Flex1500.WriteEEPROM(offset, data); t1.Stop(); Debug.WriteLine("EEWrite: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); }
private void btnRead_Click(object sender, EventArgs e) { uint op = uint.Parse(txtOpcode.Text); uint p1 = uint.Parse(txtParam1.Text, NumberStyles.HexNumber); uint p2 = uint.Parse(txtParam2.Text, NumberStyles.HexNumber); HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); uint result; int val = Flex1500.ReadOp((USBHID.Opcode)op, p1, p2, out result); t1.Stop(); Debug.WriteLine("ReadOp: "+val+" ("+t1.DurationMsec.ToString("f2")+")"); txtResult.Text = result.ToString(); }
private void btnTune_Click(object sender, EventArgs e) { if (txtTune.Text == "") return; double freq; bool b = double.TryParse(txtTune.Text, out freq); if (!b) return; uint ftw = (uint)(Math.Pow(2.0, 32) * freq*2 / 384.0); HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val = USBHID.SetFreqTW(ftw); t1.Stop(); Debug.WriteLine("Tune: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); }
private void btnI2CWrite2_Click(object sender, EventArgs e) { byte addr = byte.Parse(txtI2CAddr.Text, NumberStyles.HexNumber); byte b1 = byte.Parse(txtI2CByte1.Text, NumberStyles.HexNumber); byte b2 = byte.Parse(txtI2CByte2.Text, NumberStyles.HexNumber); HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val = USBHID.WriteI2C2Value(addr, b1, b2); t1.Stop(); Debug.WriteLine("I2C2: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); }
private void progressBarTuning() { float maxTuningTime_ms = 25000; float offset = 0; float multiplier = 1; bool slowDown = false; float percent = 0; HiPerfTimer t3 = new HiPerfTimer(); t3.Start(); Progress p = new Progress("ATU Tuning Progress"); p.SetPercent(0.0f); console.Invoke(new MethodInvoker(p.Show)); while (tuningDLL)// && t3.DurationMsec< maxTuningTime_ms*2) { t3.Stop(); if (t3.DurationMsec > maxTuningTime_ms / 2 && slowDown == false) { t3.Start(); offset = 0.5f; multiplier = 2; slowDown = true; } percent = offset + (float)t3.DurationMsec / (maxTuningTime_ms * multiplier); if (percent < .98) { p.SetPercent(percent); } else { p.SetPercent(.98f); } if (!p.Visible) { abort = true; } Thread.Sleep(400); } p.SetPercent(1); Thread.Sleep(500); p.Hide(); }
private void TuneATU() { //console.FWCATUTuned(); Debug.WriteLine("***Entering TuneATU()*****"); HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); Thread t2 = new Thread(new ThreadStart(progressBarTuning)); t2.Name = "ATU Progress Bar Thread"; t2.IsBackground = true; t2.Priority = ThreadPriority.Normal; t2.Start(); double start_swr = 99; int SLEEP_TIME = (int)udSleepTime.Value; int OFF_SLEEP = (int)udOffSleep.Value; int TUN_LVL = (int)udTunPower.Value; int old_power = console.TunePower; if (abort) { last_tune_result = TuneResult.TuneAborted; goto end; } string last_tune_result_string = last_tune_result.ToString(); string version = console.getVersion(); button1.Focus(); try { #if(!NO_NEW_ATU) ATUClass obj = new ATUClass(); MemoryTune.Hide(); console.TunePower = 10; //Thread.Sleep(OFF_SLEEP); // Audio_RadioVolumeSaved = Audio.RadioVolume; version = console.getVersion(); ////////////***load atu profiles if ATU button is pressed first if (comboAntProfileName.Items.Count == 0) { profileList = obj.Init(version, ref currentProfileName, true, ref high_swr, ref high_swr_no_limit, ref swr_thresh, ref swr_retune_target); } else { profileList = obj.Init(version, ref currentProfileName, false, ref high_swr, ref high_swr_no_limit, ref swr_thresh, ref swr_retune_target); } if (profileList.Count == 0 && comboAntProfileName.Items.Count == 0) { currentProfileName = "Default Profile"; comboAntProfileName.Items.Add(currentProfileName); comboAntProfileName.SelectedItem = currentProfileName; } else { foreach (string s in profileList) { if (!comboAntProfileName.Items.Contains(s)) { comboAntProfileName.Items.Add(s); } } comboAntProfileName.SelectedItem = currentProfileName; //last saved profile (from database) } ///////*** obj.DoWork( (int)console.RX1Band, autoMode, ref high_swr, ref high_swr_no_limit, ref swr_retune_target, ref swr_thresh, force_retune, ref currentProfileName, ref deletedProfileList, ref start_swr, console.atu_tuning, ref version, ref SLEEP_TIME, ref OFF_SLEEP, ref TUN_LVL, ref byp_swr, ref tun_swr, ref byp_fwd_pow, ref tun_fwd_pow, ref byp_ref_pow, ref tun_ref_pow, ref abort, ref tuning, console.VFOAFreq, ref last_tune_result_string, FWC.SetATUEnable, FWC.SetHiZ, SetL, SetC, getSWR, console_TunePower, //console_TunePower, Audio_RadioVolume, ref Audio_RadioVolumeSaved, console_TUN, console_TUN, rdBypass_Checked, rdBypass_Checked, rdTune_Checked, rdTune_Checked, setlblHiZ_Visible); //autoMode = false; if (start_swr == 99 && !rdBypass.Checked) { MemoryTune.Show(); } #endif } catch (Exception) { } if (last_tune_result_string == "TuneSuccessful") last_tune_result = TuneResult.TuneSuccessful; else if (last_tune_result_string == "TuneOK") last_tune_result = TuneResult.TuneOK; else if (last_tune_result_string == "TuneFailedHighSWR") last_tune_result = TuneResult.TuneFailedHighSWR; else if (last_tune_result_string == "TuneAborted") last_tune_result = TuneResult.TuneAborted; else if (last_tune_result_string == "TunerNotNeeded") last_tune_result = TuneResult.TunerNotNeeded; else if (last_tune_result_string == "TuneFailedNoRF") last_tune_result = TuneResult.TuneFailedNoRF; else if (last_tune_result_string == "TuneAutoModeTune") last_tune_result = TuneResult.TuneAutoModeTune; else if (last_tune_result_string == "TuneAutoModeBypass") last_tune_result = TuneResult.TuneAutoModeBypass; end: t1.Stop(); Debug.WriteLine("The SWR has been reduced to " + tun_swr + " from " + byp_swr + "(" + start_swr + ") in " + t1.Duration.ToString("f1") + " seconds"); LogMessageToFile("****The SWR at " + console.VFOAFreq + " MHz has been reduced to " + tun_swr + " from " + byp_swr + "(" + start_swr + ") in " + t1.Duration.ToString("f1") + " seconds***"); tuning = false; console.TUN = false; console.TunePower = old_power; rdTune.Checked = false; console.atu_tuning = false; abort = false; lblTime.Text = "Time: " + t1.Duration.ToString("f1"); UpdateFeedbackNew(); tuningDLL = false; autoMode = false; }
public void RunCalFWCTXCarrier() { float tol = -105.0f; test_tx_carrier = "TX Carrier Test: Passed"; if (!console.PowerOn) { console.PowerOn = true; Thread.Sleep(500); } if (console.VFOSync) console.VFOSync = false; double vfoa = console.VFOAFreq; double vfob = console.VFOBFreq; int tx_low = console.TXFilterLow; console.TXFilterLow = 100; int tx_high = console.TXFilterHigh; console.TXFilterHigh = 200; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M }; double[] band_freqs = { 1.85, 3.75, 5.357, 7.15, 10.125, 14.175, 18.1, 21.300, 24.9, 28.4, 50.11 }; for (int i = 0; i < band_freqs.Length; i++) { bool do_band = false; switch (bands[i]) { case Band.B160M: do_band = ck160.Checked; break; case Band.B80M: do_band = ck80.Checked; break; case Band.B60M: { if (console.CurrentRegion == FRSRegion.US) { do_band = ck60.Checked; break; } else { lstDebug.Items.Insert(0, "TX Carrier - " + BandToString(bands[i]) + ": Result OK"); continue; } } case Band.B40M: do_band = ck40.Checked; break; case Band.B30M: do_band = ck30.Checked; break; case Band.B20M: do_band = ck20.Checked; break; case Band.B17M: do_band = ck17.Checked; break; case Band.B15M: do_band = ck15.Checked; break; case Band.B12M: do_band = ck12.Checked; break; case Band.B10M: do_band = ck10.Checked; break; case Band.B6M: do_band = ck6.Checked; break; } if (do_band) { p.SetPercent(0.0f); Invoke(new MethodInvoker(p.Show)); Application.DoEvents(); console.VFOAFreq = band_freqs[i]; console.VFOBFreq = band_freqs[i]; console.CalibrateTXCarrier(band_freqs[i], p, true); //if(console.min_tx_carrier[(int)bands[i]] > tol) // try again // console.CalibrateTXCarrier(band_freqs[i], p, true); if (p.Text == "") break; if (console.min_tx_carrier[(int)bands[i]] > tol) { if (!test_tx_carrier.StartsWith("TX Carrier Test: Failed (")) test_tx_carrier = "TX Carrier Test: Failed ("; test_tx_carrier += BandToString(bands[i]) + ","; btnTXCarrier.BackColor = Color.Red; lstDebug.Items.Insert(0, "TX Carrier - " + BandToString(bands[i]) + ": Failed (" + console.min_tx_carrier[(int)bands[i]].ToString("f1") + ")"); } else { lstDebug.Items.Insert(0, "TX Carrier - " + BandToString(bands[i]) + ": Passed (" + console.min_tx_carrier[(int)bands[i]].ToString("f1") + ")"); } Thread.Sleep(500); } } console.TXFilterLow = tx_low; console.TXFilterHigh = tx_high; console.VFOAFreq = vfoa; console.VFOBFreq = vfob; if (test_tx_carrier.StartsWith("TX Carrier Test: Failed (")) test_tx_carrier = test_tx_carrier.Substring(0, test_tx_carrier.Length - 1) + ")"; toolTip1.SetToolTip(btnTXCarrier, test_tx_carrier); t1.Stop(); Debug.WriteLine("TX Carrier Timer: " + t1.Duration); string path = console.AppDataPath + "\\Tests"; if (!Directory.Exists(path)) Directory.CreateDirectory(path); bool file_exists = File.Exists(path + "\\tx_carrier.csv"); StreamWriter writer = new StreamWriter(path + "\\tx_carrier.csv", true); if (!file_exists) writer.WriteLine("Model, Serial Num, Date/Time, Version, " + "160m C0, 160m C1, 160m C2, 160m C3, 160m From Noise, " + "80m C0, 80m C1, 80m C2, 80m C3, 80m From Noise, " + "60m C0, 60m C1, 60m C2, 60m C3, 60m From Noise, " + "40m C0, 40m C1, 40m C2, 40m C3, 40m From Noise, " + "30m C0, 30m C1, 30m C2, 30m C3, 30m From Noise, " + "20m C0, 20m C1, 20m C2, 20m C3, 20m From Noise, " + "17m C0, 17m C1, 17m C2, 17m C3, 17m From Noise, " + "15m C0, 15m C1, 15m C2, 15m C3, 15m From Noise, " + "12m C0, 12m C1, 12m C2, 12m C3, 12m From Noise, " + "10m C0, 10m C1, 10m C2, 10m C3, 10m From Noise, " + "6m C0, 6m C1, 6m C2, 6m C3, 6m From Noise"); writer.Write(console.CurrentModel.ToString() + "," + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial) + "," + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "," + console.Text + ","); for (int i = 0; i < bands.Length; i++) { for (int j = 0; j < 4; j++) writer.Write((console.tx_carrier_cal[Math.Round(band_freqs[i], 3)]>>8*(3-j)).ToString() + ","); writer.Write(console.min_tx_carrier[(int)bands[i]].ToString("f1") + ","); } writer.WriteLine(""); writer.Close(); path += "\\TX Carrier"; if (!Directory.Exists(path)) Directory.CreateDirectory(path); string model = ""; switch (console.CurrentModel) { case Model.FLEX3000: model = "F3K"; break; case Model.FLEX5000: model = "F5K"; break; } writer = new StreamWriter(path + "\\tx_carrier_" + model + "_" + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial) + ".csv"); writer.WriteLine("Band, C0, C1, C2, C3, From Noise"); for (int i = 0; i < bands.Length; i++) { writer.Write(BandToString(bands[i]) + ","); for (int j = 0; j < 4; j++) writer.Write((console.tx_carrier_cal[Math.Round(band_freqs[i], 3)] >> 8 * (3 - j)).ToString() + ","); writer.WriteLine(console.min_tx_carrier[(int)bands[i]].ToString("f1")); } writer.Close(); lstDebug.Items.Insert(0, "Saving Carrier data to EEPROM..."); byte checksum; FWCEEPROM.WriteTXCarrier(console.tx_carrier_cal, out checksum); console.tx_carrier_checksum = checksum; console.SyncCalDateTime(); lstDebug.Items[0] = "Saving Carrier data to EEPROM...done"; grpGeneral.Enabled = true; grpReceiver.Enabled = true; grpTransmitter.Enabled = true; grpIO.Enabled = true; }
private void IORunAll() { HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); Invoke(new MethodInvoker(btnIOExtRef.PerformClick)); Thread.Sleep(2000); Invoke(new MethodInvoker(btnIOPwrSpkr.PerformClick)); Thread.Sleep(3500); Invoke(new MethodInvoker(btnIORCAInOut.PerformClick)); Thread.Sleep(3000); Invoke(new MethodInvoker(btnIOFWInOut.PerformClick)); Thread.Sleep(3000); Invoke(new MethodInvoker(btnIOHeadphone.PerformClick)); Thread.Sleep(5000); Invoke(new MethodInvoker(btnIODot.PerformClick)); Thread.Sleep(500); Invoke(new MethodInvoker(btnIODash.PerformClick)); Thread.Sleep(500); Invoke(new MethodInvoker(btnIORCAPTT.PerformClick)); Thread.Sleep(1000); Invoke(new MethodInvoker(btnIOMicPTT.PerformClick)); Thread.Sleep(1000); btnIORunAll.BackColor = SystemColors.Control; t1.Stop(); MessageBox.Show("Run All Tests Time: "+((int)(t1.Duration/60)).ToString()+":"+(((int)t1.Duration)%60).ToString("00")); }
private void btnEERead_Click(object sender, EventArgs e) { ushort offset = ushort.Parse(txtOffset.Text, NumberStyles.HexNumber); byte num_bytes = byte.Parse(txtNumBytes.Text, NumberStyles.HexNumber); byte[] data; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); int val; val = Flex1500.ReadEEPROM(offset, num_bytes, out data); t1.Stop(); txtEERead.Text = ""; for (int i = 0; i < num_bytes; i++) txtEERead.Text += data[i].ToString("X").PadLeft(2, '0'); Debug.WriteLine("EERead: " + val + " (" + t1.DurationMsec.ToString("f2") + ")"); }
public void RunCalFWCRXImage() { test_rx_image = "RX Image Test: Passed"; if (!console.PowerOn) { console.PowerOn = true; Thread.Sleep(500); } if (console.VFOSync) console.VFOSync = false; double vfoa = console.VFOAFreq; double vfob = console.VFOBFreq; int tx_low = console.TXFilterLow; console.TXFilterLow = 100; int tx_high = console.TXFilterHigh; console.TXFilterHigh = 200; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M }; float[] band_freqs = { 1.85f, 3.75f, 5.357f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f }; for (int i = 0; i < band_freqs.Length; i++) { float rejection_tol = 80.0f; // rejection from worst to null float floor_tol = 10.0f; // from null to noise floor if (console.CurrentModel == Model.FLEX3000 && FWCEEPROM.TRXRev >> 8 < 6) // before rev G { switch (bands[i]) { case Band.B160M: case Band.B80M: case Band.B60M: rejection_tol = 77.0f; break; } } bool do_band = false; switch (bands[i]) { case Band.B160M: do_band = ck160.Checked; break; case Band.B80M: do_band = ck80.Checked; break; case Band.B60M: { if (console.CurrentRegion == FRSRegion.US) { do_band = ck60.Checked; break; } else { lstDebug.Items.Insert(0, "RX Image - " + BandToString(bands[i]) + ": Result OK"); continue; } } case Band.B40M: do_band = ck40.Checked; break; case Band.B30M: do_band = ck30.Checked; break; case Band.B20M: do_band = ck20.Checked; break; case Band.B17M: do_band = ck17.Checked; break; case Band.B15M: do_band = ck15.Checked; break; case Band.B12M: do_band = ck12.Checked; break; case Band.B10M: do_band = ck10.Checked; break; case Band.B6M: do_band = ck6.Checked; break; } if (do_band) { p.SetPercent(0.0f); Invoke(new MethodInvoker(p.Show)); Application.DoEvents(); console.VFOAFreq = band_freqs[i] + 2 * console.IFFreq; console.VFOBFreq = band_freqs[i]; bool b = console.CalibrateRXImage(band_freqs[i], p, true); if (!b || console.rx_image_rejection[(int)bands[i]] < rejection_tol || console.rx_image_from_floor[(int)bands[i]] > floor_tol) { if (!test_rx_image.StartsWith("RX Image Test: Failed (")) test_rx_image = "RX Image Test: Failed ("; test_rx_image += BandToString(bands[i]) + ","; btnRXImage.BackColor = Color.Red; lstDebug.Items.Insert(0, "RX Image - " + BandToString(bands[i]) + ": Failed (" + console.rx_image_rejection[(int)bands[i]].ToString("f1") + ", " + console.rx_image_from_floor[(int)bands[i]].ToString("f1") + ")"); } else { lstDebug.Items.Insert(0, "RX Image - " + BandToString(bands[i]) + ": Passed (" + console.rx_image_rejection[(int)bands[i]].ToString("f1") + ", " + console.rx_image_from_floor[(int)bands[i]].ToString("f1") + ")"); } if (p.Text == "") { if (console.CurrentModel == Model.FLEX1500 && !b && console.rx_image_rejection[(int)bands[i]] == 0.0f && console.rx_image_from_floor[(int)bands[i]] == 100.0f) MessageBox.Show("Error finding Signal. Double check Sig Gen cabling.", "Error: Signal Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } Thread.Sleep(500); } } console.TXFilterLow = tx_low; console.TXFilterHigh = tx_high; console.VFOAFreq = vfoa; console.VFOBFreq = vfob; if (test_rx_image.StartsWith("RX Image Test: Failed (")) test_rx_image = test_rx_image.Substring(0, test_rx_image.Length - 1) + ")"; toolTip1.SetToolTip(btnRXImage, test_rx_image); t1.Stop(); Debug.WriteLine("RX Image Timer: " + t1.Duration); string path = console.AppDataPath + "\\Tests"; if (!Directory.Exists(path)) Directory.CreateDirectory(path); bool file_exists = File.Exists(path + "\\rx_image.csv"); StreamWriter writer = new StreamWriter(path + "\\rx_image.csv", true); if (!file_exists) writer.WriteLine("Model, Serial Num, Date/Time, Version, " + "160m gain, 160m phase, 160m rejection, 160m noise distance, " + "80m gain, 80m phase, 80m rejection, 80m noise distance, " + "60m gain, 60m phase, 60m rejection, 60m noise distance, " + "40m gain, 40m phase, 40m rejection, 40m noise distance, " + "30m gain, 30m phase, 30m rejection, 30m noise distance, " + "20m gain, 20m phase, 20m rejection, 20m noise distance, " + "17m gain, 17m phase, 17m rejection, 17m noise distance, " + "15m gain, 15m phase, 15m rejection, 15m noise distance, " + "12m gain, 12m phase, 12m rejection, 12m noise distance, " + "10m gain, 10m phase, 10m rejection, 10m noise distance, " + "6m gain, 6m phase, 6m rejection, 6m noise distance"); string serial = ""; switch (console.CurrentModel) { case Model.FLEX5000: case Model.FLEX3000: serial = FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial); break; case Model.FLEX1500: serial = HIDEEPROM.SerialToString(HIDEEPROM.SerialNumber); break; } writer.Write(console.CurrentModel.ToString() + "," + serial + "," + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "," + console.Text + ","); for (int i = 0; i < bands.Length; i++) { writer.Write(console.rx1_image_gain_table[(int)bands[i]].ToString("f11") + ","); writer.Write(console.rx1_image_phase_table[(int)bands[i]].ToString("f11") + ","); writer.Write(console.rx_image_rejection[(int)bands[i]].ToString("f1") + ","); writer.Write(console.rx_image_from_floor[(int)bands[i]].ToString("f1") + ","); } writer.WriteLine(""); writer.Close(); path += "\\RX Image"; if (!Directory.Exists(path)) Directory.CreateDirectory(path); string model = ""; switch (console.CurrentModel) { case Model.FLEX5000: model = "F5K" + "_" + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial); break; case Model.FLEX3000: model = "F3K" + "_" + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial); break; case Model.FLEX1500: model = "F1.5K" + "_" + HIDEEPROM.SerialToString(HIDEEPROM.SerialNumber); break; } writer = new StreamWriter(path + "\\rx_image_" + model + ".csv"); writer.WriteLine("Band, Gain, Phase, Rejection, Noise Distance"); for (int i = 0; i < bands.Length; i++) { writer.Write(BandToString(bands[i]) + ","); writer.Write(console.rx1_image_gain_table[(int)bands[i]].ToString("f11") + ","); writer.Write(console.rx1_image_phase_table[(int)bands[i]].ToString("f11") + ","); writer.Write(console.rx_image_rejection[(int)bands[i]].ToString("f1") + ","); writer.WriteLine(console.rx_image_from_floor[(int)bands[i]].ToString("f1")); } writer.Close(); lstDebug.Items.Insert(0, "Saving RX Image data to EEPROM..."); byte gain_sum = 0, phase_sum = 0; switch (console.CurrentModel) { case Model.FLEX5000: case Model.FLEX3000: FWCEEPROM.WriteRXImage(console.rx1_image_gain_table, console.rx1_image_phase_table, out gain_sum, out phase_sum); break; case Model.FLEX1500: HIDEEPROM.WriteRXImage(console.rx1_image_gain_table, console.rx1_image_phase_table, out gain_sum, out phase_sum); break; } console.rx1_image_gain_checksum = gain_sum; console.rx1_image_phase_checksum = phase_sum; console.SyncCalDateTime(); lstDebug.Items[0] = "Saving RX Image data to EEPROM...done"; grpGeneral.Enabled = true; grpReceiver.Enabled = true; grpTransmitter.Enabled = true; grpIO.Enabled = true; }
private void RunSel() { console.VFOSplit = false; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); string start_bands = GetStringFromBands(); #region Tests // run all general tests if(ckRunGenBal.Checked) { Invoke(new MethodInvoker(btnTestGenBal.PerformClick)); Thread.Sleep(3000); } /*if(ckRunNoise.Checked) { Invoke(new MethodInvoker(btnTestNoise.PerformClick)); Thread.Sleep(3000); }*/ if(ckRunPreamp.Checked) { Invoke(new MethodInvoker(btnTestPreamp.PerformClick)); Thread.Sleep(3000); } if(ckRunFilters.Checked) { Invoke(new MethodInvoker(btnTestFilters.PerformClick)); while(true) { while(p.Visible) Thread.Sleep(2000); Thread.Sleep(2000); if(!p.Visible) break; } if(p.Text == "") goto end; } // re-run any tests that failed if(ckRunGenBal.Checked && btnTestGenBal.BackColor != Color.Green) { Invoke(new MethodInvoker(btnTestGenBal.PerformClick)); Thread.Sleep(3000); } /*if(ckRunNoise.Checked && btnTestNoise.BackColor != Color.Green) { Invoke(new MethodInvoker(btnTestNoise.PerformClick)); Thread.Sleep(3000); }*/ if(ckRunPreamp.Checked && btnTestPreamp.BackColor != Color.Green) { Invoke(new MethodInvoker(btnTestPreamp.PerformClick)); Thread.Sleep(3000); } if(ckRunFilters.Checked && btnTestFilters.BackColor != Color.Green) { SetBandFromString(toolTip1.GetToolTip(btnTestFilters)); Invoke(new MethodInvoker(btnTestFilters.PerformClick)); while(true) { while(p.Visible) Thread.Sleep(2000); Thread.Sleep(2000); if(!p.Visible) break; } if(p.Text == "") goto end; } // reset bands back to start SetBandFromString(start_bands); if((ckRunGenBal.Checked && btnTestGenBal.BackColor != Color.Green) || (ckRunPreamp.Checked && btnTestPreamp.BackColor != Color.Green) || (ckRunFilters.Checked && btnTestFilters.BackColor != Color.Green)) goto end; #endregion #region Cal // run all calibrations if(ckCalLevel.Checked) { Invoke(new MethodInvoker(btnCalLevel.PerformClick)); while(true) { while(!btnCalLevel.Enabled) Thread.Sleep(2000); Thread.Sleep(2000); if(btnCalLevel.Enabled) break; } if(p.Text == "") goto end; } if(ckCalImage.Checked) { Invoke(new MethodInvoker(btnCalImage.PerformClick)); while(true) { while(!btnCalImage.Enabled) Thread.Sleep(2000); Thread.Sleep(2000); if(btnCalImage.Enabled) break; } if(p.Text == "") goto end; } // re-run any RX tests that failed if(ckCalLevel.Checked && btnCalLevel.BackColor != Color.Green) { SetBandFromString(toolTip1.GetToolTip(btnCalLevel)); Invoke(new MethodInvoker(btnCalLevel.PerformClick)); while(true) { while(!btnCalLevel.Enabled) Thread.Sleep(2000); Thread.Sleep(2000); if(btnCalLevel.Enabled) break; } if(p.Text == "") goto end; } if(ckCalImage.Checked && btnCalImage.BackColor != Color.Green) { SetBandFromString(toolTip1.GetToolTip(btnCalImage)); Invoke(new MethodInvoker(btnCalImage.PerformClick)); while(true) { while(!btnCalImage.Enabled) Thread.Sleep(2000); Thread.Sleep(2000); if(btnCalImage.Enabled) break; } if(p.Text == "") goto end; } // reset bands back to start SetBandFromString(start_bands); /*if((ckTestRXFilter.Checked && btnRXFilter.BackColor != Color.Green) || (ckTestRXLevel.Checked && btnRXLevel.BackColor != Color.Green) || (ckTestRXImage.Checked && btnRXImage.BackColor != Color.Green) || (ckTestRXMDS.Checked && btnRXMDS.BackColor != Color.Green)) goto end;*/ #endregion end: btnRunSel.BackColor = SystemColors.Control; btnRunSel.Enabled = true; t1.Stop(); MessageBox.Show("Run Selected Time: "+((int)(t1.Duration/60)).ToString()+":"+(((int)t1.Duration)%60).ToString("00")); }
private void Tune() { int fwd, rev; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); //const int SLEEP_TIME = 300; int SLEEP_TIME = (int)udSleepTime.Value; double HIGH_SWR = (double)udHighSWR.Value; double swr_thresh = 1.1; // start at 1.1, switch to 1.5 after 5 sec. int OFF_SLEEP = (int)udOffSleep.Value; int MaxL = 256; int MaxC = 128; int TUN_LVL = (int)udTunPower.Value; console.atu_tuning = true; // check in bypass FWC.SetATUEnable(false); FWC.SetHiZ(false); Thread.Sleep(50); lblHiZ.Visible = false; int old_power = console.TunePower; console.TunePower = TUN_LVL; console.TUN = true; tuning = true; Thread.Sleep(500); if (abort) { last_tune_result = TuneResult.TuneAborted; goto end; } // if the match is good enough, then just leave it bypassed FWC.ReadPAADC(5, out fwd); console.pa_fwd_power = fwd; FWC.ReadPAADC(4, out rev); console.pa_rev_power = rev; byp_fwd_pow = console.FWCPAPower(fwd); byp_ref_pow = console.FWCPAPower(rev) * console.atu_swr_table[(int)console.TXBand]; byp_swr = SWR(fwd, rev); tun_swr = byp_swr; if (byp_fwd_pow < 1) { rdBypass.Checked = true; last_tune_result = TuneResult.TuneFailedNoRF; goto end; } if (byp_swr < swr_thresh) { rdBypass.Checked = true; last_tune_result = TuneResult.TunerNotNeeded; goto end; } else if (byp_swr > HIGH_SWR) { rdBypass.Checked = true; last_tune_result = TuneResult.TuneFailedHighSWR; goto end; } // check HiZ console.TunePower = 0; Thread.Sleep(OFF_SLEEP); FWC.SetATUEnable(true); Thread.Sleep(OFF_SLEEP); SetC(8); SetL(8); FWC.SetHiZ(false); console.TunePower = TUN_LVL; Thread.Sleep(SLEEP_TIME); if (abort) { last_tune_result = TuneResult.TuneAborted; goto end; } FWC.ReadPAADC(5, out fwd); console.pa_fwd_power = fwd; FWC.ReadPAADC(4, out rev); console.pa_rev_power = rev; double lo_z_swr = SWR(fwd, rev); tun_swr = lo_z_swr; console.TunePower = 0; Thread.Sleep(OFF_SLEEP); FWC.SetHiZ(true); Thread.Sleep(OFF_SLEEP); console.TunePower = TUN_LVL; Thread.Sleep(SLEEP_TIME); if (abort) { last_tune_result = TuneResult.TuneAborted; goto end; } FWC.ReadPAADC(5, out fwd); console.pa_fwd_power = fwd; FWC.ReadPAADC(4, out rev); console.pa_rev_power = rev; double hi_z_swr = SWR(fwd, rev); tun_swr = hi_z_swr; Debug.WriteLine("lo: " + lo_z_swr.ToString("f1") + " hi: " + hi_z_swr.ToString("f1")); double min_swr = double.MaxValue; if (hi_z_swr < lo_z_swr) { lblHiZ.Visible = true; min_swr = hi_z_swr; } else { lblHiZ.Visible = false; console.TunePower = 0; Thread.Sleep(OFF_SLEEP); FWC.SetHiZ(false); Thread.Sleep(OFF_SLEEP); console.TunePower = TUN_LVL; min_swr = lo_z_swr; } tun_fwd_pow = console.FWCPAPower(console.pa_fwd_power); if (byp_fwd_pow < 1) { rdBypass.Checked = true; last_tune_result = TuneResult.TuneFailedLostRF; goto end; } if (min_swr < swr_thresh) { rdTune.Checked = false; last_tune_result = TuneResult.TuneSuccessful; goto end; } console.TunePower = 0; Thread.Sleep(OFF_SLEEP); SetL(0); SetC(0); Thread.Sleep(OFF_SLEEP); console.TunePower = TUN_LVL; Thread.Sleep(SLEEP_TIME); if (abort) { rdBypass.Checked = true; last_tune_result = TuneResult.TuneAborted; goto end; } int count = 0; int l_step = 8; int c_step = 8; int min_l = 0, L = 0; int min_c = 0, C = 0; int no_progress = 0; FWC.ReadPAADC(5, out fwd); console.pa_fwd_power = fwd; FWC.ReadPAADC(4, out rev); console.pa_rev_power = rev; min_swr = SWR(fwd, rev); bool first_time = true; while (rdTune.Checked) { double start_swr = min_swr; while (L >= 0 && L <= MaxL && rdTune.Checked) { if (!first_time) Thread.Sleep(SLEEP_TIME); else first_time = false; if (abort) { rdBypass.Checked = true; last_tune_result = TuneResult.TuneAborted; goto end; } t1.Stop(); if (t1.Duration > 5.0 && swr_thresh < 1.5) swr_thresh = 1.5; if (t1.Duration > 15.0) no_progress = 100; FWC.ReadPAADC(5, out fwd); console.pa_fwd_power = fwd; FWC.ReadPAADC(4, out rev); console.pa_rev_power = rev; tun_fwd_pow = console.FWCPAPower(fwd); tun_ref_pow = console.FWCPAPower(rev) * console.atu_swr_table[(int)console.TXBand]; if (byp_fwd_pow < 1) { rdBypass.Checked = true; last_tune_result = TuneResult.TuneFailedLostRF; goto end; } tun_swr = SWR(fwd, rev); Debug.WriteLine("swr (" + L + ", " + C + "): " + tun_swr.ToString("f1") + " min: " + min_swr.ToString("f1") + " start: " + start_swr.ToString("f1")); if (tun_swr < swr_thresh) { rdTune.Checked = false; last_tune_result = TuneResult.TuneSuccessful; goto end; } if (tun_swr < min_swr) { min_swr = tun_swr; min_l = L; } if (tun_swr > min_swr + 0.3) { l_step *= -1; break; } if (count++ * Math.Abs(l_step) > 32 && min_swr >= start_swr - 0.05) break; if (!rdTune.Checked) break; console.TunePower = 0; Thread.Sleep(OFF_SLEEP); SetL(L += l_step); Thread.Sleep(OFF_SLEEP); console.TunePower = TUN_LVL; } console.TunePower = 0; Thread.Sleep(OFF_SLEEP); SetL(min_l); Thread.Sleep(OFF_SLEEP); console.TunePower = TUN_LVL; L = min_l; if (min_swr >= start_swr - 0.05) no_progress++; if (no_progress > 6) { rdTune.Checked = false; last_tune_result = TuneResult.TuneOK; goto end; } Debug.Write("C"); count = 0; start_swr = min_swr; while (C >= 0 && C <= MaxC && rdTune.Checked) { Thread.Sleep(SLEEP_TIME); if (abort) { rdBypass.Checked = true; last_tune_result = TuneResult.TuneAborted; goto end; } t1.Stop(); if (t1.Duration > 5.0 && swr_thresh < 1.5) swr_thresh = 1.5; if (t1.Duration > 15.0) no_progress = 100; FWC.ReadPAADC(5, out fwd); console.pa_fwd_power = fwd; FWC.ReadPAADC(4, out rev); console.pa_rev_power = rev; tun_fwd_pow = console.FWCPAPower(fwd); tun_ref_pow = console.FWCPAPower(rev) * console.atu_swr_table[(int)console.TXBand]; if (byp_fwd_pow < 1) { rdBypass.Checked = true; last_tune_result = TuneResult.TuneFailedLostRF; goto end; } tun_swr = SWR(fwd, rev); Debug.WriteLine("swr (" + L + ", " + C + "): " + tun_swr.ToString("f1") + " min: " + min_swr.ToString("f1") + " start: " + start_swr.ToString("f1")); if (tun_swr < swr_thresh) { rdTune.Checked = false; last_tune_result = TuneResult.TuneSuccessful; goto end; } if (tun_swr < min_swr) { min_swr = tun_swr; min_c = C; } if (tun_swr > min_swr + 0.3) { c_step *= -1; break; } if (count++ * Math.Abs(c_step) > 32 && min_swr >= start_swr - 0.05) break; if (!rdTune.Checked) break; console.TunePower = 0; Thread.Sleep(OFF_SLEEP); SetC(C += c_step); Thread.Sleep(OFF_SLEEP); console.TunePower = TUN_LVL; } console.TunePower = 0; Thread.Sleep(OFF_SLEEP); SetC(min_c); Thread.Sleep(OFF_SLEEP); console.TunePower = TUN_LVL; C = min_c; count = 0; if (min_swr >= start_swr - 0.05) no_progress++; if (no_progress > 6) { rdTune.Checked = false; if (byp_swr > tun_swr) { last_tune_result = TuneResult.TuneOK; } else { last_tune_result = TuneResult.TuneFailedHighSWR; rdBypass.Checked = true; } goto end; } if (Math.Abs(l_step) > 1) l_step /= 2; if (Math.Abs(c_step) > 1) c_step /= 2; Debug.Write("L"); } end: switch (last_tune_result) { case TuneResult.TuneSuccessful: case TuneResult.TuneOK: Thread.Sleep(SLEEP_TIME); FWC.ReadPAADC(5, out fwd); console.pa_fwd_power = fwd; FWC.ReadPAADC(4, out rev); console.pa_rev_power = rev; tun_fwd_pow = console.FWCPAPower(fwd); tun_ref_pow = console.FWCPAPower(rev) * console.atu_swr_table[(int)console.TXBand]; tun_swr = SWR(fwd, rev); if (tun_swr > byp_swr) { last_tune_result = TuneResult.TunerNotNeeded; rdBypass.Checked = true; } Thread.Sleep(100); break; } //Debug.WriteLine("swr: "+swr.ToString("f1")); // cleanup tuning = false; console.TUN = false; console.TunePower = old_power; rdTune.Checked = false; console.atu_tuning = false; abort = false; //Invoke(new MethodInvoker(UpdateFeedback)); UpdateFeedback(); t1.Stop(); lblTime.Text = "Time: " + t1.Duration.ToString("f1"); }
public void CalRX2Level() { float[] offset_avg = {-55.7f, -55.8f, -56.1f, -57.6f, -55.1f, -56.0f, -55.9f, -56.3f, -55.4f, -55.8f, -55.0f}; float[] offset_avg2 = {-62.6f, -61.5f, -61.8f, -62.8f, -61.9f, -61.9f, -61.3f, -60.8f, -60.7f, -61.4f, -60.7f}; float[] preamp_avg = {-13.7f, -7.1f, -13.5f, -13.8f, -14.2f, -14.2f, -14.1f, -14.0f, -14.0f, -14.0f, -13.9f}; float[] preamp_avg2 = {-12.4f, -3.8f, -14.0f, -15.1f, -12.9f, -13.4f, -14.6f, -15.6f, -14.7f, -14.0f, -14.1f}; float offset_tol = 2.5f; // maximum distance from the average value float preamp_tol = 1.5f; double vfoa = console.VFOAFreq; double vfob = console.VFOBFreq; bool rx1_sr = console.SpurReduction; console.SpurReduction = false; bool rx2_sr = console.RX2SpurReduction; console.RX2SpurReduction = false; DSPMode dsp_mode = console.RX2DSPMode; console.RX2DSPMode = DSPMode.DSB; bool rit_on = console.RITOn; console.RITOn = false; bool rx2 = console.RX2Enabled; console.RX2Enabled = true; PreampMode preamp = console.RX1PreampMode; console.RX1PreampMode = PreampMode.OFF; PreampMode preamp2 = console.RX2PreampMode; console.RX2PreampMode = PreampMode.OFF; FWC.SetTest(true); Thread.Sleep(50); FWC.SetSig(true); Thread.Sleep(50); FWC.SetGen(true); Thread.Sleep(200); console.VFOAFreq = 14.2; console.VFOBFreq = 14.2; console.RX1PreampMode = PreampMode.OFF; console.RX2PreampMode = PreampMode.OFF; DSPMode dsp = console.RX1DSPMode; DSPMode dsp2 = console.RX2DSPMode; console.RX1DSPMode = DSPMode.DSB; console.RX2DSPMode = DSPMode.DSB; console.VFOAFreq = 14.2; console.VFOBFreq = 14.2; Filter filter = console.RX2Filter; int var_low = console.RX2FilterLow; int var_high = console.RX2FilterHigh; console.UpdateRX2Filters(-1000, 1000); Thread.Sleep(50); FWC.SetRX2Ant(6); // RX1 Tap Thread.Sleep(500); float rx1_adc = 0.0f; DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.ADC_REAL); Thread.Sleep(50); for(int j=0; j<5; j++) { rx1_adc += DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.ADC_REAL); if(j != 4) Thread.Sleep(50); } rx1_adc /= 5; float rx2_adc = 0.0f; DttSP.CalculateRXMeter(2, 0, DttSP.MeterType.ADC_REAL); Thread.Sleep(50); for(int j=0; j<5; j++) { rx2_adc += DttSP.CalculateRXMeter(2, 0, DttSP.MeterType.ADC_REAL); if(j != 4) Thread.Sleep(50); } rx2_adc /= 5; console.RX1DSPMode = dsp; console.RX2DSPMode = dsp2; float res_offset = rx1_adc-rx2_adc; console.rx2_res_offset = res_offset; bool resistor = ((rx1_adc-rx2_adc)>4.0); Debug.WriteLine("resistor: "+resistor+" "+res_offset.ToString("f2")); test_rx2_level = "RX2 Level Test: Passed"; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); Band[] bands = { Band.B6M, Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M }; float[] band_freqs = { 50.11f, 1.85f, 3.75f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f }; for(int i=0; i<band_freqs.Length; i++) { bool do_band = false; switch(bands[i]) { case Band.B160M: do_band = ck160.Checked; break; case Band.B80M: do_band = ck80.Checked; break; case Band.B60M: do_band = ck60.Checked; break; case Band.B40M: do_band = ck40.Checked; break; case Band.B30M: do_band = ck30.Checked; break; case Band.B20M: do_band = ck20.Checked; break; case Band.B17M: do_band = ck17.Checked; break; case Band.B15M: do_band = ck15.Checked; break; case Band.B12M: do_band = ck12.Checked; break; case Band.B10M: do_band = ck10.Checked; break; case Band.B6M: do_band = ck6.Checked; break; } if(do_band) { p.SetPercent(0.0f); Invoke(new MethodInvoker(p.Show)); Application.DoEvents(); console.VFOAFreq = band_freqs[i]; console.VFOBFreq = band_freqs[i]; console.CalibrateRX2Level(-24.0f, band_freqs[i], p, true); if(p.Text == "") break; float display_offset = console.GetRX2Level(bands[i], 0); float preamp_offset = console.GetRX2Level(bands[i], 1); float meter_offset = console.GetRX2Level(bands[i], 2); if((resistor && ((Math.Abs(display_offset-offset_avg[i]) > offset_tol) || (Math.Abs(preamp_offset-preamp_avg[i]) > preamp_tol))) || (!resistor && ((Math.Abs(display_offset-offset_avg2[i]) > offset_tol) || (Math.Abs(preamp_offset-preamp_avg2[i]) > preamp_tol)))) { btnCalLevel.BackColor = Color.Red; if(!test_rx2_level.StartsWith("RX2 Level Test: Failed (")) test_rx2_level = "RX2 Level Test: Failed ("; test_rx2_level += BandToString(bands[i])+", "; lstDebug.Items.Insert(0, "RX2 Level Cal - "+BandToString(bands[i])+": Failed (" +display_offset.ToString("f1")+", " +preamp_offset.ToString("f1")+", " +meter_offset.ToString("f1")+")"); } else { lstDebug.Items.Insert(0, "RX2 Level Cal - "+BandToString(bands[i])+": Passed (" +display_offset.ToString("f1")+", " +preamp_offset.ToString("f1")+", " +meter_offset.ToString("f1")+")"); } Thread.Sleep(500); } } if(test_rx2_level.StartsWith("RX2 Level Test: Failed (")) test_rx2_level = test_rx2_level.Substring(0, test_rx2_level.Length-2)+")"; toolTip1.SetToolTip(btnCalLevel, test_rx2_level); console.VFOAFreq = vfoa; console.VFOBFreq = vfob; t1.Stop(); Debug.WriteLine("RX Level Timer: "+t1.Duration); string path = Application.StartupPath+"\\Tests"; if(!Directory.Exists(path)) Directory.CreateDirectory(path); bool file_exists = File.Exists(path+"\\rx2_level.csv"); StreamWriter writer = new StreamWriter(path+"\\rx2_level.csv", true); if(!file_exists) writer.WriteLine("Serial Num, Date/Time, Version, " +"6m display offset, 6m preamp offset, 6m multimeter offset, " +"160m display offset, 160m preamp offset, 160m multimeter offset, " +"80m display offset, 80m preamp offset, 80m multimeter offset, " +"60m display offset, 60m preamp offset, 60m multimeter offset, " +"40m display offset, 40m preamp offset, 40m multimeter offset, " +"30m display offset, 30m preamp offset, 30m multimeter offset, " +"20m display offset, 20m preamp offset, 20m multimeter offset, " +"17m display offset, 17m preamp offset, 17m multimeter offset, " +"15m display offset, 15m preamp offset, 15m multimeter offset, " +"12m display offset, 12m preamp offset, 12m multimeter offset, " +"10m display offset, 10m preamp offset, 10m multimeter offset"); writer.Write(FWCEEPROM.SerialToString(FWCEEPROM.RX2Serial)+"," +DateTime.Now.ToShortDateString()+" "+DateTime.Now.ToShortTimeString()+"," +console.Text+","); for(int i=0; i<bands.Length; i++) { for(int j=0; j<3; j++) { writer.Write(console.GetRX2Level(bands[i], j).ToString("f1")); if(i!=bands.Length-1 || j!=2) writer.Write(","); } } writer.WriteLine(""); writer.Close(); path += "\\RX2 Level"; if(!Directory.Exists(path)) Directory.CreateDirectory(path); writer = new StreamWriter(path+"\\rx2_level_"+FWCEEPROM.SerialToString(FWCEEPROM.RX2Serial)+".csv"); writer.WriteLine("Band, Display Offset, Preamp Offset, Multimeter Offset"); for(int i=0; i<bands.Length; i++) { writer.Write(BandToString(bands[i])+","); writer.Write(console.GetRX2Level(bands[i], 0).ToString("f1")+","); writer.Write(console.GetRX2Level(bands[i], 1).ToString("f1")+","); writer.WriteLine(console.GetRX2Level(bands[i], 2).ToString("f1")); } writer.Close(); lstDebug.Items.Insert(0, "Saving Level data to EEPROM..."); FWCEEPROM.WriteRX2Level(console.rx2_level_table); console.RX2SyncCalDateTime(); lstDebug.Items[0] = "Saving Level data to EEPROM...done"; grpTests.Enabled = true; grpCal.Enabled = true; }
public void RunCalRXLevel() { //float[] offset_avg = {-59.3f, -60.5f, -61.1f, -61.4f, -60.8f, -60.5f, -60.0f, -59.5f, -59.5f, -59.5f, -59.6f}; //float[] preamp_avg = {-13.4f, -7.0f, -13.3f, -13.6f, -14.0f, -14.0f, -14.0f, -13.8f, -13.8f, -13.8f, -13.7f}; //float offset_tol = 2.5f; // maximum distance from the average value //float preamp_tol = 1.5f; test_rx_level = "RX Level Test: Passed"; double vfoa = console.VFOAFreq; double vfob = console.VFOBFreq; int tx_low = console.TXFilterLow; console.TXFilterLow = 100; int tx_high = console.TXFilterHigh; console.TXFilterHigh = 200; /*int dsp_phone_buf_size = console.SetupForm.DSPPhoneRXBuffer; // save current DSP buffer size int dsp_cw_buf_size = console.SetupForm.DSPCWRXBuffer; // save current DSP buffer size int dsp_dig_buf_size = console.SetupForm.DSPDigRXBuffer; // save current DSP buffer size console.SetupForm.DSPPhoneRXBuffer = 2048; // set DSP Buffer Size to 2048 console.SetupForm.DSPCWRXBuffer = 2048; console.SetupForm.DSPDigRXBuffer = 2048;*/ HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); Band[] bands = { Band.B6M, Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M }; float[] band_freqs = { 50.11f, 1.85f, 3.75f, 5.357f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f }; if (!console.PowerOn) { console.PowerOn = true; Thread.Sleep(500); } float level = (float)udLevel.Value; if (console.VFOSync) console.VFOSync = false; for (int i = 0; i < band_freqs.Length; i++) { bool do_band = false; switch (bands[i]) { case Band.B160M: do_band = ck160.Checked; break; case Band.B80M: do_band = ck80.Checked; break; case Band.B60M: { if (console.CurrentRegion == FRSRegion.US) { do_band = ck60.Checked; break; } else { lstDebug.Items.Insert(0, "RX Level Test - " + BandToString(bands[i]) + ": Result OK"); continue; } } case Band.B40M: do_band = ck40.Checked; break; case Band.B30M: do_band = ck30.Checked; break; case Band.B20M: do_band = ck20.Checked; break; case Band.B17M: do_band = ck17.Checked; break; case Band.B15M: do_band = ck15.Checked; break; case Band.B12M: do_band = ck12.Checked; break; case Band.B10M: do_band = ck10.Checked; break; case Band.B6M: do_band = ck6.Checked; break; } if (do_band) { p.SetPercent(0.0f); Invoke(new MethodInvoker(p.Show)); Application.DoEvents(); console.VFOAFreq = band_freqs[i]; console.VFOBFreq = band_freqs[i]; console.CalibrateLevel(level, band_freqs[i], p, true); if (p.Text == "") break; if (console.CurrentModel == Model.FLEX1500) { if (console.GetRX1Level(bands[i], 0) >= -96.0 && console.GetRX1Level(bands[i], 0) <= -84.0) { lstDebug.Items.Insert(0, "RX Level Test - " + BandToString(bands[i]) + ": Passed (" + console.GetRX1Level(bands[i], 0).ToString("f1") + ", " + console.GetRX1Level(bands[i], 1).ToString("f1") + ", " + console.GetRX1Level(bands[i], 2).ToString("f1") + ")"); } else { btnRXLevel.BackColor = Color.Red; if (!test_rx_level.StartsWith("RX Level Test: Failed (")) test_rx_level = "RX Level Test: Failed ("; test_rx_level += BandToString(bands[i]) + ","; lstDebug.Items.Insert(0, "RX Level Test - " + BandToString(bands[i]) + ": Failed (" + console.GetRX1Level(bands[i], 0).ToString("f1") + ", " + console.GetRX1Level(bands[i], 1).ToString("f1") + ", " + console.GetRX1Level(bands[i], 2).ToString("f1") + ")"); } } else { lstDebug.Items.Insert(0, "RX Level Test - " + BandToString(bands[i]) + ": Passed (" + console.GetRX1Level(bands[i], 0).ToString("f1") + ", " + console.GetRX1Level(bands[i], 1).ToString("f1") + ", " + console.GetRX1Level(bands[i], 2).ToString("f1") + ")"); } Thread.Sleep(500); } } /*console.SetupForm.DSPPhoneRXBuffer = dsp_phone_buf_size; console.SetupForm.DSPCWRXBuffer = dsp_cw_buf_size; console.SetupForm.DSPDigRXBuffer = dsp_dig_buf_size;*/ console.TXFilterLow = tx_low; console.TXFilterHigh = tx_high; if (test_rx_level.StartsWith("RX Level Test: Failed (")) test_rx_level = test_rx_level.Substring(0, test_rx_level.Length - 2) + ")"; toolTip1.SetToolTip(btnRXLevel, test_rx_level); console.VFOAFreq = vfoa; Thread.Sleep(10); console.VFOBFreq = vfob; t1.Stop(); Debug.WriteLine("RX Level Timer: " + t1.Duration); string path = console.AppDataPath + "\\Tests"; if (!Directory.Exists(path)) Directory.CreateDirectory(path); bool file_exists = File.Exists(path + "\\rx_level.csv"); StreamWriter writer = new StreamWriter(path + "\\rx_level.csv", true); if (!file_exists) writer.WriteLine("Model, Serial Num, Date/Time, Version, " + "6m display offset, 6m preamp offset, 6m multimeter offset, " + "160m display offset, 160m preamp offset, 160m multimeter offset, " + "80m display offset, 80m preamp offset, 80m multimeter offset, " + "60m display offset, 60m preamp offset, 60m multimeter offset, " + "40m display offset, 40m preamp offset, 40m multimeter offset, " + "30m display offset, 30m preamp offset, 30m multimeter offset, " + "20m display offset, 20m preamp offset, 20m multimeter offset, " + "17m display offset, 17m preamp offset, 17m multimeter offset, " + "15m display offset, 15m preamp offset, 15m multimeter offset, " + "12m display offset, 12m preamp offset, 12m multimeter offset, " + "10m display offset, 10m preamp offset, 10m multimeter offset"); writer.Write(console.CurrentModel.ToString() + ","); switch (console.CurrentModel) { case Model.FLEX5000: case Model.FLEX3000: writer.Write(FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial) + ","); break; case Model.FLEX1500: writer.Write(HIDEEPROM.SerialToString(HIDEEPROM.TRXSerial) + ","); break; } writer.Write(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "," + console.Text + ","); for (int i = 0; i < bands.Length; i++) { for (int j = 0; j < 3; j++) { writer.Write(console.GetRX1Level(bands[i], j).ToString("f1")); if (i != bands.Length - 1 || j != 2) writer.Write(","); } } writer.WriteLine(""); writer.Close(); path += "\\RX Level"; if (!Directory.Exists(path)) Directory.CreateDirectory(path); string filename = ""; switch (console.CurrentModel) { case Model.FLEX5000: filename = path + "\\rx_level_F5K_" + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial) + ".csv"; break; case Model.FLEX3000: filename = path + "\\rx_level_F3K_" + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial) + ".csv"; break; case Model.FLEX1500: filename = path + "\\rx_level_F1.5K_" + HIDEEPROM.SerialToString(HIDEEPROM.SerialNumber) + ".csv"; break; } writer = new StreamWriter(filename); writer.WriteLine("Band, Display Offset, Preamp Offset, Multimeter Offset"); for (int i = 0; i < bands.Length; i++) { writer.Write(BandToString(bands[i]) + ","); writer.Write(console.GetRX1Level(bands[i], 0).ToString("f1") + ","); writer.Write(console.GetRX1Level(bands[i], 1).ToString("f1") + ","); writer.WriteLine(console.GetRX1Level(bands[i], 2).ToString("f1")); } writer.Close(); lstDebug.Items.Insert(0, "Saving Level data to EEPROM..."); byte checksum = 0; switch (console.CurrentModel) { case Model.FLEX5000: case Model.FLEX3000: FWCEEPROM.WriteRXLevel(console.rx1_level_table, out checksum); break; case Model.FLEX1500: HIDEEPROM.WriteRXLevel(console.rx1_level_table, out checksum); break; } console.rx1_level_checksum = checksum; console.SyncCalDateTime(); Thread.Sleep(10); lstDebug.Items[0] = "Saving Level data to EEPROM...done"; grpGeneral.Enabled = true; grpReceiver.Enabled = true; grpTransmitter.Enabled = true; grpIO.Enabled = true; }
public void CalRX2Image() { float rejection_tol = 75.0f; // rejection from worst to null float floor_tol = 10.0f; // from null to noise floor test_rx2_image = "RX2 Image Cal: Passed"; double vfoa = console.VFOAFreq; double vfob = console.VFOBFreq; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M }; float[] band_freqs = { 1.85f, 3.75f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f}; for(int i=0; i<band_freqs.Length; i++) { bool do_band = false; switch(bands[i]) { case Band.B160M: do_band = ck160.Checked; break; case Band.B80M: do_band = ck80.Checked; break; case Band.B60M: do_band = ck60.Checked; break; case Band.B40M: do_band = ck40.Checked; break; case Band.B30M: do_band = ck30.Checked; break; case Band.B20M: do_band = ck20.Checked; break; case Band.B17M: do_band = ck17.Checked; break; case Band.B15M: do_band = ck15.Checked; break; case Band.B12M: do_band = ck12.Checked; break; case Band.B10M: do_band = ck10.Checked; break; case Band.B6M: do_band = ck6.Checked; break; } if(do_band) { p.SetPercent(0.0f); Invoke(new MethodInvoker(p.Show)); Application.DoEvents(); console.VFOBFreq = band_freqs[i]+2*console.IFFreq; console.VFOAFreq = band_freqs[i]; console.CalibrateRX2Image(band_freqs[i], p, true); if(p.Text == "") break; if(console.rx_image_rejection[(int)bands[i]] < rejection_tol || console.rx_image_from_floor[(int)bands[i]] > floor_tol) { if(!test_rx2_image.StartsWith("RX2 Image Cal: Failed (")) test_rx2_image = "RX2 Image Cal: Failed ("; test_rx2_image += BandToString(bands[i])+", "; btnCalImage.BackColor = Color.Red; lstDebug.Items.Insert(0, "RX2 Image - "+BandToString(bands[i])+": Failed (" +console.rx_image_rejection[(int)bands[i]].ToString("f1")+", " +console.rx_image_from_floor[(int)bands[i]].ToString("f1")+")"); } else { lstDebug.Items.Insert(0, "RX2 Image - "+BandToString(bands[i])+": Passed (" +console.rx_image_rejection[(int)bands[i]].ToString("f1")+", " +console.rx_image_from_floor[(int)bands[i]].ToString("f1")+")"); } Thread.Sleep(500); } } console.VFOAFreq = vfoa; console.VFOBFreq = vfob; if(test_rx2_image.StartsWith("RX2 Image Cal: Failed (")) test_rx2_image = test_rx2_image.Substring(0, test_rx2_image.Length-2)+")"; toolTip1.SetToolTip(btnCalImage, test_rx2_image); t1.Stop(); Debug.WriteLine("RX2 Image Timer: "+t1.Duration); string path = Application.StartupPath+"\\Tests"; if(!Directory.Exists(path)) Directory.CreateDirectory(path); bool file_exists = File.Exists(path+"\\rx2_image.csv"); StreamWriter writer = new StreamWriter(path+"\\rx2_image.csv", true); if(!file_exists) writer.WriteLine("Serial Num, Date/Time, Version, " +"160m gain, 160m phase, 160m rejection, 160m noise distance, " +"80m gain, 80m phase, 80m rejection, 80m noise distance, " +"60m gain, 60m phase, 60m rejection, 60m noise distance, " +"40m gain, 40m phase, 40m rejection, 40m noise distance, " +"30m gain, 30m phase, 30m rejection, 30m noise distance, " +"20m gain, 20m phase, 20m rejection, 20m noise distance, " +"17m gain, 17m phase, 17m rejection, 17m noise distance, " +"15m gain, 15m phase, 15m rejection, 15m noise distance, " +"12m gain, 12m phase, 12m rejection, 12m noise distance, " +"10m gain, 10m phase, 10m rejection, 10m noise distance, " +"6m gain, 6m phase, 6m rejection, 6m noise distance"); writer.Write(FWCEEPROM.SerialToString(FWCEEPROM.RX2Serial)+"," +DateTime.Now.ToShortDateString()+" "+DateTime.Now.ToShortTimeString()+"," +console.Text+","); for(int i=0; i<bands.Length; i++) { writer.Write(console.rx2_image_gain_table[(int)bands[i]].ToString("f3")+","); writer.Write(console.rx2_image_phase_table[(int)bands[i]].ToString("f3")+","); writer.Write(console.rx_image_rejection[(int)bands[i]].ToString("f1")+","); writer.Write(console.rx_image_from_floor[(int)bands[i]].ToString("f1")+","); } writer.WriteLine(""); writer.Close(); path += "\\RX2 Image"; if(!Directory.Exists(path)) Directory.CreateDirectory(path); writer = new StreamWriter(path+"\\rx2_image_"+FWCEEPROM.SerialToString(FWCEEPROM.RX2Serial)+".csv"); writer.WriteLine("Band, Gain, Phase, Rejection, Noise Distance"); for(int i=0; i<bands.Length; i++) { writer.Write(BandToString(bands[i])+","); writer.Write(console.rx2_image_gain_table[(int)bands[i]].ToString("f3")+","); writer.Write(console.rx2_image_phase_table[(int)bands[i]].ToString("f3")+","); writer.Write(console.rx_image_rejection[(int)bands[i]].ToString("f1")+","); writer.WriteLine(console.rx_image_from_floor[(int)bands[i]].ToString("f1")); } writer.Close(); lstDebug.Items.Insert(0, "Saving Image data to EEPROM..."); FWCEEPROM.WriteRX2Image(console.rx2_image_gain_table, console.rx2_image_phase_table); console.RX2SyncCalDateTime(); lstDebug.Items[0] = "Saving Image data to EEPROM...done"; grpTests.Enabled = true; grpCal.Enabled = true; }
public CWKeyer2(Console c) { console = c; if(console.CurrentModel == Model.SDR1000) hw = console.Hdw; siolisten = console.Siolisten; Thread.Sleep(50); DttSP.NewKeyer(600.0f, true, 0.0f, 3.0f, 25.0f, (float)Audio.SampleRate1); RadioDSP.KeyerIambicMode = 0; Thread.Sleep(50); threads_running = true; cw_tone_thread = new Thread(new ThreadStart(DttSP.KeyerSoundThread)); cw_tone_thread.Name = "CW Sound Thread"; cw_tone_thread.Priority = ThreadPriority.Highest; cw_tone_thread.IsBackground = true; cw_tone_thread.Start(); keyer_thread = new Thread(new ThreadStart(KeyThread)); keyer_thread.Name = "CW KeyThread"; keyer_thread.Priority = ThreadPriority.Highest; keyer_thread.IsBackground = true; keyer_thread.Start(); timer = new HiPerfTimer(); }
private void RunImpulse() { HiPerfTimer t1 = new HiPerfTimer(); for(int i=0; i<100; i++) { //t1.Start(); FWC.SetImpulse(true); //t1.Stop(); //while(t1.DurationMsec < 10) t1.Stop(); //t1.Start(); FWC.SetImpulse(false); //t1.Stop(); //while(t1.DurationMsec < 10) t1.Stop(); } }
public void RunCalFWCTXSpur() { float tol = -80.0f; test_tx_spur = "TX Spur Test: Passed"; if (!console.PowerOn) { console.PowerOn = true; Thread.Sleep(500); } if (console.VFOSync) console.VFOSync = false; double vfoa = console.VFOAFreq; double vfob = console.VFOBFreq; int tx_low = console.TXFilterLow; console.TXFilterLow = 100; int tx_high = console.TXFilterHigh; console.TXFilterHigh = 200; HiPerfTimer t1 = new HiPerfTimer(); t1.Start(); Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M }; float[] band_freqs = { 1.85f, 3.55f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f }; for (int i = 0; i < band_freqs.Length; i++) { bool do_band = false; switch (bands[i]) { case Band.B160M: do_band = ck160.Checked; break; case Band.B80M: do_band = ck80.Checked; break; case Band.B60M: do_band = ck60.Checked; break; case Band.B40M: do_band = ck40.Checked; break; case Band.B30M: do_band = ck30.Checked; break; case Band.B20M: do_band = ck20.Checked; break; case Band.B17M: do_band = ck17.Checked; break; case Band.B15M: do_band = ck15.Checked; break; case Band.B12M: do_band = ck12.Checked; break; case Band.B10M: do_band = ck10.Checked; break; case Band.B6M: do_band = ck6.Checked; break; } if (do_band) { progress.SetPercent(0.0f); Invoke(new MethodInvoker(progress.Show)); Application.DoEvents(); console.VFOAFreq = band_freqs[i]; console.VFOBFreq = band_freqs[i]; console.CalTXSpur(band_freqs[i], progress); if (progress.Text == "") break; if (console.tx_spur_level[(int)bands[i]] > tol) { if (!test_tx_spur.StartsWith("TX Spur Test: Failed (")) test_tx_spur = "TX Spur Test: Failed ("; test_tx_spur += BandToString(bands[i]) + ","; btnTXSpur.BackColor = Color.Red; lstDebug.Items.Insert(0, "TX Spur - " + BandToString(bands[i]) + ": Failed (" + console.tx_spur_level[(int)bands[i]].ToString("f1") + ")"); } else { lstDebug.Items.Insert(0, "TX Spur - " + BandToString(bands[i]) + ": Passed (" + console.tx_spur_level[(int)bands[i]].ToString("f1") + ")"); } Thread.Sleep(500); } } console.TXFilterLow = tx_low; console.TXFilterHigh = tx_high; console.VFOAFreq = vfoa; console.VFOBFreq = vfob; if (test_tx_spur.StartsWith("TX Spur Test: Failed (")) test_tx_spur = test_tx_spur.Substring(0, test_tx_spur.Length - 1) + ")"; toolTip1.SetToolTip(btnTXSpur, test_tx_spur); t1.Stop(); Debug.WriteLine("TX Spur Timer: " + t1.Duration); string path = console.AppDataPath + "\\Tests"; if (!Directory.Exists(path)) Directory.CreateDirectory(path); bool file_exists = File.Exists(path + "\\tx_spur.csv"); StreamWriter writer = new StreamWriter(path + "\\tx_spur.csv", true); if (!file_exists) writer.WriteLine("Model, Serial Num, Date/Time, Version, " + "160m, 80m, 60m, 40m, 30m, 20m, 17m, 15m, 12m, 10m, 6m,"); writer.Write(console.CurrentModel.ToString() + "," + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial) + "," + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "," + console.Text + ","); for (int i = 0; i < bands.Length; i++) { writer.Write(console.tx_spur_level[(int)bands[i]].ToString("f1") + ","); } writer.WriteLine(""); writer.Close(); path += "\\TX Spur"; if (!Directory.Exists(path)) Directory.CreateDirectory(path); string model = ""; switch (console.CurrentModel) { case Model.FLEX5000: model = "F5K"; break; } writer = new StreamWriter(path + "\\tx_spur_" + model + "_" + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial) + ".csv"); writer.WriteLine("Band, dBc"); for (int i = 0; i < bands.Length; i++) { writer.Write(BandToString(bands[i]) + ","); writer.WriteLine(console.tx_spur_level[(int)bands[i]].ToString("f1")); } writer.Close(); lstDebug.Items.Insert(0, "Saving Carrier data to EEPROM..."); byte checksum; FWCEEPROM.WriteTXCarrier(console.tx_carrier_table, out checksum); console.tx_carrier_checksum = checksum; console.SyncCalDateTime(); lstDebug.Items[0] = "Saving Carrier data to EEPROM...done"; /*grpGeneral.Enabled = true; grpReceiver.Enabled = true; grpTransmitter.Enabled = true;*/ }