From 502b7c6457900ba48ea249fc5ee391dc7d501fa3 Mon Sep 17 00:00:00 2001 From: rennmaus-coder <77056626+rennmaus-coder@users.noreply.github.com> Date: Sat, 28 Dec 2024 15:57:45 +0100 Subject: [PATCH] warm with minduration; extend cam info with TargetTemp and AtTargetTemp --- ninaAPI/WebService/V2/Equipment/Camera.cs | 88 +++++++++++++++++++++-- ninaAPI/api_spec.yaml | 11 +++ ninaAPI/buildAndCopy.bat | 22 ++++-- 3 files changed, 111 insertions(+), 10 deletions(-) diff --git a/ninaAPI/WebService/V2/Equipment/Camera.cs b/ninaAPI/WebService/V2/Equipment/Camera.cs index b112694..53705c0 100644 --- a/ninaAPI/WebService/V2/Equipment/Camera.cs +++ b/ninaAPI/WebService/V2/Equipment/Camera.cs @@ -26,6 +26,7 @@ This Source Code Form is subject to the terms of the Mozilla Public using NINA.Profile.Interfaces; using ninaAPI.Utility; using NINA.Core.Utility; +using NINA.Equipment.Equipment.MyCamera; namespace ninaAPI.WebService.V2 { @@ -35,6 +36,84 @@ class CaptureResponse public PlateSolveResult PlateSolveResult { get; set; } } + class CameraInfoResponse : CameraInfo + { + public static CameraInfoResponse FromCam(ICameraMediator cam) + { + return new CameraInfoResponse() + { + Connected = cam.GetInfo().Connected, + CanSetTemperature = cam.GetInfo().CanSetTemperature, + HasDewHeater = cam.GetInfo().HasDewHeater, + IsExposing = cam.GetInfo().IsExposing, + PixelSize = cam.GetInfo().PixelSize, + BinX = cam.GetInfo().BinX, + BinY = cam.GetInfo().BinY, + Battery = cam.GetInfo().Battery, + Offset = cam.GetInfo().Offset, + OffsetMin = cam.GetInfo().OffsetMin, + OffsetMax = cam.GetInfo().OffsetMax, + DefaultOffset = cam.GetInfo().DefaultOffset, + USBLimit = cam.GetInfo().USBLimit, + USBLimitMin = cam.GetInfo().USBLimitMin, + USBLimitMax = cam.GetInfo().USBLimitMax, + DefaultGain = cam.GetInfo().DefaultGain, + GainMin = cam.GetInfo().GainMin, + GainMax = cam.GetInfo().GainMax, + CanSetGain = cam.GetInfo().CanSetGain, + Gains = cam.GetInfo().Gains, + CoolerOn = cam.GetInfo().CoolerOn, + CoolerPower = cam.GetInfo().CoolerPower, + HasShutter = cam.GetInfo().HasShutter, + Temperature = cam.GetInfo().Temperature, + TemperatureSetPoint = cam.GetInfo().TemperatureSetPoint, + ReadoutModes = cam.GetInfo().ReadoutModes, + ReadoutMode = cam.GetInfo().ReadoutMode, + ReadoutModeForSnapImages = cam.GetInfo().ReadoutModeForSnapImages, + ReadoutModeForNormalImages = cam.GetInfo().ReadoutModeForNormalImages, + IsSubSampleEnabled = cam.GetInfo().IsSubSampleEnabled, + SubSampleX = cam.GetInfo().SubSampleX, + SubSampleY = cam.GetInfo().SubSampleY, + SubSampleWidth = cam.GetInfo().SubSampleWidth, + SubSampleHeight = cam.GetInfo().SubSampleHeight, + ExposureMax = cam.GetInfo().ExposureMax, + ExposureMin = cam.GetInfo().ExposureMin, + LiveViewEnabled = cam.GetInfo().LiveViewEnabled, + CanShowLiveView = cam.GetInfo().CanShowLiveView, + SupportedActions = cam.GetInfo().SupportedActions, + CanSetUSBLimit = cam.GetInfo().CanSetUSBLimit, + Name = cam.GetInfo().Name, + DisplayName = cam.GetInfo().DisplayName, + DeviceId = cam.GetInfo().DeviceId, + BayerOffsetX = cam.GetInfo().BayerOffsetX, + BayerOffsetY = cam.GetInfo().BayerOffsetY, + BinningModes = cam.GetInfo().BinningModes, + BitDepth = cam.GetInfo().BitDepth, + CameraState = cam.GetInfo().CameraState, + XSize = cam.GetInfo().XSize, + YSize = cam.GetInfo().YSize, + CanGetGain = cam.GetInfo().CanGetGain, + CanSetOffset = cam.GetInfo().CanSetOffset, + CanSubSample = cam.GetInfo().CanSubSample, + Description = cam.GetInfo().Description, + DewHeaterOn = cam.GetInfo().DewHeaterOn, + DriverInfo = cam.GetInfo().DriverInfo, + DriverVersion = cam.GetInfo().DriverVersion, + ElectronsPerADU = cam.GetInfo().ElectronsPerADU, + ExposureEndTime = cam.GetInfo().ExposureEndTime, + LastDownloadTime = cam.GetInfo().LastDownloadTime, + SensorType = cam.GetInfo().SensorType, + Gain = cam.GetInfo().Gain, + offsetMax = cam.GetInfo().offsetMax, + offsetMin = cam.GetInfo().offsetMin, + TargetTemp = cam.TargetTemp, + AtTargetTemp = cam.AtTargetTemp, + }; + } + public double TargetTemp { get; set; } + public bool AtTargetTemp { get; set; } + } + public partial class ControllerV2 { public static void StartCameraWatchers() @@ -60,7 +139,8 @@ public void CameraInfo() try { ICameraMediator cam = AdvancedAPI.Controls.Camera; - response.Response = cam.GetInfo(); + CameraInfoResponse info = CameraInfoResponse.FromCam(cam); + response.Response = info; } catch (Exception ex) { @@ -151,7 +231,7 @@ public void CameraCool([QueryField] double temperature, [QueryField] bool cancel { CameraCoolToken?.Cancel(); CameraCoolToken = new CancellationTokenSource(); - cam.CoolCamera(temperature, TimeSpan.FromMinutes(minutes), AdvancedAPI.Controls.StatusMediator.GetStatus(), CameraCoolToken.Token); + cam.CoolCamera(temperature, TimeSpan.FromMinutes(minutes == -1 ? AdvancedAPI.Controls.Profile.ActiveProfile.CameraSettings.CoolingDuration : minutes), AdvancedAPI.Controls.StatusMediator.GetStatus(), CameraCoolToken.Token); response.Response = "Cooling started"; } } @@ -166,7 +246,7 @@ public void CameraCool([QueryField] double temperature, [QueryField] bool cancel } [Route(HttpVerbs.Get, "/equipment/camera/warm")] - public void CameraWarm([QueryField] bool cancel) + public void CameraWarm([QueryField] bool cancel, [QueryField] double minutes) { Logger.Debug($"API call: {HttpContext.Request.Url.AbsoluteUri}"); HttpResponse response = new HttpResponse(); @@ -194,7 +274,7 @@ public void CameraWarm([QueryField] bool cancel) { CameraCoolToken?.Cancel(); CameraCoolToken = new CancellationTokenSource(); - cam.WarmCamera(TimeSpan.Zero, AdvancedAPI.Controls.StatusMediator.GetStatus(), CameraCoolToken.Token); + cam.WarmCamera(TimeSpan.FromMinutes(minutes == -1 ? AdvancedAPI.Controls.Profile.ActiveProfile.CameraSettings.WarmingDuration : minutes), AdvancedAPI.Controls.StatusMediator.GetStatus(), CameraCoolToken.Token); response.Response = "Warming started"; } } diff --git a/ninaAPI/api_spec.yaml b/ninaAPI/api_spec.yaml index 6598fea..c423c4c 100644 --- a/ninaAPI/api_spec.yaml +++ b/ninaAPI/api_spec.yaml @@ -189,6 +189,13 @@ paths: summary: Warming description: This endpoint warms the camera. parameters: + - in: query + name: minutes + description: The minimum duration to warm the camera. + required: false + schema: + type: number + format: double - in: query name: cancel description: Whether to cancel the warming process. @@ -3383,6 +3390,10 @@ components: Response: type: object properties: + TargetTemp: + type: number + AtTargetTemp: + type: boolean CanSetTemperature: type: boolean HasShutter: diff --git a/ninaAPI/buildAndCopy.bat b/ninaAPI/buildAndCopy.bat index e617f1b..db1534f 100644 --- a/ninaAPI/buildAndCopy.bat +++ b/ninaAPI/buildAndCopy.bat @@ -1,17 +1,27 @@ dotnet build C:\Users\Christian\source\repos\NINA\ninaAPI\ninaAPI\ninaAPI.csproj /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary /p:Configuration=Release /p:Platform="AnyCPU" -pwsh.exe CreateNET7Manifest.ps1 -file "C:\Users\Christian\AppData\Local\NINA\Plugins\3.0.0\Advanced API\ninaAPI.dll" -includeAll -createArchive +pwsh -Command Compress-Archive -Path 'C:\Users\Christian\AppData\Local\NINA\Plugins\3.0.0\Advanced API\*' -Destination ninaAPI.zip -Force +set /p beta="Should this be a beta release? y/n: " +set /p version="Version: " +if %beta%==y ( + set /p b_v="What beta version is that?: " + gh release create %version%-b.%b_v% ninaAPI.zip -title ninaAPI %version%-beta %b_v% -p + pwsh.exe CreateNET7Manifest.ps1 -file ninaAPI.zip -beta -installerUrl "https://github.com/christian-photo/ninaAPI/releases/download/%version%-b.%b_v%/ninaAPI.zip" +) +else ( + gh release create %version% ninaAPI.zip -title %version% + pwsh.exe CreateNET7Manifest.ps1 -file ninaAPI.zip -installerUrl "https://github.com/christian-photo/ninaAPI/releases/download/%version%/ninaAPI.zip" +) cd .. cd .. cd nina.plugin.manifests git pull git pull https://AstroChris23@bitbucket.org/Isbeorn/nina.plugin.manifests.git -copy ..\ninaAPI\ninaAPI\manifest.json manifests\n\ninaAPI\3.0.0\manifest.json -echo "Please finish the manifest and upload the file" -pause +copy ..\ninaAPI\ninaAPI\manifest.json manifests\n\ninaAPI\3.0.0\%version%\manifest.json +echo "Testing the manifest" node gather +echo "Please verify that the test ran successfully" pause -set /p "version=Enter Version: " git add manifests\n\ninaAPI\3.0.0\* -git commit -m "Added ninaAPI manifest" +git commit -m "Added ninaAPI manifest for version %version%" git push origin main pause \ No newline at end of file