Пример #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
        public async Task Successful_CaptureAndSolving_Test()
        {
            var imageDataMock     = new Mock <IImageData>();
            var renderedImageMock = new Mock <IRenderedImage>();

            renderedImageMock.SetupGet(x => x.RawImageData).Returns(imageDataMock.Object);
            var testResult = new PlateSolveResult()
            {
                Success = true
            };
            var seq       = new CaptureSequence();
            var parameter = new CaptureSolverParameter()
            {
                FocalLength = 700
            };

            imagingMediatorMock.Setup(x => x.CaptureAndPrepareImage(seq, It.IsAny <PrepareImageParameters>(), It.IsAny <CancellationToken>(), It.IsAny <IProgress <ApplicationStatus> >())).ReturnsAsync(renderedImageMock.Object);
            imageSolverMock.Setup(x => x.Solve(imageDataMock.Object, It.IsAny <PlateSolveParameter>(), It.IsAny <IProgress <ApplicationStatus> >(), It.IsAny <CancellationToken>())).ReturnsAsync(testResult);

            var sut = new CaptureSolver(plateSolverMock.Object, blindSolverMock.Object, imagingMediatorMock.Object);

            sut.ImageSolver = imageSolverMock.Object;

            var result = await sut.Solve(seq, parameter, default, default, default);
Пример #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);
        }