コード例 #1
0
ファイル: ImageMetaData.cs プロジェクト: daleghent/NINA
 public void FromTelescopeInfo(TelescopeInfo info)
 {
     if (info.Connected)
     {
         if (string.IsNullOrWhiteSpace(Telescope.Name))
         {
             Telescope.Name = info.Name;
         }
         Observer.Elevation    = info.SiteElevation;
         Telescope.Coordinates = info.Coordinates;
     }
 }
コード例 #2
0
 public async Task Disconnect()
 {
     if (Telescope != null)
     {
         Logger.Info("Disconnected Telescope");
     }
     if (updateTimer != null)
     {
         await updateTimer.Stop();
     }
     Telescope?.Disconnect();
     Telescope     = null;
     TelescopeInfo = DeviceInfo.CreateDefaultInstance <TelescopeInfo>();
     BroadcastTelescopeInfo();
 }
コード例 #3
0
ファイル: ImageMetaDataTest.cs プロジェクト: daleghent/NINA
        public void FromTelescopeInfoNoCoordinateTransformTest()
        {
            var coordinates   = new Coordinates(Angle.ByHours(4), Angle.ByDegree(29), Epoch.J2000);
            var telescopeInfo = new TelescopeInfo()
            {
                Connected   = true,
                Coordinates = coordinates
            };
            var sut = new ImageMetaData();

            sut.FromTelescopeInfo(telescopeInfo);

            Assert.AreEqual(Epoch.J2000, sut.Telescope.Coordinates.Epoch);
            Assert.AreEqual(60, sut.Telescope.Coordinates.RADegrees);
            Assert.AreEqual(29, sut.Telescope.Coordinates.Dec);
        }
コード例 #4
0
ファイル: ImageMetaDataTest.cs プロジェクト: daleghent/NINA
        public void FromTelescopeInfoNotConnectedTest()
        {
            var coordinates   = new Coordinates(Angle.ByHours(4), Angle.ByDegree(29), Epoch.J2000);
            var telescopeInfo = new TelescopeInfo()
            {
                Connected     = false,
                Name          = "TestName",
                SiteElevation = 120.3,
                Coordinates   = coordinates
            };
            var sut = new ImageMetaData();

            sut.FromTelescopeInfo(telescopeInfo);

            Assert.AreEqual(string.Empty, sut.Telescope.Name);
            Assert.AreEqual(double.NaN, sut.Telescope.FocalLength);
            Assert.AreEqual(double.NaN, sut.Telescope.FocalRatio);
            Assert.AreEqual(null, sut.Telescope.Coordinates);
        }
コード例 #5
0
ファイル: MeridianFlipVMTest.cs プロジェクト: daleghent/NINA
        public void ShouldFlipTest(double timeToFlipMinutes, double exposureTimeMinutes, double minutesAfterMeridian, double pauseBeforeMeridian, bool useSideOfPier, bool shouldFlip, PierSide pierSide = PierSide.pierUnknown)
        {
            meridianFlipSettingsMock.SetupGet(m => m.Enabled).Returns(true);
            meridianFlipSettingsMock.SetupGet(m => m.MinutesAfterMeridian).Returns(minutesAfterMeridian);
            meridianFlipSettingsMock.SetupGet(m => m.PauseTimeBeforeMeridian).Returns(pauseBeforeMeridian);
            meridianFlipSettingsMock.SetupGet(m => m.Recenter).Returns(false);
            meridianFlipSettingsMock.SetupGet(m => m.SettleTime).Returns(0);
            meridianFlipSettingsMock.SetupGet(m => m.UseSideOfPier).Returns(useSideOfPier);

            var telescopeInfo = new TelescopeInfo()
            {
                TimeToMeridianFlip = TimeSpan.FromMinutes(timeToFlipMinutes).TotalHours,
                SideOfPier         = pierSide,
                Connected          = true
            };

            var exposureTime = TimeSpan.FromMinutes(exposureTimeMinutes).TotalSeconds;

            var sut = MeridianFlipVM.ShouldFlip(profileServiceMock.Object, exposureTime, telescopeInfo);

            sut.Should().Be(shouldFlip);
        }
コード例 #6
0
ファイル: ImageMetaDataTest.cs プロジェクト: daleghent/NINA
        public void FromTelescopeInfoConnectedTest()
        {
            var coordinates   = new Coordinates(Angle.ByHours(4), Angle.ByDegree(29), Epoch.JNOW, new DateTime(2020, 06, 16));
            var telescopeInfo = new TelescopeInfo()
            {
                Connected     = true,
                Name          = "TestName",
                SiteElevation = 120.3,
                Coordinates   = coordinates
            };
            var sut = new ImageMetaData();

            sut.FromTelescopeInfo(telescopeInfo);

            Assert.AreEqual("TestName", sut.Telescope.Name);
            Assert.AreEqual(120.3, sut.Observer.Elevation);
            Assert.AreEqual(double.NaN, sut.Telescope.FocalLength);
            Assert.AreEqual(double.NaN, sut.Telescope.FocalRatio);

            Assert.AreEqual(Epoch.J2000, sut.Telescope.Coordinates.Epoch);
            Assert.AreEqual(59.694545025696307d, sut.Telescope.Coordinates.RADegrees);
            Assert.AreEqual(28.945185789035015d, sut.Telescope.Coordinates.Dec);
        }
コード例 #7
0
        private async Task <bool> ChooseTelescope()
        {
            await ss.WaitAsync();

            try {
                await Disconnect();

                if (updateTimer != null)
                {
                    await updateTimer.Stop();
                }

                if (TelescopeChooserVM.SelectedDevice.Id == "No_Device")
                {
                    profileService.ActiveProfile.TelescopeSettings.Id = TelescopeChooserVM.SelectedDevice.Id;
                    return(false);
                }

                this.applicationStatusMediator.StatusUpdate(
                    new ApplicationStatus()
                {
                    Source = Title,
                    Status = Locale.Loc.Instance["LblConnecting"]
                }
                    );

                var telescope = (ITelescope)TelescopeChooserVM.SelectedDevice;
                _cancelChooseTelescopeSource?.Dispose();
                _cancelChooseTelescopeSource = new CancellationTokenSource();
                if (telescope != null)
                {
                    try {
                        var connected = await telescope?.Connect(_cancelChooseTelescopeSource.Token);

                        _cancelChooseTelescopeSource.Token.ThrowIfCancellationRequested();
                        if (connected)
                        {
                            Telescope = telescope;

                            if (Telescope.EquatorialSystem == Epoch.B1950 || Telescope.EquatorialSystem == Epoch.J2050)
                            {
                                Logger.Error($"Mount uses an unsupported equatorial system: {Telescope.EquatorialSystem}");
                                throw new OperationCanceledException(string.Format(Locale.Loc.Instance["LblUnsupportedEpoch"], Telescope.EquatorialSystem));
                            }

                            if (Telescope.HasUnknownEpoch)
                            {
                                Logger.Warning($"Mount reported an Unknown or Other equatorial system. Defaulting to {Telescope.EquatorialSystem}");
                                Notification.ShowWarning(string.Format(Locale.Loc.Instance["LblUnknownEpochWarning"], Telescope.EquatorialSystem));
                            }

                            if (Telescope.SiteLatitude != profileService.ActiveProfile.AstrometrySettings.Latitude || Telescope.SiteLongitude != profileService.ActiveProfile.AstrometrySettings.Longitude)
                            {
                                var syncVM = new TelescopeLatLongSyncVM(
                                    Telescope.CanSetSiteLatLong,
                                    profileService.ActiveProfile.AstrometrySettings.Latitude,
                                    profileService.ActiveProfile.AstrometrySettings.Longitude,
                                    Telescope.SiteLatitude,
                                    Telescope.SiteLongitude
                                    );
                                await WindowService.ShowDialog(syncVM, Locale.Loc.Instance["LblSyncLatLong"], System.Windows.ResizeMode.NoResize, System.Windows.WindowStyle.ToolWindow);

                                if (syncVM.Mode == TelescopeLatLongSyncVM.LatLongSyncMode.NINA)
                                {
                                    profileService.ChangeLatitude(Telescope.SiteLatitude);
                                    profileService.ChangeLongitude(Telescope.SiteLongitude);
                                }
                                else if (syncVM.Mode == TelescopeLatLongSyncVM.LatLongSyncMode.TELESCOPE)
                                {
                                    Telescope.SiteLatitude  = profileService.ActiveProfile.AstrometrySettings.Latitude;
                                    Telescope.SiteLongitude = profileService.ActiveProfile.AstrometrySettings.Longitude;
                                }
                            }

                            TelescopeInfo = new TelescopeInfo {
                                AltitudeString        = Telescope.AltitudeString,
                                AtPark                = Telescope.AtPark,
                                AzimuthString         = Telescope.AzimuthString,
                                Connected             = true,
                                Coordinates           = Telescope.Coordinates,
                                Declination           = Telescope.Declination,
                                DeclinationString     = Telescope.DeclinationString,
                                HoursToMeridianString = Telescope.HoursToMeridianString,
                                Name                     = Telescope.Name,
                                RightAscension           = Telescope.RightAscension,
                                RightAscensionString     = Telescope.RightAscensionString,
                                SiderealTime             = Telescope.SiderealTime,
                                SiderealTimeString       = Telescope.SiderealTimeString,
                                SiteElevation            = Telescope.SiteElevation,
                                SiteLatitude             = Telescope.SiteLatitude,
                                SiteLongitude            = Telescope.SiteLongitude,
                                TimeToMeridianFlip       = Telescope.TimeToMeridianFlip,
                                TimeToMeridianFlipString = Telescope.TimeToMeridianFlipString,
                                SideOfPier               = Telescope.SideOfPier,
                                Tracking                 = Telescope.Tracking,
                                CanSetTracking           = Telescope.CanSetTracking,
                                CanPark                  = Telescope.CanPark,
                                CanSetPark               = Telescope.CanSetPark,
                                EquatorialSystem         = Telescope.EquatorialSystem,
                                HasUnknownEpoch          = Telescope.HasUnknownEpoch
                            };

                            BroadcastTelescopeInfo();

                            updateTimer.Interval = profileService.ActiveProfile.ApplicationSettings.DevicePollingInterval;
                            updateTimer.Start();

                            Notification.ShowSuccess(Locale.Loc.Instance["LblTelescopeConnected"]);
                            profileService.ActiveProfile.TelescopeSettings.Id = Telescope.Id;

                            Logger.Info($"Successfully connected Telescope. Id: {telescope.Id} Name: {telescope.Name} Driver Version: {telescope.DriverVersion}");

                            return(true);
                        }
                        else
                        {
                            Telescope = null;
                            return(false);
                        }
                    } catch (OperationCanceledException ex) {
                        if (telescope?.Connected == true)
                        {
                            await Disconnect();
                        }
                        Notification.ShowError(ex.Message);
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            } finally {
                ss.Release();
                this.applicationStatusMediator.StatusUpdate(
                    new ApplicationStatus()
                {
                    Source = Title,
                    Status = string.Empty
                }
                    );
            }
        }
コード例 #8
0
 public void UpdateDeviceInfo(TelescopeInfo deviceInfo)
 {
     this.telescopeInfo = deviceInfo;
 }
コード例 #9
0
 public void UpdateDeviceInfo(TelescopeInfo telescopeInfo)
 {
     this.TelescopeInfo = telescopeInfo;
 }