//void Refine void DipoleAnalyseOneStepOnly() { if (!CheckForCalibration() || !bDeviceConnected) { return; } Int64 nFrequencyStep; float[] fSweepResult = null; Int64 nFrequencyBase; int nCaptureCount; // first scan MyNotifier.SetProgressBar(SweepProgressBar); LOGDraw("Start dipole detection..."); nFrequencyBase = nFrequencyDetectionStart; nCaptureCount = Convert.ToInt32(SamplesTextBox.Text); nFrequencyStep = ((nFrequencyDetectionEnd - nFrequencyDetectionStart) + (nCaptureCount - 1)) / nCaptureCount; if (nFrequencyStep == 0) { nFrequencyStep = 1; nCaptureCount = (int)(nFrequencyDetectionEnd - nFrequencyDetectionStart); SamplesTextBox.Text = nCaptureCount.ToString(); } fSweepResult = RunSweep(nFrequencyBase, nFrequencyStep, nCaptureCount, MyNotifier, (NWTDevice.DetectorUsed)DetectorCombobox.SelectedItem); SingleCurveDisplay(nFrequencyBase, nFrequencyStep, fSweepResult); DipoleProcessAnalyseOnFinalRange(fSweepResult, nFrequencyBase, nFrequencyStep); RefreshQERFilterEstimator(); }
void DipoleAnalyse() { if (!CheckForCalibration() || !bDeviceConnected) { return; } Int64 nFrequencyStep; float[] fSweepResult = null; Int64 nFrequencyBase; int nCaptureCount; int nserieIndex; Int64 nserieFrequency; // first scan MyNotifier.SetProgressBar(SweepProgressBar); LOGDraw("Start dipole detection..."); nFrequencyBase = nFrequencyDetectionStart; nCaptureCount = 9999; nFrequencyStep = ((nFrequencyDetectionEnd - nFrequencyDetectionStart) + (nCaptureCount - 1)) / nCaptureCount; if (nFrequencyStep == 0) { nFrequencyStep = 1; nCaptureCount = (int)(nFrequencyDetectionEnd - nFrequencyDetectionStart); SamplesTextBox.Text = nCaptureCount.ToString(); } fSweepResult = RunSweep(nFrequencyBase, nFrequencyStep, nCaptureCount, MyNotifier); SingleCurveDisplay(nFrequencyBase, nFrequencyStep, fSweepResult); // check if the precision will be acceptable { nserieIndex = Utility.RetrieveMaxValueIndex(fSweepResult); nserieFrequency = nFrequencyBase + nserieIndex * nFrequencyStep; LOGDraw("first estimation serie resonance :" + Utility.GetStringWithSeparators(nserieFrequency / 1000, " ") + "kHz"); int nStepFromFrequencyFactor = (int)((nserieFrequency * 6) / 30000000); if (nStepFromFrequencyFactor > 5) { nStepFromFrequencyFactor = 5; } nFrequencyStep = (nStepFromFrequencyFactor) + 1; if (!ParallelCheckBox.Checked) { nFrequencyBase = nserieFrequency - nFrequencyStep * 5000; } else { nFrequencyBase = nserieFrequency - nFrequencyStep * 3300; } nCaptureCount = 9999; LOGDraw("dipole accurate analyse..."); fSweepResult = RunSweep(nFrequencyBase, nFrequencyStep, nCaptureCount, MyNotifier); SingleCurveDisplay(nFrequencyBase, nFrequencyStep, fSweepResult); } float nParralelLeveldB = 0.0f; float fParrallelFrequency = 0.0f; if (ParallelCheckBox.Checked) { int nParrallelIndex = Utility.RetrieveMinValueIndex(fSweepResult); while (nParrallelIndex > 9500) { nFrequencyStep += nFrequencyStep; LOGDraw("parrallel mode resonance not found, we broaden the scan..."); fSweepResult = RunSweep(nFrequencyBase, nFrequencyStep, nCaptureCount, MyNotifier); SingleCurveDisplay(nFrequencyBase, nFrequencyStep, fSweepResult); nParrallelIndex = Utility.RetrieveMinValueIndex(fSweepResult); } nParralelLeveldB = fSweepResult[nParrallelIndex]; fParrallelFrequency = nFrequencyBase + nParrallelIndex * nFrequencyStep; } DipoleProcessAnalyseOnFinalRange(fSweepResult, nFrequencyBase, nFrequencyStep); RefreshQERFilterEstimator(); }
public Form1() { InitializeComponent(); SweepModeCurvesList.Clear(); SweepModeCurvesList.Add(new CCurve()); CurveListComboBox.DataSource = null; CurveListComboBox.DataSource = SweepModeCurvesList; CurveListComboBox.SelectedItem = SweepModeCurvesList[0]; CurveConfigPropertyGrid.SelectedObject = SweepModeCurvesList[0]; AutodetectCOMcheckBox.Checked = Program.Save.SerialPortAutodetectAtLaunch; RawCaptureCheckBox.Checked = Program.Save.RawCapture; //SerialPortComboBox.SelectedValueChanged -= DevicesComboBox_SelectedValueChanged; RefreshCOMPortList(); //SerialPortComboBox.SelectedValueChanged += DevicesComboBox_SelectedValueChanged; Text = Program.Version; OutputModeComboBox.DataSource = Enum.GetValues(typeof(OutputMode)); FilterComboBox.DataSource = Enum.GetValues(typeof(FilterMode)); OutputModeComboBox.SelectedItem = Program.Save.Output; FilterComboBox.SelectedItem = Program.Save.Filter; AttLevelcomboBox.SelectedIndexChanged -= AttLevelcomboBox_SelectedIndexChanged; AttLevelcomboBox.DataSource = Enum.GetValues(typeof(AttLevel)); AttLevelcomboBox.SelectedIndexChanged += AttLevelcomboBox_SelectedIndexChanged; DetectorCombobox.DataSource = Enum.GetValues(typeof(NWTDevice.DetectorUsed)); MyNotifier.SetProgressBar(SweepProgressBar); MyNotifier.SetForm(this); DeviceManagerInit(); //SerialPortComboBox.Items.AddRange(SerialPort.GetPortNames()); //AutoDetectserialPort(); DeviceListMenuRefresh(); bMuteDeviceComboBoxEvent = true; int nDeviceIndex = GetDeviceIndex(Program.Save.LastUsedDevice); if (nDeviceIndex >= 0) { SelectecDeviceComboBox.SelectedIndex = nDeviceIndex; } else { SelectecDeviceComboBox.SelectedIndex = 0; } bMuteDeviceComboBoxEvent = false; SetAnalyzer(SelectecDeviceComboBox.SelectedIndex, true); if (Program.Save.LastUsedCOMPort != null) { // we try to initalize this com port bool bSuccess = SerialPortInitialize(Program.Save.LastUsedCOMPort); if (bSuccess) { SerialPortComboBox.SelectedItem = Program.Save.LastUsedCOMPort; } if (!bSuccess && Program.Save.SerialPortAutodetectAtLaunch) { AutoDetectSerialPort(); } } else { if (Program.Save.SerialPortAutodetectAtLaunch) { AutoDetectSerialPort(); } } AttCalCheckBox.Checked = Program.Save.AttCal; SpectrumPictureBox.SetOwnedForm(this); SetSampleCount(Program.Save.SampleCount); if (DeviceInterface.GetDevice().Attenuator) { if (Program.Save.AttCal) { DeviceInterface.SetAttenuatorLevel((AttLevel)AttLevelcomboBox.SelectedItem, (AttLevel)AttLevelcomboBox.SelectedItem); } else { DeviceInterface.SetAttenuatorLevel((AttLevel)AttLevelcomboBox.SelectedItem, AttLevel._0dB); } } VFOFrequencyTextBox.Text = Utility.GetStringWithSeparators(Program.Save.LastVFOFrequency, " "); }