Esempio n. 1
0
        private void singlePointMode_Click(object sender, RoutedEventArgs e)
        {
            Move.Stop();
            capturing = false;

            double wavenumFrom = -100, wavenumTo = 100, wavenumStep = 1;
            int    column     = (int)DataProcessing.XDataBase;
            uint   expoTime   = (uint)Ccd.ExpoTime;
            double end        = SpexPos + wavenumTo;
            double wavenumNow = SpexPos;

            Thread thread = new Thread(new ThreadStart(
                                           () =>
            {
                this.Dispatcher.Invoke((ThreadStart) delegate()
                {
                    moveAndProgress(SpexPos, SpexPos + wavenumFrom);
                });
                moveThread.Join();
                wavenumNow       += wavenumFrom;
                DataProcessing dp = new DataProcessing(true);
                Ccd.Setup(true, expoTime);
                Ccd.GetFrame(dp.DataArray);
                Ccd.Stop();
                this.Dispatcher.BeginInvoke((ThreadStart) delegate()
                {
                    dp.GetList(SpexPos);
                    monitor.Data = new List <Point>(dp.PointArray);
                });
                while (wavenumNow < end)
                {
                    this.Dispatcher.Invoke((ThreadStart) delegate()
                    {
                        moveAndProgress(SpexPos, SpexPos + wavenumStep);
                    });
                    moveThread.Join();
                    wavenumNow += wavenumStep;
                    Ccd.Setup(true, expoTime);
                    Ccd.GetFrame(dp.DataArray);
                    Ccd.Stop();
                    this.Dispatcher.BeginInvoke((ThreadStart) delegate()
                    {
                        dp.GetList(SpexPos);
                        dp.Append((System.Collections.Generic.List <Point>)monitor.Data);
                        monitor.RepaintLine(monitor.Data, false);
                    });
                }
            }));

            thread.Start();
        }
Esempio n. 2
0
        private void autoSpex_Click(object sender, RoutedEventArgs e)
        {
            if (!acquiring)
            {
                AutoSpexWindow autoSpexWindow = new AutoSpexWindow();
                autoSpexWindow.Owner = this;
                autoSpexWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;

                autoSpexWindow.ShowDialog();
                if (autoSpexWindow.DialogResult == true)
                {
                    acquiring                  = true;
                    acquire                    = true;
                    autoSpex.Content           = "停止采谱";
                    autoSpex.ToolTip           = "Stop acquiring";
                    startStopMoving.IsEnabled  = false;
                    startStopCapture.IsEnabled = false;
                    displaySettings.IsEnabled  = false;
                    hardwareSettings.IsEnabled = false;

                    Move.Stop();
                    capturing = false;

                    double waveNumFrom, waveNumTo, waveNumStep, waveNumDisInit, waveNumNow;
                    int    overlappedPixel;
                    int    expoTime;

                    waveNumFrom     = autoSpexWindow.WaveNumFrom;
                    waveNumTo       = autoSpexWindow.WaveNumTo;
                    waveNumStep     = (Ccd.ROITo - Ccd.ROIFrom) * DataProcessing.XScale - autoSpexWindow.OverlappedWaveNum;
                    overlappedPixel = (int)(autoSpexWindow.OverlappedWaveNum / monitor.XScale + 0.5);
                    waveNumDisInit  = waveNumFrom - (Ccd.ROIFrom - DataProcessing.XDataBase) * DataProcessing.XScale - SpexPos;
                    expoTime        = autoSpexWindow.ExpoTime;
                    waveNumNow      = SpexPos;

                    autoSpexThread = new Thread(new ThreadStart(
                                                    () =>
                    {
                        List <Point> data = new List <Point>();
                        if (moveThread != null)
                        {
                            moveThread.Join();
                        }
                        if (moveProgressThread != null)
                        {
                            moveProgressThread.Join();
                        }
                        if (getFrameThread != null)
                        {
                            getFrameThread.Join();
                        }

                        DataProcessing dp = new DataProcessing(true);
                        this.Dispatcher.Invoke((ThreadStart) delegate()
                        {
                            moveAndProgress(waveNumNow, waveNumNow + waveNumDisInit);
                        });
                        moveThread.Join();
                        waveNumNow += waveNumDisInit;
                        if (Ccd.Setup(true, (UInt32)expoTime) != 0)
                        {
                            Ccd.GetFrame(dp.DataArray);
                            Ccd.Stop();
                            this.Dispatcher.BeginInvoke((ThreadStart) delegate()
                            {
                                dp.GetList(SpexPos);
                                monitor.Data = new List <Point>(dp.PointArray);
                            });
                            waveNumFrom += waveNumStep;
                            while (acquire && waveNumFrom < waveNumTo)
                            {
                                //MessageBox.Show(waveNumNow.ToString());
                                this.Dispatcher.Invoke((ThreadStart) delegate()
                                {
                                    moveAndProgress(waveNumNow, waveNumNow + waveNumStep);
                                });
                                moveThread.Join();
                                waveNumNow += waveNumStep;
                                if (Ccd.Setup(true, (UInt32)expoTime) == 0)
                                {
                                    MessageBox.Show("无法初始化sequence", this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                                    break;
                                }
                                Ccd.GetFrame(dp.DataArray);
                                Ccd.Stop();
                                this.Dispatcher.BeginInvoke((ThreadStart) delegate()
                                {
                                    dp.GetList(SpexPos);
                                    dp.Append((System.Collections.Generic.List <Point>)monitor.Data);
                                    monitor.RepaintLine(monitor.Data, false);
                                });
                                waveNumFrom += waveNumStep;
                            }
                        }

                        this.Dispatcher.BeginInvoke((ThreadStart) delegate()
                        {
                            MessageBox.Show(SpexPos.ToString());
                            displaySettings.IsEnabled  = true;
                            hardwareSettings.IsEnabled = true;
                            startStopCapture.IsEnabled = true;
                            startStopMoving.IsEnabled  = true;
                            autoSpex.Content           = "自动采谱";
                            autoSpex.ToolTip           = "Start acquiring";
                        });
                        acquiring = false;
                    }));
                    autoSpexThread.Start();
                }
            }
            else
            {
                acquire = false;
                Move.Stop();
            }
        }
Esempio n. 3
0
 private void startStopCapture_Click(object sender, RoutedEventArgs e)
 {
     if (!capturing)
     {
         capturing = true;
         startStopCapture.Content = "停止";
         startStopCapture.ToolTip = "Stop";
         UInt32 size = Ccd.Setup(specCapturing, (UInt32)Ccd.ExpoTime);
         if (size == 0)
         {
             MessageBox.Show("无法初始化sequence", this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
             startStopCapture.Content = "监测";
             startStopCapture.ToolTip = "Start";
             capturing = false;
         }
         else
         {
             bool specNow = specCapturing;
             getFrameThread = new Thread(new ThreadStart(
                                             () =>
             {
                 DataProcessing dp = new DataProcessing(specNow);
                 while (capturing)
                 {
                     Thread.Sleep(Ccd.ExpoTime);
                     Ccd.GetFrame(dp.DataArray);
                     this.Dispatcher.BeginInvoke((ThreadStart) delegate()
                     {
                         if (specNow)
                         {
                             dp.GetList(SpexPos);
                             monitor.Data = dp.PointArray;
                         }
                         if (cw != null && cw.IsVisible)
                         {
                             cw.DataArray = dp.DataArray;
                         }
                     });
                     if (specNow != specCapturing)
                     {
                         Ccd.Stop();
                         if (Ccd.Setup(specCapturing, (UInt32)Ccd.ExpoTime) == 0)
                         {
                             break;
                         }
                         specNow = specCapturing;
                         dp      = new DataProcessing(specNow);
                     }
                 }
                 Ccd.Stop();
                 this.Dispatcher.BeginInvoke((ThreadStart) delegate()
                 {
                     startStopCapture.Content = "监测";
                     startStopCapture.ToolTip = "Start";
                 });
             }));
             getFrameThread.Start();
         }
     }
     else
     {
         capturing = false;
     }
 }