Skip to content
Merged
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
9 changes: 9 additions & 0 deletions NINA.Core/Locale/Locale.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4459,6 +4459,15 @@ In case a longer duration is needed, a duration can be specified and the applica
<data name="Lbl_SequenceTrigger_AutofocusAfterHFRIncreaseTrigger_Name" xml:space="preserve">
<value>AF After HFR Increase</value>
</data>
<data name="Lbl_SequenceTrigger_AutofocusAfterHFRIncreaseTrigger_TrendPerFilter" xml:space="preserve">
<value>HFR trend per filter</value>
</data>
<data name="Lbl_SequenceTrigger_AutofocusAfterHFRIncreaseTrigger_TrendPerFilterTooltip" xml:space="preserve">
<value>When disabled, the HFR trend is evaluated across all filters combined.
This can help to trigger autofocus runs earlier, particular when imaging with frequent filter changes
and a temperature sensitive optics on a quickly changing ambient temperature.
Note: This mode requires that HFR differences between filters in your setup are small.</value>
</data>
<data name="Lbl_SequenceTrigger_AutofocusAfterTemperatureChangeTrigger_Description" xml:space="preserve">
<value>A trigger to initiate an autofocus run after the temperature has changed by the given amount in degrees since the last autofocus run or start of sequence</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ public int SampleSize {
}
}

private bool trendPerFilter = true; // default true to keep the original behaviour creating an HFR trend per filter

[JsonProperty]
public bool TrendPerFilter {
get => trendPerFilter;
set {
trendPerFilter = value;
RaisePropertyChanged();
}
}

private double originalHFR;

public double OriginalHFR {
Expand Down Expand Up @@ -182,7 +193,7 @@ public override bool ShouldTrigger(ISequenceItem previousItem, ISequenceItem nex
imageHistory = imageHistory.Where(point => point.Id > lastAF.Id).ToList();
}

if (fwInfo != null && fwInfo.Connected && fwInfo.SelectedFilter != null) {
if (TrendPerFilter == true && fwInfo != null && fwInfo.Connected && fwInfo.SelectedFilter != null) {
//Further filter the history to only considere items by the current filter
Filter = fwInfo.SelectedFilter.Name;

Expand Down Expand Up @@ -245,7 +256,7 @@ public override bool ShouldTrigger(ISequenceItem previousItem, ISequenceItem nex
}

public override string ToString() {
return $"Trigger: {nameof(AutofocusAfterHFRIncreaseTrigger)}, Amount: {Amount}";
return $"Trigger: {nameof(AutofocusAfterHFRIncreaseTrigger)}, Amount: {Amount}, TrendPerFilter: {TrendPerFilter}";
}

public bool Validate() {
Expand All @@ -264,4 +275,4 @@ public bool Validate() {
return i.Count == 0;
}
}
}
}
9 changes: 9 additions & 0 deletions NINA.Sequencer/Trigger/Datatemplates.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@
Text="{Binding Amount}"
TextAlignment="Right"
Unit="%" />
<TextBlock
Margin="10,0,0,0"
VerticalAlignment="Center"
Text="{ns:Loc Lbl_SequenceTrigger_AutofocusAfterHFRIncreaseTrigger_TrendPerFilter}" />
<CheckBox
Margin="5,0,0,0"
VerticalAlignment="Center"
IsChecked="{Binding TrendPerFilter}"
ToolTip="{ns:Loc Lbl_SequenceTrigger_AutofocusAfterHFRIncreaseTrigger_TrendPerFilterTooltip}" />
</StackPanel>
</view:SequenceBlockView.SequenceItemContent>
<view:SequenceBlockView.SequenceItemProgressContent>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ο»Ώ#region "copyright"
#region "copyright"

/*
Copyright Β© 2016 - 2024 Stefan Berg <[email protected]> and the N.I.N.A. contributors
Expand Down Expand Up @@ -224,7 +224,11 @@ public async Task Execute_Successfully_WithAllParametersPassedCorrectly() {
public void ToString_FilledProperly() {
var sut = new AutofocusAfterHFRIncreaseTrigger(profileServiceMock.Object, imagehistory, cameraMediatorMock.Object, filterWheelMediatorMock.Object, focuserMediatorMock.Object, autoFocusVMFactoryMock.Object, safetyMonitorMediatorMock.Object);
var tostring = sut.ToString();
tostring.Should().Be("Trigger: AutofocusAfterHFRIncreaseTrigger, Amount: 5");
tostring.Should().Be("Trigger: AutofocusAfterHFRIncreaseTrigger, Amount: 5, TrendPerFilter: True");

sut.TrendPerFilter = false;
tostring = sut.ToString();
tostring.Should().Be("Trigger: AutofocusAfterHFRIncreaseTrigger, Amount: 5, TrendPerFilter: False");
}

[Test]
Expand Down Expand Up @@ -263,6 +267,36 @@ public void ShouldTrigger_HistoryExists_NoPreviousAFs_OnlyTestFilterConsidered_T
trigger.Should().Be(shouldTrigger);
}

[Test] // index 2+3 are for a different filter
[TestCase(new double[] { 3, 3, 50, 100, 3, 3 }, 1, true, false)] // should not trigger as trend per filter true
[TestCase(new double[] { 3, 3, 50, 100, 3, 3 }, 1, false, true)] // should trigger as trend across all filters
public void ShouldTrigger_HistoryExists_NoPreviousAFs_TestTrendPerFilterConsidered(double[] hfrs, double changeAmount, bool trendPerFilter, bool shouldTrigger) {
for (int i = 0; i < hfrs.Length; i++) {
if (i > 1 && i < 4) {
var p = new ImageHistoryPoint(i, null, "LIGHT");
var id = imagehistory.GetNextImageId();
imagehistory.Add(id, null, "LIGHT");
imagehistory.AppendImageProperties(new ImageSavedEventArgs() { Filter = "OtherFilter", StarDetectionAnalysis = new StarDetectionAnalysis() { DetectedStars = 1, HFR = hfrs[i] }, MetaData = new ImageMetaData() { Image = new ImageParameter() { Id = id } } });
} else {
var p = new ImageHistoryPoint(i, null, "LIGHT");
var id = imagehistory.GetNextImageId();
imagehistory.Add(id, null, "LIGHT");
imagehistory.AppendImageProperties(new ImageSavedEventArgs() { Filter = "TestFilter", StarDetectionAnalysis = new StarDetectionAnalysis() { DetectedStars = 1, HFR = hfrs[i] }, MetaData = new ImageMetaData() { Image = new ImageParameter() { Id = id } } });
}
}

filterWheelMediatorMock.Setup(x => x.GetInfo()).Returns(new FilterWheelInfo() { Connected = true, SelectedFilter = new FilterInfo() { Name = "TestFilter" } });

var sut = new AutofocusAfterHFRIncreaseTrigger(profileServiceMock.Object, imagehistory, cameraMediatorMock.Object, filterWheelMediatorMock.Object, focuserMediatorMock.Object, autoFocusVMFactoryMock.Object, safetyMonitorMediatorMock.Object);
sut.Amount = changeAmount;
sut.TrendPerFilter = trendPerFilter;

var itemMock = new Mock<IExposureItem>();
itemMock.SetupGet(x => x.ImageType).Returns("LIGHT");
var trigger = sut.ShouldTrigger(null, itemMock.Object);

trigger.Should().Be(shouldTrigger);
}


[Test]
Expand Down Expand Up @@ -328,4 +362,4 @@ public void HFRTrend_And_Percentage_AreComputed_FromWindowAndBaseline(
sut.HFRTrendPercentage.Should().BeApproximately(expectedPct, 0.05);
}
}
}
}
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ More details at <a href="https://nighttime-imaging.eu/donate/" target="_blank">n
- ToupTek based filter wheels and focusers will no longer be listed in the camera connector.

## Improvements
- **Autofocus after HFR Increase Trigger**
- new Trend per Filter checkbox to consider HFR Trend per filter (default) or across all filters to earlier trigger autofocus runs when imaging with continues filter loops
- When a safety monitor is connected and is reporting unsafe conditions, the imaging related core triggers will no longer fire as the conditions aren't safe anyways to execute them.
- In case the meridian should trigger in this scenario, it will stop mount tracking instead to ensure there will be no pier collision. Safety related logic in a sequence needs to handle resuming tracking once it's safe again.

Expand Down
Loading