private void DeviceAdded(NikonManager sender, NikonDevice device) { dev = device; if (SaveToPc) { dev.SetUnsigned(eNkMAIDCapability.kNkMAIDCapability_SaveMedia, (uint)eNkMAIDSaveMedia.kNkMAIDSaveMedia_Card_SDRAM); } else { dev.SetUnsigned(eNkMAIDCapability.kNkMAIDCapability_SaveMedia, (uint)eNkMAIDSaveMedia.kNkMAIDSaveMedia_Card); } dev.ImageReady += DeviceImageReady; dev.CaptureComplete += OnCaptureComplete; Console.WriteLine("Fotocamera collegata!"); dev.SetBoolean(eNkMAIDCapability.kNkMAIDCapability_LockCamera, false); dev.SetUnsigned(eNkMAIDCapability.kNkMAIDCapability_ApertureLockSetting, 0); IsConnected = true; IsReady = true; IsSaved = true; OnConnected(); }
private void BulbCapture(double exposureTime) { // Lock camera so we can change it to 'manual exposure' eNkMAIDCapability lockCameraCap = eNkMAIDCapability.kNkMAIDCapability_LockCamera; _camera.SetBoolean(lockCameraCap, true); // Set camera to manual exposure eNkMAIDCapability exposureModeCap = eNkMAIDCapability.kNkMAIDCapability_ExposureMode; NikonEnum exposureMode = _camera.GetEnum(exposureModeCap); exposureMode.Index = (int)eNkMAIDExposureMode.kNkMAIDExposureMode_Manual; _camera.SetEnum(exposureModeCap, exposureMode); // Set shutter speed to 'bulb' eNkMAIDCapability shutterSpeedCap = eNkMAIDCapability.kNkMAIDCapability_ShutterSpeed; NikonEnum shutterSpeed = _camera.GetEnum(shutterSpeedCap); for (int i = 0; i < shutterSpeed.Length; i++) { if (shutterSpeed.GetEnumValueByIndex(i).ToString().ToLower() == "bulb") { Console.WriteLine("Index " + i.ToString()); shutterSpeed.Index = i; _camera.SetEnum(shutterSpeedCap, shutterSpeed); break; } } // Capture - and ignore the 'BulbReleaseBusy' exception. This is expected. try { _camera.Capture(); } catch (NikonException ex) { if (ex.ErrorCode != eNkMAIDResult.kNkMAIDResult_BulbReleaseBusy) { throw; } } // What for 5 seconds - or however long you want to capture Thread.Sleep(TimeSpan.FromSeconds(exposureTime)); // Stop bulb capture (Note: must be compiled with 'unsafe code' enabled) NkMAIDTerminateCapture terminate = new NkMAIDTerminateCapture(); terminate.ulParameter1 = 0; terminate.ulParameter2 = 0; unsafe { IntPtr terminate_pointer = new IntPtr(&terminate); _camera.Start( eNkMAIDCapability.kNkMAIDCapability_TerminateCapture, eNkMAIDDataType.kNkMAIDDataType_GenericPtr, terminate_pointer); } // Unlock camera _camera.SetBoolean(lockCameraCap, false); }
public void Close() { dev?.SetBoolean(eNkMAIDCapability.kNkMAIDCapability_LockCamera, false); man.Shutdown(); }