Skip to content

Commit

Permalink
warm with minduration; extend cam info with TargetTemp and AtTargetTemp
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-photo committed Dec 28, 2024
1 parent ddbb922 commit 502b7c6
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 10 deletions.
88 changes: 84 additions & 4 deletions ninaAPI/WebService/V2/Equipment/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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()
Expand All @@ -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)
{
Expand Down Expand Up @@ -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";
}
}
Expand All @@ -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();
Expand Down Expand Up @@ -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";
}
}
Expand Down
11 changes: 11 additions & 0 deletions ninaAPI/api_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -3383,6 +3390,10 @@ components:
Response:
type: object
properties:
TargetTemp:
type: number
AtTargetTemp:
type: boolean
CanSetTemperature:
type: boolean
HasShutter:
Expand Down
22 changes: 16 additions & 6 deletions ninaAPI/buildAndCopy.bat
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 502b7c6

Please sign in to comment.