Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion NINA.Core/Locale/Locale.resx
Original file line number Diff line number Diff line change
Expand Up @@ -7351,4 +7351,7 @@ The sky flat exposure time will be determined again and the exposure will be rep
<data name="LblAlpacaDeviceNumber" xml:space="preserve">
<value>Device Number</value>
</data>
</root>
<data name="LblFilterUndefinedError" xml:space="preserve">
<value>Please define filters before connecting to the filter wheel.</value>
</data>
</root>
51 changes: 39 additions & 12 deletions NINA.Equipment/Equipment/MyFilterWheel/ToupTekAlikeFilterWheel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This Source Code Form is subject to the terms of the Mozilla Public
#endregion "copyright"

using CommunityToolkit.Mvvm.Input;
using NINA.Core.Locale;
using NINA.Core.Model.Equipment;
using NINA.Core.Utility;
using NINA.Core.Utility.Notification;
Expand Down Expand Up @@ -74,16 +75,25 @@ public bool Unidirectional {
}
}

private int slotNum;
public int SlotNum {
get => slotNum;
set {
if (slotNum != value) {
slotNum = value;
RaisePropertyChanged();
}
}
}

public IList<string> SupportedActions => new List<string>();

private object lockObj = new object();
public AsyncObservableCollection<FilterInfo> Filters {
get {
lock (lockObj) {
var filtersList = profileService.ActiveProfile.FilterWheelSettings.FilterWheelFilters;
sdk.get_Option(ToupTekAlikeOption.OPTION_FILTERWHEEL_SLOT, out var positions);

var filters = new FilterManager().SyncFiltersWithPositions(filtersList, positions);
var filters = new FilterManager().SyncFiltersWithPositions(filtersList, SlotNum);
profileService.ActiveProfile.FilterWheelSettings.FilterWheelFilters = filters;
return filters;
}
Expand Down Expand Up @@ -152,26 +162,35 @@ public Task<bool> Connect(CancellationToken ct) {
try {
SupportedActions.Clear();

// Fetch profile settings
var profile = profileService.ActiveProfile.FilterWheelSettings;
Unidirectional = profile.Unidirectional;

// Filters must be defined in order to connect to the filter wheel
if (profile.FilterWheelFilters.Count < 1) {
Notification.ShowError(Loc.Instance["LblFilterUndefinedError"]);
Logger.Error("Please define filters before connecting to the filter wheel.");
return false;
}

// Open connection
sdk = sdk.Open(this.internalId);

// Read number of positions
sdk.get_Option(ToupTekAlikeOption.OPTION_FILTERWHEEL_SLOT, out var slotNum);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should still get the slot number, but only do the workaround for those that don't report the number.

What happens on the older wheels for this getter, does it return zero? if yes then just do the workaround when there are no slots reported.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, the new ones have internal storage. Not sure if they are already shipped. I have the AFW-L for testing, it always reports 7 after turning on.

// Older filter wheels do not internally store the number of slots
// so we fetch it from the filters list
slotNum = profileService.ActiveProfile.FilterWheelSettings.FilterWheelFilters.Count;

// Initialize filter wheel with number of positions
sdk.put_Option(ToupTekAlikeOption.OPTION_FILTERWHEEL_SLOT, slotNum);

// Initially reset filter wheel
sdk.put_Option(ToupTekAlikeOption.OPTION_FILTERWHEEL_POSITION, -1);

// Wait for calibration to finish
// Wait for filter wheel to reach ready state
// Due to a firmware bug in older filter wheels (reporting ready while they are not),
// it may happen that control returns before the filter wheel is actually ready
await WaitForReadyState(ct);

// Connected flag
Connected = true;

success = true;
var profile = profileService.ActiveProfile.FilterWheelSettings;
Unidirectional = profile.Unidirectional;

RaiseAllPropertiesChanged();
} catch (Exception ex) {
Expand Down Expand Up @@ -201,6 +220,14 @@ private async Task<bool> CalibrateAfw(object arg, CancellationToken ct) {
var ct = cts.Token;

try {
// On older filter wheels, IsMoving status can be wrong when calibration is trigged from slot 0
// In order to avoid this issue, we first move to slot 1 if we are currently at slot 0
if (currentPostion == 0) {
Position = 1;
await WaitForReadyState(ct);
}

// Trigger calibration
sdk.put_Option(ToupTekAlikeOption.OPTION_FILTERWHEEL_POSITION, -1);

// Wait for calibration to finish
Expand Down
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ More details at <a href="https://nighttime-imaging.eu/donate/" target="_blank">n
## Bugfixes
- Autofocus after HFR Increase HFRTrendPercentage is now calculated correctly and will no longer underestimate the change on large HFR drift
- ToupTek based filter wheels and focusers will no longer be listed in the camera connector.
- ToupTek based filter wheels number of slots will now be based on the filter list to support different filter configurations and calibration should no longer return control before the filter wheel is in ready state.

## Improvements
- **Autofocus after HFR Increase Trigger**
Expand Down