Пример #1
0
        private async Task <double> CalculatePoleError(Coordinates startPosition, IProgress <ApplicationStatus> progress, CancellationToken canceltoken)
        {
            var plateSolver = PlateSolverFactory.GetPlateSolver(profileService.ActiveProfile.PlateSolveSettings);
            var blindSolver = PlateSolverFactory.GetBlindSolver(profileService.ActiveProfile.PlateSolveSettings);
            var solver      = new CaptureSolver(plateSolver, blindSolver, imagingMediator);
            var parameter   = new CaptureSolverParameter()
            {
                Attempts         = 1,
                Binning          = SnapBin?.X ?? CameraInfo.BinX,
                DownSampleFactor = profileService.ActiveProfile.PlateSolveSettings.DownSampleFactor,
                FocalLength      = profileService.ActiveProfile.TelescopeSettings.FocalLength,
                MaxObjects       = profileService.ActiveProfile.PlateSolveSettings.MaxObjects,
                PixelSize        = profileService.ActiveProfile.CameraSettings.PixelSize,
                ReattemptDelay   = TimeSpan.FromMinutes(profileService.ActiveProfile.PlateSolveSettings.ReattemptDelay),
                Regions          = profileService.ActiveProfile.PlateSolveSettings.Regions,
                SearchRadius     = profileService.ActiveProfile.PlateSolveSettings.SearchRadius
            };

            double poleError = double.NaN;

            try {
                double driftAmount = 0.5d;

                progress.Report(new ApplicationStatus()
                {
                    Status = "Solving image..."
                });

                var seq = new CaptureSequence(SnapExposureDuration, CaptureSequence.ImageTypes.SNAPSHOT, SnapFilter, SnapBin, 1);
                seq.Gain = SnapGain;

                parameter.Coordinates = startPosition;
                PlateSolveResult      = await solver.Solve(seq, parameter, default, progress, canceltoken);
Пример #2
0
        private async Task <bool> Recenter(CancellationToken token, IProgress <ApplicationStatus> progress)
        {
            if (profileService.ActiveProfile.MeridianFlipSettings.Recenter)
            {
                Logger.Trace("Meridian Flip - Recenter after meridian flip");

                progress.Report(new ApplicationStatus()
                {
                    Status = Locale.Loc.Instance["LblInitiatePlatesolve"]
                });

                var plateSolver = PlateSolverFactory.GetPlateSolver(profileService.ActiveProfile.PlateSolveSettings);
                var blindSolver = PlateSolverFactory.GetBlindSolver(profileService.ActiveProfile.PlateSolveSettings);
                var seq         = new CaptureSequence(
                    profileService.ActiveProfile.PlateSolveSettings.ExposureTime,
                    CaptureSequence.ImageTypes.SNAPSHOT,
                    profileService.ActiveProfile.PlateSolveSettings.Filter,
                    new Model.MyCamera.BinningMode(profileService.ActiveProfile.PlateSolveSettings.Binning, profileService.ActiveProfile.PlateSolveSettings.Binning),
                    1
                    );
                seq.Gain = profileService.ActiveProfile.PlateSolveSettings.Gain;

                var solver    = new CenteringSolver(plateSolver, blindSolver, imagingMediator, telescopeMediator);
                var parameter = new CenterSolveParameter()
                {
                    Attempts         = profileService.ActiveProfile.PlateSolveSettings.NumberOfAttempts,
                    Binning          = profileService.ActiveProfile.PlateSolveSettings.Binning,
                    Coordinates      = _targetCoordinates,
                    DownSampleFactor = profileService.ActiveProfile.PlateSolveSettings.DownSampleFactor,
                    FocalLength      = profileService.ActiveProfile.TelescopeSettings.FocalLength,
                    MaxObjects       = profileService.ActiveProfile.PlateSolveSettings.MaxObjects,
                    PixelSize        = profileService.ActiveProfile.CameraSettings.PixelSize,
                    ReattemptDelay   = TimeSpan.FromMinutes(profileService.ActiveProfile.PlateSolveSettings.ReattemptDelay),
                    Regions          = profileService.ActiveProfile.PlateSolveSettings.Regions,
                    SearchRadius     = profileService.ActiveProfile.PlateSolveSettings.SearchRadius,
                    Threshold        = profileService.ActiveProfile.PlateSolveSettings.Threshold,
                    NoSync           = profileService.ActiveProfile.TelescopeSettings.NoSync
                };
                _ = await solver.Center(seq, parameter, default, progress, token);
Пример #3
0
        private async Task <bool> CaptureSolveSyncAndReslew(IProgress <ApplicationStatus> progress)
        {
            _solveCancelToken?.Dispose();
            _solveCancelToken = new CancellationTokenSource();
            try {
                if ((this.Sync || this.SlewToTarget) && !telescopeInfo.Connected)
                {
                    throw new Exception(Locale.Loc.Instance["LblTelescopeNotConnected"]);
                }

                var seq = new CaptureSequence(SnapExposureDuration, CaptureSequence.ImageTypes.SNAPSHOT, SnapFilter, SnapBin, 1);
                seq.Gain = SnapGain;

                var plateSolver   = PlateSolverFactory.GetPlateSolver(profileService.ActiveProfile.PlateSolveSettings);
                var blindSolver   = PlateSolverFactory.GetBlindSolver(profileService.ActiveProfile.PlateSolveSettings);
                var solveProgress = new Progress <PlateSolveProgress>(x => {
                    if (x.PlateSolveResult != null)
                    {
                        PlateSolveResult = x.PlateSolveResult;
                    }
                });

                if (this.SlewToTarget)
                {
                    var solver    = new CenteringSolver(plateSolver, blindSolver, imagingMediator, telescopeMediator);
                    var parameter = new CenterSolveParameter()
                    {
                        Attempts         = 1,
                        Binning          = SnapBin?.X ?? CameraInfo.BinX,
                        Coordinates      = telescopeMediator.GetCurrentPosition(),
                        DownSampleFactor = profileService.ActiveProfile.PlateSolveSettings.DownSampleFactor,
                        FocalLength      = profileService.ActiveProfile.TelescopeSettings.FocalLength,
                        MaxObjects       = profileService.ActiveProfile.PlateSolveSettings.MaxObjects,
                        PixelSize        = profileService.ActiveProfile.CameraSettings.PixelSize,
                        ReattemptDelay   = TimeSpan.FromMinutes(profileService.ActiveProfile.PlateSolveSettings.ReattemptDelay),
                        Regions          = profileService.ActiveProfile.PlateSolveSettings.Regions,
                        SearchRadius     = profileService.ActiveProfile.PlateSolveSettings.SearchRadius,
                        Threshold        = RepeatThreshold,
                        NoSync           = profileService.ActiveProfile.TelescopeSettings.NoSync
                    };
                    _ = await solver.Center(seq, parameter, solveProgress, progress, _solveCancelToken.Token);
                }
                else
                {
                    var solver    = new CaptureSolver(plateSolver, blindSolver, imagingMediator);
                    var parameter = new CaptureSolverParameter()
                    {
                        Attempts         = 1,
                        Binning          = SnapBin?.X ?? CameraInfo.BinX,
                        DownSampleFactor = profileService.ActiveProfile.PlateSolveSettings.DownSampleFactor,
                        FocalLength      = profileService.ActiveProfile.TelescopeSettings.FocalLength,
                        MaxObjects       = profileService.ActiveProfile.PlateSolveSettings.MaxObjects,
                        PixelSize        = profileService.ActiveProfile.CameraSettings.PixelSize,
                        ReattemptDelay   = TimeSpan.FromMinutes(profileService.ActiveProfile.PlateSolveSettings.ReattemptDelay),
                        Regions          = profileService.ActiveProfile.PlateSolveSettings.Regions,
                        SearchRadius     = profileService.ActiveProfile.PlateSolveSettings.SearchRadius,
                        Coordinates      = telescopeMediator.GetCurrentPosition()
                    };
                    var result = await solver.Solve(seq, parameter, solveProgress, progress, _solveCancelToken.Token);

                    if (telescopeInfo.Connected)
                    {
                        var position = parameter.Coordinates.Transform(result.Coordinates.Epoch);
                        result.Separation = result.DetermineSeparation(position);
                    }

                    if (!profileService.ActiveProfile.TelescopeSettings.NoSync && Sync)
                    {
                        await telescopeMediator.Sync(result.Coordinates);
                    }
                }
            } catch (OperationCanceledException) {
            } catch (Exception ex) {
                Logger.Error(ex);
                Notification.ShowError(ex.Message);
            }

            return(true);
        }