예제 #1
0
        bool ProcessCalibrationNoAttenuator(UInt16 nCaptureDelay = 0)
        {
            if (!DeviceInterface.IsPortOpen())
            {
                LOGWarning("Port not open, i try to autodetect analyzer");
                AutoDetectSerialPort();
            }

            if (DeviceInterface.GetDevice().HaveLogDetector)
            {
                LOGDraw("Calibration in progress using logarithmic detector..", true);
                DeviceInterface.RunCalibration(MyNotifier, 9999, false);
            }

            if (DeviceInterface.GetDevice().HaveLinDetector)
            {
                LOGDraw("Calibration in progress using linear detector..", true);
                DeviceInterface.RunCalibration(MyNotifier, 9999, true);
            }

            DeviceInterface.SaveCalibration(Program.CalibrationPath);
            bCalibrationAvailable = true;

            LOGDraw("done.");
            return(true);
        }
예제 #2
0
        bool SerialPortInitialize(String PortName)
        {
            if (DeviceInterface.Initialize(PortName) == true)
            {
                LOGDraw("Firmware version : " + DeviceInterface.nFirmwareVersionNumber.ToString());
                FirmwareTextBox.Text = DeviceInterface.nFirmwareVersionNumber.ToString();

                bool bFirmwareOK = false;

                foreach (int i in DeviceInterface.GetDevice().AllowedFirmwaresVersions)
                {
                    if (i == DeviceInterface.nFirmwareVersionNumber)
                    {
                        bFirmwareOK = true;
                        break;
                    }
                }

                if (bFirmwareOK)
                {
                    FirmwareTextBox.BackColor = Color.Chartreuse;
                    LOGDraw("Compatible analyzer found on port " + PortName);
                }
                else
                {
                    if (DeviceInterface.nFirmwareVersionNumber > 100 && DeviceInterface.nFirmwareVersionNumber < 120)
                    {
                        FirmwareTextBox.BackColor = Color.Yellow;
                        LOGWarning(PortName + ":In range firmware version number, but no match with selected analyzer");
                    }
                    else
                    {
                        FirmwareTextBox.BackColor = Color.OrangeRed;
                        LOGWarning(PortName + ":The device respond to the version request, but the firmware version number is out of range ");
                    }
                }
                bDeviceConnected = true;
                return(true);
            }
            else
            {
                FirmwareTextBox.BackColor = Color.Red;
                FirmwareTextBox.Text      = "NA";
                bDeviceConnected          = false;
                LOGError(PortName + ":No device respond to version request");
                return(false);
            }
        }
예제 #3
0
        void FillAcquisitionParams(NWTDevice.RunSweepModeParam Param)
        {
            int nCaptureCount = Convert.ToInt32(SamplesTextBox.Text);

            int nFrequencyStep = (int)((nFrequencyDetectionEnd - nFrequencyDetectionStart) / nCaptureCount);

            if (nFrequencyStep == 0)
            {
                nFrequencyStep = 1;
            }

            Param.Detector       = (NWTDevice.DetectorUsed)DetectorCombobox.SelectedItem;
            Param.nBaseFrequency = nFrequencyDetectionStart;
            Param.nFrequencyStep = nFrequencyStep;
            Param.nCount         = nCaptureCount;
            Param.Notifier       = null;
            Param.Worker         = backgroundWorkerSerialCapture;
            Param.bUseRawMode    = Program.Save.RawCapture;
            Param.RawModeBase    = DeviceInterface.GetDevice().RawMode_0dB_Reference;
        }
예제 #4
0
        bool ProcessCalibration(bool AllAttenuatorforced = false, UInt16 nCaptureDelay = 0)
        {
            if (!CurrentDeviceDef.Attenuator)
            {
                return(ProcessCalibrationNoAttenuator());
            }

            DialogResult Result;

            if (AllAttenuatorforced)
            {
                Result = MessageBox.Show("We will run calibration for all attenuators setup", "Need calibration", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
            }
            else
            {
                Result = MessageBox.Show("Run calibration for all attenuators setup ?", "Need calibration", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
            }

            if (Result == DialogResult.Cancel)
            {
                LOGDraw(" canceled", true);
                return(false);
            }
            else
            {
                AttLevel Current = (AttLevel)AttLevelcomboBox.SelectedItem;

                if (Result == DialogResult.No)
                {
                    if (DeviceInterface.GetDevice().HaveLogDetector)
                    {
                        LOGDraw("Calibration for " + Current.ToString() + " attenuator, using logarithmic detector", true);
                        DeviceInterface.SetAttenuatorLevel(Current, Current);
                        DeviceInterface.RunCalibration(MyNotifier, 9999, false);
                    }
                    if (DeviceInterface.GetDevice().HaveLinDetector)
                    {
                        LOGDraw("Calibration for " + Current.ToString() + " attenuator, using linear detector..", true);
                        DeviceInterface.SetAttenuatorLevel(Current, Current);
                        DeviceInterface.RunCalibration(MyNotifier, 9999, true);
                    }

                    DeviceInterface.SaveCalibration(Program.CalibrationPath);
                    bCalibrationAvailable = true;
                    LOGDraw("done.");
                }
                else
                {
                    foreach (AttLevel Level in Enum.GetValues(typeof(AttLevel)))
                    {
                        if (DeviceInterface.GetDevice().HaveLogDetector)
                        {
                            LOGDraw("Calibration for " + Level.ToString() + " attenuator, using logarihtmic detector..", true);
                            DeviceInterface.SetAttenuatorLevel(Level, Level);
                            DeviceInterface.RunCalibration(MyNotifier, 4000, false);
                        }

                        if (DeviceInterface.GetDevice().HaveLinDetector)
                        {
                            LOGDraw("Calibration for " + Level.ToString() + " attenuator, using linear detector..", true);
                            DeviceInterface.SetAttenuatorLevel(Level, Level);
                            DeviceInterface.RunCalibration(MyNotifier, 4000, true);
                        }


                        LOGDraw("done.");
                    }
                    DeviceInterface.SaveCalibration(Program.CalibrationPath);
                    bCalibrationAvailable = true;

                    if (Program.Save.AttCal)
                    {
                        DeviceInterface.SetAttenuatorLevel(Current, Current);
                    }
                    else
                    {
                        DeviceInterface.SetAttenuatorLevel(Current, AttLevel._0dB);
                    }
                }

                return(true);
            }
        }
예제 #5
0
        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, " ");
        }