Пример #1
0
        void ConnectCameraDoWork(object sender, DoWorkEventArgs e)
        {
            _statusVM.Busy++;
            DateTime timestamp = DateTime.Now;
            var      sts       = new StatusMessage {
                Timestamp = timestamp, Message = "Trying to connect to camera..."
            };

            _statusVM.Messages.Add(sts);
            _timestamps.Push(timestamp);

            _ptGreyImageQueue = new ConcurrentQueue <PtGreyCameraImage>();
            _ptGreyCamera     = new PtGreyCamera();
            long   width, height;
            string message;

            if (_ptGreyCamera.Open(_ptGreyImageQueue, out message, out width, out height))
            {
                _ptGreyStopImageThreadEvent = new System.Threading.AutoResetEvent(false);

                if (_ptGreyCamera.DefaultSettings())
                {
                    Properties.Settings.Default.VideoMode = 0;
                    Properties.Settings.Default.Save();
                    Gain      = Properties.Settings.Default.Gain;
                    Shutter   = Properties.Settings.Default.ShutterTimePhos;
                    WBred     = Properties.Settings.Default.WBRed;
                    WBblue    = Properties.Settings.Default.WBBlue;
                    VideoMode = Properties.Settings.Default.VideoMode;
                    _ptGreyCamera.StartVideo();

                    ImageHeight = height;
                    ImageWidth  = width;
                }
                else
                {
                    message = "Error: Could not load default camera settings";
                }

                e.Result = message;
            }
            else
            {
                e.Result = "Error: " + message;
            }
        }