private void RebuildGuideHistoryList() { lock (lockObj) { if (overallGuideSteps.Count > 0) { var collection = new LinkedList <HistoryStep>(); var startIndex = overallGuideSteps.Count - historySize; if (startIndex < 0) { startIndex = 0; } RMS.Clear(); for (int i = startIndex; i < overallGuideSteps.Count; i++) { var p = overallGuideSteps.ElementAt(i); RMS.AddDataPoint(p.RADistanceRaw, p.DECDistanceRaw); if (Scale == GuiderScaleEnum.ARCSECONDS) { p = p.AdjustPixelScale(PixelScale); } else { p = p.AdjustPixelScale(1); } collection.AddLast(p); } GuideSteps = new AsyncObservableLimitedSizedStack <HistoryStep>(historySize, collection); CalculateMaximumDurationY(); } } }
public GuideStepsHistory(int historySize, GuiderScaleEnum scale, double maxY) { RMS = new RMS(); PixelScale = 1; HistorySize = historySize; MaxY = maxY; Scale = scale; GuideSteps = new AsyncObservableLimitedSizedStack <HistoryStep>(historySize); MaxDurationY = 1; }
public void Clear() { lock (lockObj) { overallGuideSteps.Clear(); GuideSteps.Clear(); RMS.Clear(); MaxDurationY = 1; HistoryStep.ResetIdProvider(); } }
public void AddGuideStep(IGuideStep step) { lock (lockObj) { var historyStep = HistoryStep.FromGuideStep(step, Scale == GuiderScaleEnum.PIXELS ? 1 : PixelScale); overallGuideSteps.AddLast(historyStep); if (GuideSteps.Count == HistorySize) { var elementIdx = overallGuideSteps.Count - HistorySize; if (elementIdx >= 0) { var stepToRemove = overallGuideSteps.ElementAt(elementIdx); RMS.RemoveDataPoint(stepToRemove.RADistanceRaw, stepToRemove.DECDistanceRaw); } } RMS.AddDataPoint(step.RADistanceRaw, step.DECDistanceRaw); GuideSteps.Add(historyStep); CalculateMaximumDurationY(); } }