private void StartCaptureThread()
        {
            bool retry;

            do
            {
                retry = false;
                try
                {
                    Log.Debug("Bulb capture started");
                    if (UseExternal)
                    {
                        if (SelectedConfig != null)
                        {
                            NikonBase nikonBase = CameraDevice as NikonBase;
                            if (nikonBase != null)
                            {
                                nikonBase.StopEventTimer();
                            }
                            ServiceProvider.ExternalDeviceManager.OpenShutter(SelectedConfig);
                        }
                        else
                        {
                            StaticHelper.Instance.SystemMessage = TranslationStrings.LabelNoExternalDeviceSelected;
                        }
                    }
                    else
                    {
                        if (CameraDevice.GetCapability(CapabilityEnum.Bulb))
                        {
                            CameraDevice.LockCamera();
                            CameraDevice.StartBulbMode();
                        }
                        else
                        {
                            StaticHelper.Instance.SystemMessage = TranslationStrings.MsgBulbModeNotSupported;
                        }
                    }
                }
                catch (DeviceException deviceException)
                {
                    if (deviceException.ErrorCode == ErrorCodes.ERROR_BUSY)
                    {
                        retry = true;
                    }
                    else
                    {
                        StaticHelper.Instance.SystemMessage = deviceException.Message;
                        Log.Error("Bulb start", deviceException);
                    }
                }
                catch (Exception exception)
                {
                    StaticHelper.Instance.SystemMessage = exception.Message;
                    Log.Error("Bulb start", exception);
                }
            } while (retry);
        }
 private void btn_start_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (ServiceProvider.Settings.DefaultSession.WriteComment)
         {
             ServiceProvider.Settings.DefaultSession.Comment  = "c=" + slider_cmera.Value + "|";
             ServiceProvider.Settings.DefaultSession.Comment += "dw=" + slider_drop_wait.Value + "|";
             ServiceProvider.Settings.DefaultSession.Comment += "dw2=" + slider_drop2_wait.Value + "|";
             ServiceProvider.Settings.DefaultSession.Comment += "d1=" + slider_drop1.Value + "|";
             ServiceProvider.Settings.DefaultSession.Comment += "d2=" + slider_drop2.Value + "|";
             ServiceProvider.Settings.DefaultSession.Comment += "d3=" + slider_drop3.Value + "|";
             ServiceProvider.Settings.DefaultSession.Comment += "f=" + slider_flash.Value.ToString() + "|";
         }
         if (chk_external.IsChecked == true)
         {
             NikonBase camera = ServiceProvider.DeviceManager.SelectedCameraDevice as NikonBase;
             if (camera != null)
             {
                 camera.StopEventTimer();
                 _timer.Interval = GetTotalLength() + 100;
                 _timer.Start();
             }
         }
         else
         {
             ServiceProvider.DeviceManager.SelectedCameraDevice.CapturePhoto();
         }
         OpenPort();
         sp.WriteLine(" ");
     }
     catch (Exception exception)
     {
         lst_message.Items.Add(exception.Message);
     }
 }
        private void StartCaptureThread()
        {
            bool retry;

            Message = "";
            do
            {
                retry = false;
                try
                {
                    Log.Debug("Bulb capture started");
                    CountDown = CaptureTime;
                    Event     = "Capture";
                    PhotoLeft--;
                    if (DefaultScript.UseExternal)
                    {
                        if (DefaultScript.SelectedConfig != null)
                        {
                            NikonBase nikonBase = CameraDevice as NikonBase;
                            if (nikonBase != null)
                            {
                                nikonBase.StopEventTimer();
                            }
                            ServiceProvider.ExternalDeviceManager.OpenShutter(DefaultScript.SelectedConfig);
                        }
                        else
                        {
                            MessageBox.Show(TranslationStrings.LabelNoExternalDeviceSelected);
                        }
                    }
                    else
                    {
                        if (CameraDevice.GetCapability(CapabilityEnum.Bulb))
                        {
                            expDelay   = CameraDevice.GetExposureDelay();
                            CountDown += expDelay;
                            waitDelay  = CameraDevice.GetPropertyValue(NikonBase.CONST_PROP_NoiseReduction) == "ON" ? CaptureTime : 0;
                            ServiceProvider.DeviceManager.LastCapturedImage[CameraDevice] = "-";
                            CameraDevice.IsBusy = true;
                            CameraDevice.LockCamera();
                            CameraDevice.StartBulbMode();
                        }
                        else
                        {
                            StaticHelper.Instance.SystemMessage = TranslationStrings.MsgBulbModeNotSupported;
                        }
                    }
                }
                catch (DeviceException deviceException)
                {
                    if (deviceException.ErrorCode == ErrorCodes.ERROR_BUSY)
                    {
                        retry = true;
                    }
                    else
                    {
                        StaticHelper.Instance.SystemMessage = deviceException.Message;
                        Log.Error("Bulb start", deviceException);
                        CameraDevice.IsBusy = false;
                    }
                }
                catch (Exception exception)
                {
                    StaticHelper.Instance.SystemMessage = exception.Message;
                    Log.Error("Bulb start", exception);
                    Event               = "Error";
                    CountDown           = 0;
                    CameraDevice.IsBusy = false;
                    return;
                }
            } while (retry);
            _waitSecs    = 0;
            _captureSecs = 0;
            _captureTimer.Start();
        }
Exemple #4
0
        private void StartCaptureThread()
        {
            bool retry;

            Message = "";
            do
            {
                retry = false;
                try
                {
                    Log.Debug("Bulb capture started");
                    CountDown = CaptureTime;
                    Event     = "Capture";
                    PhotoLeft--;
                    if (DefaultScript.UseExternal)
                    {
                        if (DefaultScript.SelectedConfig != null)
                        {
                            NikonBase nikonBase = CameraDevice as NikonBase;
                            if (nikonBase != null)
                            {
                                nikonBase.StopEventTimer();
                            }
                            ServiceProvider.ExternalDeviceManager.OpenShutter(DefaultScript.SelectedConfig);
                        }
                        else
                        {
                            MessageBox.Show(TranslationStrings.LabelNoExternalDeviceSelected);
                        }
                    }
                    else
                    {
                        if (CameraDevice.GetCapability(CapabilityEnum.Bulb))
                        {
                            AsyncObservableCollection <PropertyValue <long> > coll = CameraDevice.AdvancedProperties;
                            foreach (PropertyValue <long> prop in coll)
                            {
                                if (prop.Code == 0xD06A && !string.IsNullOrEmpty(prop.Value)) //.Name == "Exposure delay mode")
                                {
                                    if (prop.Value != "OFF")
                                    {
                                        expDelay = int.Parse(prop.Value.Substring(0, 1));
                                        //expDelay = (int)prop.NumericValue;
                                        CountDown += expDelay;
                                    }
                                    else
                                    {
                                        expDelay = 0;
                                    }
                                }
                                else if (prop.Code == NikonBase.CONST_PROP_NoiseReduction && prop.Value != null)
                                {
                                    waitDelay = prop.Value == "ON" ? CaptureTime : 0;
                                }
                            }
                            ServiceProvider.DeviceManager.LastCapturedImage[CameraDevice] = "";
                            CameraDevice.IsBusy = true;
                            CameraDevice.LockCamera();
                            CameraDevice.StartBulbMode();
                        }
                        else
                        {
                            StaticHelper.Instance.SystemMessage = TranslationStrings.MsgBulbModeNotSupported;
                        }
                    }
                }
                catch (DeviceException deviceException)
                {
                    if (deviceException.ErrorCode == ErrorCodes.ERROR_BUSY)
                    {
                        retry = true;
                    }
                    else
                    {
                        StaticHelper.Instance.SystemMessage = deviceException.Message;
                        Log.Error("Bulb start", deviceException);
                        CameraDevice.IsBusy = false;
                    }
                }
                catch (Exception exception)
                {
                    StaticHelper.Instance.SystemMessage = exception.Message;
                    Log.Error("Bulb start", exception);
                    Event               = "Error";
                    CountDown           = 0;
                    CameraDevice.IsBusy = false;
                    return;
                }
            } while (retry);
            _waitSecs    = 0;
            _captureSecs = 0;
            _captureTimer.Start();
        }