Skip to content

Commit

Permalink
Merge pull request #23 from christian-photo/2.1.7.0
Browse files Browse the repository at this point in the history
2.1.7.0
  • Loading branch information
christian-photo authored Feb 4, 2025
2 parents d29c774 + 46db471 commit 020aac4
Show file tree
Hide file tree
Showing 29 changed files with 920 additions and 135 deletions.
29 changes: 19 additions & 10 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
The changes for each individual beta release can be seen [here](https://github.com/christian-photo/ninaAPI/releases)

## 2.1.6.0
## 2.1.7.1

- ⚠️ **Breaking** Enums are now serialized as strings, check the documentation for concrete updates. Please note, that not everything might be updated correctly ⚠️
- **Added support for the Livestack plugin (>= 1.0.0.9)**
- `livestack/start` to start the livestack
- `livestack/stop` to stop the livestack
- `livestack/image/{target}/{filter}` to get the current stacked image for a given filter and target
- `STACK-UPDATED` event in the websocket added, to notify when a new image is available

- Added `waitForResult` to `framing/slew`
- Added `version` to the documentation, it was always there just not documented
- Added `application/plugins` to get a list of installed plugins

- Added a 1s delay to the `IMAGE-SAVE` event to give NINA a bit more time to finish up the image
- `image/{index}` now automatically retries the image retrieval 10 times with a 200ms delay between each try, if it fails to load the image (because it is in use for example)

- Fixed solving a capture image
- Fixed an issue where the slew failed if no image was loaded in the framing assistant. An image is now automatically loaded

### Changes
## 2.1.6.0

- `framing/determine-rotation` added to determine the rotation from the camera
- `camera/set-binning` added to set the binning of the camera, the binning mode has to be supported by the camera
Expand All @@ -19,8 +36,6 @@ The changes for each individual beta release can be seen [here](https://github.c

## 2.1.5.0

### Changes

- `mount/flip` added to perform a meridian flip, the flip will only be executed if it is needed
- `mount/slew` slews the mount to the specified ra and dec angles
- `dome/set-follow` to start or stop the dome following the mount
Expand All @@ -30,17 +45,13 @@ The changes for each individual beta release can be seen [here](https://github.c

## 2.1.4.0

### Changes

- `guider/start` now accepts the parameter calibrate to force a calibration (true / false)
- Guider info now contains a State field indicating what the guider is currently doing
- `guider/clear-calibration` added to clear the current calibration
- `guider/graph` to get the last n guide steps as configured on the guide graph in NINA (in NINA you can set x to be 50, 100, 200 or 400)

## 2.1.3.0

### Changes

- Added query parameter `skipRescan` to all connect endpoints, which can be used to skip the rescanning process resulting in a faster connection
- Some websocket events now include more information:
- `FILTERWHEEL-CHANGED` includes the previous and new filter
Expand All @@ -52,8 +63,6 @@ The changes for each individual beta release can be seen [here](https://github.c

**⚠️ THIS UPDATE REMOVES V1 SUPPORT ⚠️**

### Changes

- ⚠️ **Breaking** Removed support for the deprecated v1 api ⚠️
- Added more endpoints to `flatdevice`:
- `flatdevice/set-cover` to open or close the cover
Expand Down
4 changes: 2 additions & 2 deletions ninaAPI/AdvancedAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public int CachedPort
{
cachedPort = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CachedPort)));
PortVisibility = CachedPort == Port ? Visibility.Hidden : Visibility.Visible;
PortVisibility = ((CachedPort != Port) && APIEnabled) ? Visibility.Visible : Visibility.Hidden;
SetHostNames();
}
}
Expand Down Expand Up @@ -208,12 +208,12 @@ public bool APIEnabled
Server.Start();
Notification.ShowSuccess("API successfully started");
ShowNotificationIfPortChanged();

}
else
{
Server.Stop();
Server = null;
CachedPort = -1;
Notification.ShowSuccess("API successfully stopped");
}
}
Expand Down
14 changes: 8 additions & 6 deletions ninaAPI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

// [MANDATORY] The assembly versioning
//Should be incremented for each new build of a plugin
[assembly: AssemblyVersion("2.1.6.1")] // last one is for beta
[assembly: AssemblyFileVersion("2.1.6.1")]
[assembly: AssemblyVersion("2.1.7.1")] // last one is for beta
[assembly: AssemblyFileVersion("2.1.7.1")]

// [MANDATORY] The name of your plugin
[assembly: AssemblyTitle("Advanced API")]
Expand Down Expand Up @@ -41,18 +41,20 @@
## Features:
- Listen to events like connections, meridian flips and much more
- TPPA integration (Requires TPPA to be installed and V2 of the api)
- TPPA integration (Requires TPPA to be installed)
- Livestack integration (Requires Livestack to be installed)
- Supports basic control over the equipment and application in general
- And much more!
---
If you have question/issues/feedback, you can create an issue [here](https://github.com/christian-photo/ninaAPI/issues), take a look at the
[documentation](https://bump.sh/christian-photo/doc/advanced-api/) and here for the [websockets](https://bump.sh/christian-photo/doc/advanced-api-websockets) or just ask on the N.I.N.A. discord in [#plugin-discussions](https://discord.com/channels/436650817295089664/854531935660146718)
[documentation](https://bump.sh/christian-photo/doc/advanced-api/) and here for the [websockets](https://bump.sh/christian-photo/doc/advanced-api-websockets) or just ask on the N.I.N.A. discord in [#plugin-discussions](https://discord.com/channels/436650817295089664/854531935660146718)
**Thanks to szymon and notzeeg (discord) for their help!**")]


// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// [Unused]
Expand Down
1 change: 1 addition & 0 deletions ninaAPI/Utility/Communicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public void Dispose()

public Task OnMessageReceived(IMessage message)
{
// The purpose of this class is to provide the port, the api is running on. It automatically returns the port or -1 if the api is not running
return AdvancedAPI.Controls.MessageBroker.Publish(new PortRequestMessage(AdvancedAPI.GetCachedPort(), message.CorrelationId.Value));
}
}
Expand Down
7 changes: 6 additions & 1 deletion ninaAPI/Utility/CoreUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ namespace ninaAPI.Utility
{
public static class CoreUtility
{
static CoreUtility()
{
options.Converters.Add(new JsonStringEnumConverter());
}

public static IList<IDeepSkyObjectContainer> GetAllTargets(this ISequenceMediator sequence)
{
IList<IDeepSkyObjectContainer> targets = sequence.GetAllTargetsInAdvancedSequence();
Expand Down Expand Up @@ -146,7 +151,7 @@ public static void WriteToResponse(this IHttpContext context, object json)
}
*/

string text = System.Text.Json.JsonSerializer.Serialize(json, options);
string text = JsonSerializer.Serialize(json, options);

using (var writer = new StreamWriter(context.Response.OutputStream))
{
Expand Down
2 changes: 1 addition & 1 deletion ninaAPI/Utility/NINALogMessageProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private Dictionary<Regex, EventMatcher> initMatchers()
re = new Regex("^Stopping all dome movement$", options);
_matchers.Add(re, new EventMatcher(NINALogEvent.NINA_DOME_STOPPED, false, null));

// Center / Plate solve
// Center / Plate solve in Sequence
re = new Regex("^Starting Category: Telescope, Item: Center, (?<extra>.+)$", options);
_matchers.Add(re, new EventMatcher(NINALogEvent.NINA_CENTER, true, null));

Expand Down
2 changes: 1 addition & 1 deletion ninaAPI/WebService/API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ This Source Code Form is subject to the terms of the Mozilla Public
using ninaAPI.Properties;
using ninaAPI.Utility;
using ninaAPI.WebService.V2;
using ninaAPI.WebService.V2.Equipment;
using System;
using System.Collections.Generic;
using System.Threading;
Expand Down Expand Up @@ -66,6 +65,7 @@ public static void StartWatchers()
Watchers.Add(new WeatherWatcher());
Watchers.Add(new ImageWatcher());
Watchers.Add(new NinaLogWatcher());
Watchers.Add(new LiveStackWatcher());

foreach (INinaWatcher watcher in Watchers)
{
Expand Down
23 changes: 23 additions & 0 deletions ninaAPI/WebService/V2/Application/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ This Source Code Form is subject to the terms of the Mozilla Public
using NINA.Image.ImageAnalysis;
using System.IO;
using System.Threading.Tasks;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;

namespace ninaAPI.WebService.V2
{
Expand Down Expand Up @@ -152,5 +155,25 @@ public async Task ApplicationScreenshot([QueryField] bool resize, [QueryField] i

HttpContext.WriteToResponse(response);
}

[Route(HttpVerbs.Get, "/application/plugins")]
public void ApplicationPlugins()
{
HttpResponse response = new HttpResponse();

try
{
string path = Directory.GetParent(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)).FullName;
List<string> plugins = [.. Directory.GetDirectories(path).Select(Path.GetFileName)];
response.Response = plugins;
}
catch (Exception ex)
{
Logger.Error(ex);
response = CoreUtility.CreateErrorTable(CommonErrors.UNKNOWN_ERROR);
}

HttpContext.WriteToResponse(response);
}
}
}
16 changes: 13 additions & 3 deletions ninaAPI/WebService/V2/Application/Framing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,26 @@ public void FramingSetCoordinates([QueryField] double RAangle, [QueryField] doub
}

[Route(HttpVerbs.Get, "/framing/slew")]
public void FramingSlew([QueryField] string slew_option)
public async Task FramingSlew([QueryField] string slew_option, [QueryField] bool waitForResult)
{
HttpResponse response = new HttpResponse();

try
{
IFramingAssistantVM framing = AdvancedAPI.Controls.FramingAssistant;

framing.SlewToCoordinatesCommand.Execute(slew_option ?? string.Empty); // SlewOption is either Center Rotate or empty
response.Response = $"Slew started";
if (framing.ImageParameter is null)
{
await framing.LoadImageCommand.ExecuteAsync(null);
await Task.Delay(1000);
}

if (waitForResult)
await framing.SlewToCoordinatesCommand.ExecuteAsync(slew_option ?? string.Empty); // SlewOption is either Center Rotate or empty
else
framing.SlewToCoordinatesCommand.Execute(slew_option ?? string.Empty); // SlewOption is either Center Rotate or empty

response.Response = waitForResult ? "Slew finished" : "Slew started";
}
catch (Exception ex)
{
Expand Down
3 changes: 1 addition & 2 deletions ninaAPI/WebService/V2/Application/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ This Source Code Form is subject to the terms of the Mozilla Public
using NINA.WPF.Base.Interfaces.Mediator;
using System.Windows.Media.Imaging;
using System.IO;
using ninaAPI.WebService.V2.Equipment;

namespace ninaAPI.WebService.V2
{
Expand Down Expand Up @@ -141,7 +140,7 @@ public async Task GetImage(int index,
{
ImageHistoryPoint p = hist.ImageHistory[index]; // Get the historyPoint at the specified index for the image

IImageData imageData = await AdvancedAPI.Controls.ImageDataFactory.CreateFromFile(p.LocalPath, 16, true, RawConverterEnum.FREEIMAGE);
IImageData imageData = await Retry.Do(async () => await AdvancedAPI.Controls.ImageDataFactory.CreateFromFile(p.LocalPath, 16, true, RawConverterEnum.FREEIMAGE), TimeSpan.FromMilliseconds(200), 10);
IRenderedImage renderedImage = imageData.RenderImage();

renderedImage = await renderedImage.Stretch(factor, blackClipping, unlinked);
Expand Down
Loading

0 comments on commit 020aac4

Please sign in to comment.