Exemple #1
0
        void SingleCurveDisplay(Int64 nFrequencyBase, Int64 nStep, float [] data)
        {
            int    Count = data.Length;
            CCurve Curve = (CCurve)SweepModeCurvesList[0];

            Curve.Color_ = Color.DeepPink;

            /*
             * CGraph Graph = SpectrumPictureBox.GetGraphConfig();
             * Graph.nLastDrawingLowFrequency = nFrequencyBase;
             * Graph.nLastDrawingHighFrequency = nFrequencyBase + nStep * Count;
             * Graph.fLastDrawingLevelLow = -90;
             * Graph.fLastDrawingLevelHigh = 0;
             *
             * SpectrumPictureBox.GetGraphConfig().DrawBackGround();
             */
            Curve.SpectrumValues         = data;
            Curve.nSpectrumLowFrequency  = nFrequencyBase;
            Curve.nSpectrumHighFrequency = nFrequencyBase + nStep * Count;
            Curve.Name = "Crystal";
            Curve.DetermineMinMaxLevels();

            SpectrumPictureBox.DrawCurveCollection(SweepModeCurvesList);
            //SpectrumPictureBox.DrawSingleCurve(Curve);
        }
        private void LoadCurveButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter           = "Curves files (*.xml)|*.xml|all files (*.*)|*.*";
            dialog.InitialDirectory = Program.CurvesPath;
            dialog.RestoreDirectory = true;


            if (dialog.ShowDialog() == DialogResult.OK)
            {
                XmlSerializer xs = new XmlSerializer(typeof(CCurve));
                using (StreamReader wr = new StreamReader(dialog.FileName))
                {
                    try
                    {
                        CCurve CurveToLoad = xs.Deserialize(wr) as CCurve;
                        CurveToLoad.ComputeCaracteristicsParams();

                        SweepModeCurvesList.Add(CurveToLoad);
                        UpdateCurveComboBoxFromCurveList();

                        SpectrumPictureBox.DrawCurveCollection(SweepModeCurvesList);
                        CurveListComboBox.SelectedIndex = SweepModeCurvesList.Count - 1;
                    }
                    catch (Exception)
                    {
                        LOGError("sorry, your curve file format is incompatible with this software version");
                    }

                    Program.CurvesPath = System.IO.Path.GetDirectoryName(dialog.FileName);
                }
            }
        }
        public void ProcessSweepModeDisplayAcquisition(NWTDevice.RunSweepModeParam AcquisitionParams)
        {
            CGraph Graph       = SpectrumPictureBox.GetGraphConfig();
            CCurve CurveConfig = (CCurve)CurveConfigPropertyGrid.SelectedObject;

            SpectrumPictureBox.SetActiveCurve(CurveConfig);

            CurveConfig.nSpectrumLowFrequency  = AcquisitionParams.nBaseFrequency;
            CurveConfig.nSpectrumHighFrequency = AcquisitionParams.nBaseFrequency + AcquisitionParams.nFrequencyStep * AcquisitionParams.nCount;
            CurveConfig.nFrequencyStep         = AcquisitionParams.nFrequencyStep;

            if (AcquisitionParams.ResultDatas != null)
            {
                Utility.FilterArray(AcquisitionParams.ResultDatas, (int)((FilterMode)FilterComboBox.SelectedItem));
                CurveConfig.SpectrumValues = AcquisitionParams.ResultDatas;
                CurveConfig.DetermineMinMaxLevels();
                CurveConfig.ComputeCaracteristicsParams();
                if (bLoop == false)
                {
                    LOGDraw(""); // new line
                    LOGDraw("*** ----- RESULTS----- ***");
                    LOGDraw(CurveConfig.GetCurveDescription());
                }
            }

            Graph.nLastDrawingLowFrequency  = nFrequencyDetectionStart;
            Graph.nLastDrawingHighFrequency = nFrequencyDetectionEnd;
            SpectrumPictureBox.DrawCurveCollection(SweepModeCurvesList, bLoop);
        }
 private void OutputModeComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (OutputModeComboBox.SelectedIndex != -1)
     {
         SpectrumPictureBox.Redraw();
     }
 }
Exemple #5
0
        public void FrequencyBoxUpdate(ref Int64 Storage, TextBox Box)
        {
            String Result = Utility.RemoveSeparator(Box.Text);

            Result = Result.Replace(",", ".");

            if (Result.Length > 0)
            {
                Storage = Convert.ToInt64(Result, new CultureInfo("en-US"));

                if (Storage > DeviceInterface.MaxFrequency || Storage < DeviceInterface.MinFrequency || nFrequencyDetectionEnd <= nFrequencyDetectionStart)
                {
                    Box.ForeColor = Color.Red;
                }
                else
                {
                    Box.ForeColor = Color.Black;

                    if (nFrequencyDetectionEnd > nFrequencyDetectionStart)
                    {
                        SpectrumPictureBox.GraphicUpdateScaleRefresh(nFrequencyDetectionStart, nFrequencyDetectionEnd);
                    }
                }
            }
        }
        private void CurveConfigPropertyGrid_PropertyValueChanged(object s, System.Windows.Forms.PropertyValueChangedEventArgs e)
        {
            CCurve Curve = (CCurve)CurveConfigPropertyGrid.SelectedObject;

            Curve.ComputeCaracteristicsParams();
            SpectrumPictureBox.Redraw();
            UpdateCurveComboBoxFromCurveList();
            CurveListComboBox.SelectedItem = CurveConfigPropertyGrid.SelectedObject;
        }
Exemple #7
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F1)
            {
                SpectrumPictureBox.ZoomDecrease();
            }

            if (e.KeyCode == Keys.F2)
            {
                SpectrumPictureBox.ZoomIncrease();
            }
        }
Exemple #8
0
        private void AddNewCurveButton_Click(object sender, EventArgs e)
        {
            CCurve NewCurve = new CCurve();

            NewCurve.Name   = "Curve_" + SweepModeCurvesList.Count;
            NewCurve.Color_ = GetDefaultCurveColor(SweepModeCurvesList.Count);
            SweepModeCurvesList.Add(NewCurve);
            CurveListComboBox.DataSource   = null;
            CurveListComboBox.DataSource   = SweepModeCurvesList;
            CurveListComboBox.SelectedItem = NewCurve;
            SpectrumPictureBox.DrawCurveCollection(SweepModeCurvesList);
            CurveConfigPropertyGrid.SelectedObject = NewCurve;
        }
Exemple #9
0
 private void DeleteCurveButton_Click(object sender, EventArgs e)
 {
     if (SweepModeCurvesList.Count > 1)
     {
         int nIndexToDelete = CurveListComboBox.SelectedIndex;
         CurveListComboBox.DataSource           = null;
         CurveConfigPropertyGrid.SelectedObject = null;
         SweepModeCurvesList.RemoveAt(nIndexToDelete);
         CurveListComboBox.DataSource = SweepModeCurvesList;
         SpectrumPictureBox.SetActiveCurve((CCurve)SweepModeCurvesList[0]);
         SpectrumPictureBox.DrawCurveCollection(SweepModeCurvesList);
         CurveListComboBox.SelectedIndex = 0;
     }
 }
 private void CurveListComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (CurveListComboBox.SelectedIndex != -1)
     {
         CurveConfigPropertyGrid.SelectedObject = SweepModeCurvesList[CurveListComboBox.SelectedIndex];
         SpectrumPictureBox.SetActiveCurve((CCurve)SweepModeCurvesList[CurveListComboBox.SelectedIndex]);
         SpectrumPictureBox.Redraw();
         CCurve Curve = (CCurve)SweepModeCurvesList[CurveListComboBox.SelectedIndex];
         if (Curve.SpectrumValues != null && Curve.SpectrumValues.Length > 0)
         {
             LOGDraw("***------ SELECTED CURVE ----------***");
             LOGDraw(Curve.GetCurveDescription());
         }
     }
 }
        private void DeleteCurveButton_Click(object sender, EventArgs e)
        {
            if (SweepModeCurvesList.Count > 1)
            {
                int nIndexToDelete = CurveListComboBox.SelectedIndex;
                //CurveListComboBox.DataSource = null;
                CurveConfigPropertyGrid.SelectedObject = null;
                SweepModeCurvesList.RemoveAt(nIndexToDelete);
                UpdateCurveComboBoxFromCurveList();
                SpectrumPictureBox.SetActiveCurve((CCurve)SweepModeCurvesList[0]);
                SpectrumPictureBox.DrawCurveCollection(SweepModeCurvesList);
                if (nIndexToDelete - 1 >= 0)
                {
                    CurveListComboBox.SelectedIndex = nIndexToDelete - 1;
                }
                else
                {
                    CurveListComboBox.SelectedIndex = 0;
                }

                CurveConfigPropertyGrid.SelectedObject = SweepModeCurvesList[CurveListComboBox.SelectedIndex];

                /*
                 *              int nIndexToDelete = CurveListComboBox.SelectedIndex;
                 *              CurveListComboBox.DataSource = null;
                 *              CurveConfigPropertyGrid.SelectedObject = null;
                 *              SweepModeCurvesList.RemoveAt(nIndexToDelete);
                 *              CurveListComboBox.Items.Clear();
                 *              CurveListComboBox.Items.AddRange(SweepModeCurvesList.ToArray());
                 *              SpectrumPictureBox.SetActiveCurve((CCurve)SweepModeCurvesList[0]);
                 *              SpectrumPictureBox.DrawCurveCollection(SweepModeCurvesList);
                 *              CurveListComboBox.SelectedIndex = 0;
                 *              CurveConfigPropertyGrid.SelectedObject = SweepModeCurvesList[0];
                 */
            }
        }
Exemple #12
0
 private void SpectrumPictureBox_MouseMove(object sender, MouseEventArgs e)
 {
     SpectrumPictureBox.OnMouseMove(sender, e);
 }
Exemple #13
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, " ");
        }
Exemple #14
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);
            }
        }
Exemple #15
0
 private void copyToClipboardToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SpectrumPictureBox.CopyPictureToclipboard();
 }
Exemple #16
0
 private void MenuSavePicture_Click(object sender, EventArgs e)
 {
     SpectrumPictureBox.SavePicture();
 }
Exemple #17
0
 private void SpectrumPictureBox_SizeChanged(object sender, EventArgs e)
 {
     SpectrumPictureBox.ResizeAndRedraw(sender, e);
 }
Exemple #18
0
 private void SpectrumPictureBox_Click(object sender, EventArgs e)
 {
     SpectrumPictureBox.MouseClicManagement(sender, e);
 }