Skip to content

Commit

Permalink
remove redudant time fields; add conditions and triggers; fix time in…
Browse files Browse the repository at this point in the history
…structions / conditions
  • Loading branch information
christian-photo committed Dec 31, 2024
1 parent a194247 commit b01d613
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 61 deletions.
4 changes: 2 additions & 2 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.0.2")]
[assembly: AssemblyFileVersion("2.1.0.2")]
[assembly: AssemblyVersion("2.1.0.3")]
[assembly: AssemblyFileVersion("2.1.0.3")]

// [MANDATORY] The name of your plugin
[assembly: AssemblyTitle("Advanced API")]
Expand Down
153 changes: 94 additions & 59 deletions ninaAPI/WebService/V2/Application/Sequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ This Source Code Form is subject to the terms of the Mozilla Public
using NINA.Sequencer.SequenceItem.Switch;
using NINA.Sequencer.SequenceItem.Telescope;
using System.IO;
using System.Security.Policy;
using NINA.Sequencer;
using System.Linq;

namespace ninaAPI.WebService.V2
{
Expand Down Expand Up @@ -65,7 +68,9 @@ public void SequenceJson()
}
else
{
response.Response = getSequenceRecursivley(targets[0].Parent.Parent);
List<Hashtable> json = getSequenceRecursivley(targets[0].Parent.Parent);
json.Add(new Hashtable() { { "GlobalTriggers", getTriggers(targets[0].Parent.Parent as SequenceContainer) } }); // Global triggers
response.Response = json;
}
}
}
Expand All @@ -78,95 +83,124 @@ public void SequenceJson()
HttpContext.WriteToResponse(response);
}

private static List<Hashtable> getSequenceRecursivley(ISequenceContainer sequence)
private static List<Hashtable> getConditions(SequenceContainer sequence)
{
List<Hashtable> result = new List<Hashtable>();
foreach (var item in sequence.Items)
List<Hashtable> conditions = new List<Hashtable>();
foreach (var condition in sequence.Conditions)
{
Hashtable it = new Hashtable
Hashtable ctable = new Hashtable
{
{ "Name", item.Name },
{ "Status", item.Status.ToString() },
// { "Description", item.Description }
{ "Name", condition.Name + "_Condition" },
{ "Status", condition.Status.ToString() }
};

if (item is ISequenceTrigger t)
if (condition is TimeCondition c1)
{
it["Name"] = item.Name + "_Trigger";
ctable.Add("RemainingTime", c1.RemainingTime);
ctable.Add("TargetTime", c1.DateTime.Now + c1.RemainingTime);
}
else if (item is ISequenceCondition c)
else if (condition is LoopForAltitudeBase c2)
{
it["Name"] = item.Name + "_Condition";
ctable.Add("Altitude", c2.Data.Offset);
ctable.Add("CurrentAltitude", c2.Data.CurrentAltitude);
ctable.Add("ExpectedTime", c2.Data.ExpectedTime);
}
else if (item is ISequenceContainer container && item is not SmartExposure && item is not TakeManyExposures)
else if (condition is LoopCondition c3)
{
it["Name"] = item.Name + "_Container";
it.Add("Items", getSequenceRecursivley(container));
ctable.Add("Iterations", c3.Iterations);
ctable.Add("CompletedIterations", c3.CompletedIterations);
}

if (item is AutofocusAfterExposures trigger)
else if (condition is MoonIlluminationCondition c5)
{
it.Add("Exposures", trigger.ProgressExposures);
it.Add("DeltaExposures", trigger.AfterExposures);
ctable.Add("TargetIllumination", c5.UserMoonIllumination);
ctable.Add("CurrentIllumination", c5.CurrentMoonIllumination);
}
else if (item is AutofocusAfterHFRIncreaseTrigger t2)
else if (condition is TimeSpanCondition c6)
{
it.Add("HFRTrendPercentage", t2.HFRTrendPercentage);
it.Add("OriginalHFR", t2.OriginalHFR);
it.Add("SampleSize", t2.SampleSize);
it.Add("DeltaHFR", t2.Amount);
ctable.Add("RemainingTime", c6.RemainingTime);
ctable.Add("TargetTime", c6.DateTime.Now + c6.RemainingTime);
}
else if (item is AutofocusAfterTemperatureChangeTrigger t3)
conditions.Add(ctable);

}
return conditions;
}

private static List<Hashtable> getTriggers(SequenceContainer sequence)
{
List<Hashtable> triggers = new List<Hashtable>();
foreach (var trigger in sequence.Triggers)
{
Hashtable triggertable = new Hashtable
{
it.Add("DeltaTemperature", t3.DeltaT);
it.Add("TargetTemperature", t3.Amount);
}
else if (item is AutofocusAfterTimeTrigger t4)
{ "Name", trigger.Name + "_Trigger" },
{ "Status", trigger.Status.ToString() }
};
if (trigger is AutofocusAfterExposures t1)
{
it.Add("DeltaTime", t4.Amount);
it.Add("ElapsedTime", t4.Elapsed);
triggertable.Add("Exposures", t1.ProgressExposures);
triggertable.Add("DeltaExposures", t1.AfterExposures);
}
else if (item is DitherAfterExposures t5)
else if (trigger is AutofocusAfterHFRIncreaseTrigger t2)
{
it.Add("Exposures", t5.ProgressExposures);
it.Add("TargetExposures", t5.AfterExposures);
triggertable.Add("HFRTrendPercentage", t2.HFRTrendPercentage);
triggertable.Add("OriginalHFR", t2.OriginalHFR);
triggertable.Add("SampleSize", t2.SampleSize);
triggertable.Add("DeltaHFR", t2.Amount);
}
else if (item is MeridianFlipTrigger t6)
else if (trigger is AutofocusAfterTemperatureChangeTrigger t3)
{
it.Add("TimeToFlip", t6.TimeToMeridianFlip);
triggertable.Add("DeltaTemperature", t3.DeltaT);
triggertable.Add("TargetTemperature", t3.Amount);
}
else if (item is CenterAfterDriftTrigger t7)
else if (trigger is AutofocusAfterTimeTrigger t4)
{
it.Add("Coordinates", t7.Coordinates);
it.Add("Drift", t7.LastDistanceArcMinutes);
it.Add("TargetDrift", t7.DistanceArcMinutes);
triggertable.Add("DeltaTime", t4.Amount);
triggertable.Add("ElapsedTime", t4.Elapsed);
}
else if (item is TimeCondition c1)
else if (trigger is DitherAfterExposures t5)
{
it.Add("RemainingTime", c1.RemainingTime);
it.Add("DateTime", c1.DateTime);
triggertable.Add("Exposures", t5.ProgressExposures);
triggertable.Add("TargetExposures", t5.AfterExposures);
}
else if (item is LoopForAltitudeBase c2)
else if (trigger is MeridianFlipTrigger t6)
{
it.Add("Altitude", c2.Data.Offset);
it.Add("CurrentAltitude", c2.Data.CurrentAltitude);
it.Add("ExpectedTime", c2.Data.ExpectedTime);
triggertable.Add("TimeToFlip", t6.TimeToMeridianFlip);
}
else if (item is LoopCondition c3)
else if (trigger is CenterAfterDriftTrigger t7)
{
it.Add("Iterations", c3.Iterations);
it.Add("CompletedIterations", c3.CompletedIterations);
triggertable.Add("Coordinates", t7.Coordinates);
triggertable.Add("Drift", t7.LastDistanceArcMinutes);
triggertable.Add("TargetDrift", t7.DistanceArcMinutes);
}
else if (item is MoonIlluminationCondition c5)
triggers.Add(triggertable);
}
return triggers;
}

private static List<Hashtable> getSequenceRecursivley(ISequenceContainer sequence)
{
List<Hashtable> result = new List<Hashtable>();

foreach (var item in sequence.Items)
{
Hashtable it = new Hashtable
{
it.Add("TargetIllumination", c5.UserMoonIllumination);
it.Add("CurrentIllumination", c5.CurrentMoonIllumination);
}
else if (item is TimeSpanCondition c6)
{ "Name", item.Name },
{ "Status", item.Status.ToString() },
// { "Description", item.Description }
};

if (item is ISequenceContainer container && item is not SmartExposure && item is not TakeManyExposures)
{
it.Add("RemainingTime", c6.RemainingTime);
it.Add("DateTime", c6.DateTime);
it["Name"] = item.Name + "_Container";
it.Add("Items", getSequenceRecursivley(container));
if (container is SequenceContainer sc)
{
it.Add("Conditions", getConditions(sc));
it.Add("Triggers", getTriggers(sc));
}
}

else if (item is CoolCamera i1)
{
it.Add("Temperature", i1.Temperature);
Expand Down Expand Up @@ -302,7 +336,8 @@ private static List<Hashtable> getSequenceRecursivley(ISequenceContainer sequenc
}
else if (item is WaitForTime i26)
{
it.Add("Time", i26.DateTime);
it.Add("TargetTime", i26.DateTime.Now + i26.GetEstimatedDuration());
it.Add("CalculatedWaitDuration", i26.GetEstimatedDuration());
}
else if (item is WaitForTimeSpan i27)
{
Expand Down
1 change: 1 addition & 0 deletions ninaAPI/buildAndCopy.bat
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cd ..
cd nina.plugin.manifests
git pull
git pull https://AstroChris23@bitbucket.org/Isbeorn/nina.plugin.manifests.git
mkdir manifests\n\ninaAPI\3.0.0\%version%
copy ..\ninaAPI\ninaAPI\manifest.json manifests\n\ninaAPI\3.0.0\%version%\manifest.json
echo "Testing the manifest"
node gather
Expand Down

0 comments on commit b01d613

Please sign in to comment.