コード例 #1
0
ファイル: CenterSolverTest.cs プロジェクト: daleghent/NINA
        public async Task Successful_Centering_NoSeparation_Test()
        {
            var seq         = new CaptureSequence();
            var coordinates = new Coordinates(Angle.ByDegree(5), Angle.ByDegree(3), Epoch.JNOW);
            var parameter   = new CenterSolveParameter()
            {
                Coordinates = coordinates.Transform(Epoch.JNOW),
                FocalLength = 700,
                Threshold   = 1
            };
            var testResult = new PlateSolveResult()
            {
                Success     = true,
                Coordinates = coordinates.Transform(Epoch.JNOW)
            };

            captureSolverMock
            .Setup(x => x.Solve(seq, It.IsAny <CaptureSolverParameter>(), It.IsAny <IProgress <PlateSolveProgress> >(), It.IsAny <IProgress <ApplicationStatus> >(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(testResult);
            telescopeMediatorMock
            .Setup(x => x.GetCurrentPosition())
            .Returns(coordinates);

            var sut = new CenteringSolver(plateSolverMock.Object, blindSolverMock.Object, null, telescopeMediatorMock.Object);

            sut.CaptureSolver = captureSolverMock.Object;

            var result = await sut.Center(seq, parameter, default, default, default);
コード例 #2
0
ファイル: MeridianFlipVM.cs プロジェクト: daleghent/NINA
        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);
        }