private void LoadAlignmentPoints() { var dir = Path.GetDirectoryName(_configFile); if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir)) { Directory.CreateDirectory(dir); } if (File.Exists(_configFile)) { AlignmentPoints.Clear(); using (var file = File.OpenText(_configFile)) { var serializer = new JsonSerializer(); var loaded = (AlignmentPointCollection)serializer.Deserialize(file, typeof(AlignmentPointCollection)); if (loaded != null) { foreach (var alignmentPoint in loaded) { AlignmentPoints.Add(alignmentPoint); } } } } ReportAlignmentPoints(); }
private void AddAlignmentPoint(double[] mountAltAz, double[] observedAltAz, AxisPosition mountAxes, AxisPosition observedAxes, PierSide pierSide, DateTime syncTime) { lock (_accessLock) { if (AlignmentPoints.Count > 2 && ProximityLimit > 0.0) { // Remove any existing alignment points that are too close to the new one. var nearPoints = AlignmentPoints .Where(p => p.MountAxes.IncludedAngleTo(mountAxes) <= ProximityLimit).ToList(); foreach (AlignmentPoint deletePt in nearPoints) { AlignmentPoints.Remove(deletePt); } } CarteseanCoordinate mountXy = AltAzToCartesean(mountAltAz); CarteseanCoordinate observedXy = AltAzToCartesean(observedAltAz); AlignmentPoints.Add(new AlignmentPoint(observedAltAz, mountAxes, observedAxes, mountXy, observedXy, pierSide, syncTime)); _currentChecksum = int.MinValue; // Reset checksum so that offsets are recalculated OneStarAdjustment[0] = observedAxes[0] - mountAxes[0]; OneStarAdjustment[1] = observedAxes[1] - mountAxes[1]; SaveAlignmentPoints(); } }