Beispiel #1
0
        void SetAnalyzer(int Index, bool TakeAcountOfSave = false)
        {
            if (DeviceArray.Count > 0)
            {
                NWTCompatibleDeviceDef DeviceDef = (NWTCompatibleDeviceDef)DeviceArray[Index];
                CurrentDeviceDef = DeviceDef;
                DeviceInterface.SetDevice(DeviceDef);
                LoadCalibrationFile();

                Int64 LowRange;
                Int64 HighRange;

                if (TakeAcountOfSave == true)
                {
                    if (Program.Save.LowFrequency >= DeviceInterface.MinFrequency &&
                        Program.Save.LowFrequency <= DeviceInterface.MaxFrequency)
                    {
                        LowRange = Program.Save.LowFrequency;
                    }
                    else
                    {
                        LowRange = DeviceInterface.MinFrequency;
                    }

                    if (Program.Save.HighFrequency <= DeviceInterface.MaxFrequency &&
                        Program.Save.HighFrequency >= DeviceInterface.MinFrequency)
                    {
                        HighRange = Program.Save.HighFrequency;
                    }
                    else
                    {
                        HighRange = DeviceInterface.MaxFrequency;
                    }
                }
                else
                {
                    LowRange  = DeviceInterface.MinFrequency;
                    HighRange = DeviceInterface.MaxFrequency;
                }

                SetSweepFrequencies(LowRange, HighRange);
                SetSweepFrequencies(LowRange, HighRange);


                CGraph Graph = SpectrumPictureBox.GetGraphConfig();

                Graph.fLastDrawingLevelLow      = -90;
                Graph.fLastDrawingLevelHigh     = 10;
                Graph.nLastDrawingLowFrequency  = LowRange;
                Graph.nLastDrawingHighFrequency = HighRange;
                SpectrumPictureBox.GetGraphConfig().DrawBackGround();

                if (!DeviceDef.Attenuator)
                {
                    AttLevelcomboBox.SelectedIndex = 0;
                    AttLevelcomboBox.Enabled       = false;
                }
                else
                {
                    AttLevelcomboBox.Enabled = true;
                    if (Program.Save.LastUsedAttLevel != null)
                    {
                        AttLevel Level;
                        try
                        {
                            Level = (AttLevel)System.Enum.Parse(typeof(AttLevel), Program.Save.LastUsedAttLevel);
                        }
                        catch (Exception)
                        {
                            Level = AttLevel._0dB;
                        }
                        AttLevelcomboBox.SelectedIndex = (int)Level;
                    }
                    else
                    {
                        AttLevelcomboBox.SelectedIndex = 0;
                    }
                }

                if (!DeviceDef.HaveLinDetector)
                {
                    DetectorCombobox.SelectedIndex = 0;
                    DetectorCombobox.Enabled       = false;
                }
                else
                {
                    DetectorCombobox.Enabled = true;
                }

                AttCalCheckBox.Enabled = DeviceDef.Attenuator;
            }

            if (SerialPortComboBox.SelectedItem != null)
            {
                SerialPortInitialize((String)SerialPortComboBox.SelectedItem);
            }
        }