예제 #1
0
        public void ProcessSweepModeStartAcquisition()
        {
            if (!bDeviceConnected)
            {
                LOGError("No Device connected");
                return;
            }

            if (!Program.Save.RawCapture)
            {
                if (!CheckForCalibration())
                {
                    LOGError("No calibration available");
                    return;
                }
            }


            FillAcquisitionParams(CurrentAcquisitionParams);
            FillAcquisitionParams(NextAcquisitionParams);
            NextAcquisitionParams.ResultDatas = new float[NextAcquisitionParams.nCount];



            //MyNotifier.SetProgressBar(SweepProgressBar);
            LOGDraw("====================================", true);

            LOGDraw("Run sweep mode.", true);

            LOGDraw("BW:" + Utility.GetStringWithSeparators(nFrequencyDetectionEnd - nFrequencyDetectionStart, " ") + "Hz", false);
            LOGDraw(" samples:" + CurrentAcquisitionParams.nCount.ToString(), true);
            LOGDraw(" Step:" + CurrentAcquisitionParams.nFrequencyStep.ToString() + "Hz", false);
            LOGDraw(" Attenuator:" + GetCurrentAttenuatorLevel().ToString());

            SweepProcessButton.Enabled = false;
            ControlgroupBox.Enabled    = false;

            if (bLoop)
            {
                SweepProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
            }
            else
            {
                SweepProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
            }

            if (!DeviceInterface.IsPortOpen())
            {
                LOGWarning("Port not open, i try to open port");
                if (!DeviceInterface.TryToReOpenPort())
                {
                    LOGError("unable to open port. run device detection of manualy select available port");
                    ControlgroupBox.Enabled    = true;
                    SweepProcessButton.Enabled = true;
                    SweepProgressBar.Style     = System.Windows.Forms.ProgressBarStyle.Continuous;

                    if (bLoop)
                    {
                        SweepLoopStopButton.Enabled    = false;
                        SweepLoopProcessButton.Enabled = true;
                    }

                    return;
                }
                LOGDraw("Port open ok, i run the capture", true);
            }

            try
            {
                backgroundWorkerSerialCapture.RunWorkerAsync(NextAcquisitionParams);
            }
            catch (Exception ex)
            {
                LOGError(ex.Message);
            }
        }