diff --git a/Drivers/CameraDriver.cs b/Drivers/CameraDriver.cs index c928898..8e134df 100644 --- a/Drivers/CameraDriver.cs +++ b/Drivers/CameraDriver.cs @@ -25,9 +25,9 @@ namespace NINA.RetroKiwi.Plugin.SonyCamera.Drivers { public class CameraDriver : BaseINPC, ICamera { // Some camera settings we are interested in - private const uint PROPID_BATTERY = 53784; - private const uint PROPID_ISO = 53790; // Actual ISO currently set - private const uint PROPID_ISOS = 65534; // List of learnt ISOs this camera supports + private const uint PROPID_BATTERY = 53784; + private const uint PROPID_ISO = 0xD21E; // Actual ISO currently set + private const uint PROPID_ISOS = PROPID_ISO; // List of learnt ISOs this camera supports // Capture Status private const uint CAPTURE_CREATED = 0x0000; @@ -232,9 +232,14 @@ public bool CanGetGain { public int GainMax { get { if (_camera != null) { - PropertyInfo gainInfo = _camera.GetPropertyInfo(PROPID_ISOS); + try { + PropertyInfo gainInfo = _camera.GetPropertyInfo(PROPID_ISOS); - return (int)gainInfo.Options().Last().Value; + return (int)gainInfo.Options().Where(o => o.Value <= 0x00FFFFFF).Last().Value; + } catch (Exception ex) { + Logger.Error("Problem getting gain min", ex); + return -1; + } } else { return 0; } @@ -244,9 +249,14 @@ public int GainMax { public int GainMin { get { if (_camera != null) { - PropertyInfo gainInfo = _camera.GetPropertyInfo(PROPID_ISOS); + try { + PropertyInfo gainInfo = _camera.GetPropertyInfo(PROPID_ISOS); - return (int)gainInfo.Options().Min(o => o.Value); + return (int)gainInfo.Options().Where(o => o.Value <= 0x00FFFFFF).Min(o => o.Value); + } catch (Exception ex) { + Logger.Error("Problem getting gain max", ex); + return -1; + } } else { return -1; } @@ -258,7 +268,6 @@ public int Gain { if (_camera != null) { try { PropertyValue value = GetPropertyValue(PROPID_ISO); - PropertyInfo gainInfo = _camera.GetPropertyInfo(PROPID_ISOS); return (int)(value.Value == 0xffffff ? 0 : value.Value); } catch (Exception ex) { @@ -288,7 +297,7 @@ public IList Gains { if (_camera != null) { PropertyInfo gainInfo = _camera.GetPropertyInfo(PROPID_ISOS); - foreach (var iso in gainInfo.Options()) { + foreach (var iso in gainInfo.Options().Where(o => o.Value <= 0x00FFFFFF)) { if (iso.Value == 0xffffff) { // AUTO gains.Add(0); @@ -343,6 +352,7 @@ public double TemperatureSetPoint { set { } } + public bool CanSubSample => false; public bool EnableSubSample { get; set; } @@ -441,8 +451,7 @@ public Task Connect(CancellationToken token) { return Task.Run(() => { try { _camera = SonyDriver.GetInstance().OpenCamera(_device.Id); - } - catch (Exception ex) { + } catch (Exception ex) { Logger.Error(ex); _camera = null; } @@ -468,7 +477,8 @@ public Task DownloadLiveView(CancellationToken token) { using (var memStream = new MemoryStream(SonyDriver.GetInstance().GetLiveView(_camera.Handle))) { memStream.Position = 0; - JpegBitmapDecoder decoder = new JpegBitmapDecoder(memStream, BitmapCreateOptions.IgnoreColorProfile, BitmapCacheOption.OnLoad); + JpegBitmapDecoder decoder = + new JpegBitmapDecoder(memStream, BitmapCreateOptions.IgnoreColorProfile, BitmapCacheOption.OnLoad); FormatConvertedBitmap bitmap = new FormatConvertedBitmap(); bitmap.BeginInit(); @@ -482,15 +492,16 @@ public Task DownloadLiveView(CancellationToken token) { var metaData = new ImageMetaData(); return _exposureDataFactory.CreateImageArrayExposureData( - input: outArray, - width: bitmap.PixelWidth, - height: bitmap.PixelHeight, - bitDepth: 16, - isBayered: false, - metaData: metaData); + input: outArray, + width: bitmap.PixelWidth, + height: bitmap.PixelHeight, + bitDepth: 16, + isBayered: false, + metaData: metaData); } }); } + public void SetupDialog() { throw new NotImplementedException(); } @@ -500,7 +511,8 @@ public void StartExposure(CaptureSequence sequence) { SonyDriver driver = SonyDriver.GetInstance(); uint captureStatus = driver.GetCaptureStatus(_camera.Handle); - if (captureStatus == CAPTURE_CAPTURING || captureStatus == CAPTURE_PROCESSING || captureStatus == CAPTURE_STARTING || captureStatus == CAPTURE_READING || captureStatus == CAPTURE_PROCESSING) { + if (captureStatus == CAPTURE_CAPTURING || captureStatus == CAPTURE_PROCESSING || captureStatus == CAPTURE_STARTING || + captureStatus == CAPTURE_READING || captureStatus == CAPTURE_PROCESSING) { Notification.ShowWarning("Another exposure still in progress. Cancelling it to start another."); } @@ -508,7 +520,7 @@ public void StartExposure(CaptureSequence sequence) { driver.CancelCapture(_camera.Handle); double exposureTime = sequence.ExposureTime; - driver.StartCapture(_camera.Handle, (float)exposureTime);//); + driver.StartCapture(_camera.Handle, (float)exposureTime); //); } } @@ -530,7 +542,8 @@ public async Task WaitUntilExposureIsReady(CancellationToken token) { try { uint captureStatus = driver.GetCaptureStatus(_camera.Handle); - Logger.Info($"Waiting for image to be ready, current state is {captureStatus}, completion states are {String.Join(", ", completionStates)}"); + Logger.Info( + $"Waiting for image to be ready, current state is {captureStatus}, completion states are {String.Join(", ", completionStates)}"); while (!completionStates.Contains(captureStatus)) { await CoreUtil.Wait(TimeSpan.FromMilliseconds(100), token); @@ -583,6 +596,10 @@ public string SendCommandString(string command, bool raw = true) { public void SetBinning(short x, short y) { // Ignore } + + public void UpdateSubSampleArea() { + throw new NotImplementedException(); + } #endregion diff --git a/NINASonyCameraPlugin.csproj b/NINASonyCameraPlugin.csproj index d0b7dd3..4b16149 100644 --- a/NINASonyCameraPlugin.csproj +++ b/NINASonyCameraPlugin.csproj @@ -12,7 +12,7 @@ - + @@ -21,7 +21,6 @@ - @@ -29,21 +28,10 @@ - - - - - - - - - - - @@ -55,17 +43,12 @@ - - - + + - - - - @@ -99,6 +82,6 @@ - + \ No newline at end of file