コード例 #1
0
        public AnchorablePlateSolverVM(IProfileService profileService,
                                       ICameraMediator cameraMediator,
                                       ITelescopeMediator telescopeMediator,
                                       IImagingMediator imagingMediator,
                                       IApplicationStatusMediator applicationStatusMediator) : base(profileService)
        {
            Title = "LblPlateSolving";

            this.cameraMediator = cameraMediator;
            this.cameraMediator.RegisterConsumer(this);
            this.telescopeMediator = telescopeMediator;
            this.telescopeMediator.RegisterConsumer(this);
            this.imagingMediator           = imagingMediator;
            this.applicationStatusMediator = applicationStatusMediator;

            ImageGeometry = (System.Windows.Media.GeometryGroup)System.Windows.Application.Current.Resources["PlatesolveSVG"];

            SolveCommand       = new AsyncCommand <bool>(() => CaptureSolveSyncAndReslew(new Progress <ApplicationStatus>(p => Status = p)));
            CancelSolveCommand = new RelayCommand(CancelSolve);

            SnapExposureDuration = profileService.ActiveProfile.PlateSolveSettings.ExposureTime;
            SnapFilter           = profileService.ActiveProfile.PlateSolveSettings.Filter;
            RepeatThreshold      = profileService.ActiveProfile.PlateSolveSettings.Threshold;
            SlewToTarget         = profileService.ActiveProfile.PlateSolveSettings.SlewToTarget;

            profileService.ProfileChanged += (object sender, EventArgs e) => {
                SnapExposureDuration = profileService.ActiveProfile.PlateSolveSettings.ExposureTime;
                SnapFilter           = profileService.ActiveProfile.PlateSolveSettings.Filter;
                RepeatThreshold      = profileService.ActiveProfile.PlateSolveSettings.Threshold;
                SlewToTarget         = profileService.ActiveProfile.PlateSolveSettings.SlewToTarget;
            };
        }
コード例 #2
0
        public ApplicationStatusVM(IProfileService profileService, IApplicationStatusMediator applicationStatusMediator) : base(profileService)
        {
            Title         = "LblApplicationStatus";
            ImageGeometry = (System.Windows.Media.GeometryGroup)System.Windows.Application.Current.Resources["ApplicationStatusSVG"];

            this.applicationStatusMediator = applicationStatusMediator;
            this.applicationStatusMediator.RegisterHandler(this);
        }
コード例 #3
0
        public ImagingVM(
            IProfileService profileService,
            IImagingMediator imagingMediator,
            ICameraMediator cameraMediator,
            ITelescopeMediator telescopeMediator,
            IFilterWheelMediator filterWheelMediator,
            IFocuserMediator focuserMediator,
            IRotatorMediator rotatorMediator,
            IGuiderMediator guiderMediator,
            IWeatherDataMediator weatherDataMediator,
            IApplicationStatusMediator applicationStatusMediator
            ) : base(profileService)
        {
            this.imagingMediator = imagingMediator;
            this.imagingMediator.RegisterHandler(this);

            this.cameraMediator = cameraMediator;
            this.cameraMediator.RegisterConsumer(this);

            this.telescopeMediator = telescopeMediator;
            this.telescopeMediator.RegisterConsumer(this);

            this.filterWheelMediator = filterWheelMediator;
            this.filterWheelMediator.RegisterConsumer(this);

            this.focuserMediator = focuserMediator;
            this.focuserMediator.RegisterConsumer(this);

            this.rotatorMediator = rotatorMediator;
            this.rotatorMediator.RegisterConsumer(this);

            this.guiderMediator            = guiderMediator;
            this.applicationStatusMediator = applicationStatusMediator;

            this.weatherDataMediator = weatherDataMediator;
            this.weatherDataMediator.RegisterConsumer(this);

            progress = new Progress <ApplicationStatus>(p => Status = p);

            ImageControl = new ImageControlVM(profileService, cameraMediator, telescopeMediator, applicationStatusMediator);
        }
コード例 #4
0
        public FlatDeviceVM(IProfileService profileService, IFlatDeviceMediator flatDeviceMediator, IApplicationStatusMediator applicationStatusMediator, IImageGeometryProvider imageGeometryProvider) : base(profileService)
        {
            _applicationStatusMediator = applicationStatusMediator;
            _flatDeviceMediator        = flatDeviceMediator;
            _flatDeviceMediator.RegisterHandler(this);

            this.Title         = "LblFlatDevice";
            this.ImageGeometry = imageGeometryProvider.GetImageGeometry("LightBulbSVG");

            ConnectCommand               = new AsyncCommand <bool>(Connect);
            CancelConnectCommand         = new RelayCommand(CancelConnectFlatDevice);
            DisconnectCommand            = new AsyncCommand <bool>(() => DisconnectFlatDeviceDialog());
            OpenCoverCommand             = new AsyncCommand <bool>(OpenCover);
            CloseCoverCommand            = new AsyncCommand <bool>(CloseCover);
            RefreshFlatDeviceListCommand =
                new RelayCommand(RefreshFlatDeviceList, o => _flatDevice?.Connected != true);
            SetBrightnessCommand = new RelayCommand(SetBrightness);
            ToggleLightCommand   = new RelayCommand(ToggleLight);
            AddGainCommand       = new RelayCommand(AddGain);
            AddBinningCommand    = new RelayCommand(AddBinning);
            DeleteGainCommand    = new RelayCommand(DeleteGainDialog);
            DeleteBinningCommand = new RelayCommand(DeleteBinningDialog);

            FlatDeviceChooserVM = new FlatDeviceChooserVM(profileService);
            FlatDeviceChooserVM.GetEquipment();

            _updateTimer = new DeviceUpdateTimer(
                GetFlatDeviceValues,
                UpdateFlatDeviceValues,
                profileService.ActiveProfile.ApplicationSettings.DevicePollingInterval
                );

            _flatDeviceSettings = profileService.ActiveProfile.FlatDeviceSettings;
            _flatDeviceSettings.PropertyChanged += FlatDeviceSettingsChanged;
            profileService.ProfileChanged       += ProfileChanged;
            profileService.ActiveProfile.FilterWheelSettings.PropertyChanged += FilterWheelSettingsChanged;
            UpdateWizardValueBlocks();
        }
コード例 #5
0
        public AnchorableSnapshotVM(
            IProfileService profileService,
            IImagingMediator imagingMediator,
            ICameraMediator cameraMediator,
            IApplicationStatusMediator applicationStatusMediator) : base(profileService)
        {
            Title         = "LblImaging";
            ImageGeometry = (System.Windows.Media.GeometryGroup)System.Windows.Application.Current.Resources["ImagingSVG"];
            this.applicationStatusMediator = applicationStatusMediator;
            this.cameraMediator            = cameraMediator;
            this.cameraMediator.RegisterConsumer(this);
            this.imagingMediator = imagingMediator;
            progress             = new Progress <ApplicationStatus>(p => Status = p);
            SnapCommand          = new AsyncCommand <bool>(() => SnapImage(progress));
            CancelSnapCommand    = new RelayCommand(CancelSnapImage);
            StartLiveViewCommand = new AsyncCommand <bool>(StartLiveView);
            StopLiveViewCommand  = new RelayCommand(StopLiveView);
            SnapFilter           = profileService.ActiveProfile.FilterWheelSettings.FilterWheelFilters?.FirstOrDefault(x => x.Name == profileService.ActiveProfile.SnapShotControlSettings.Filter?.Name);

            profileService.ProfileChanged += (object sender, EventArgs e) => {
                SnapFilter = profileService.ActiveProfile.FilterWheelSettings.FilterWheelFilters?.FirstOrDefault(x => x.Name == profileService.ActiveProfile.SnapShotControlSettings.Filter?.Name);
            };
        }
コード例 #6
0
        public SwitchVM(IProfileService profileService, IApplicationStatusMediator applicationStatusMediator, ISwitchMediator switchMediator) : base(profileService)
        {
            Title           = "LblSwitch";
            ImageGeometry   = (System.Windows.Media.GeometryGroup)System.Windows.Application.Current.Resources["SwitchesSVG"];
            SwitchChooserVM = new SwitchChooserVM(profileService);
            SwitchChooserVM.GetEquipment();

            this.applicationStatusMediator = applicationStatusMediator;
            this.switchMediator            = switchMediator;
            this.switchMediator.RegisterHandler(this);

            ConnectCommand        = new AsyncCommand <bool>(Connect);
            DisconnectCommand     = new AsyncCommand <bool>(async() => { await Disconnect(); return(true); });
            CancelConnectCommand  = new RelayCommand((object o) => CancelConnect());
            RefreshDevicesCommand = new RelayCommand((object o) => RefreshDevices(), o => !(SwitchHub?.Connected == true));

            updateTimer = new DeviceUpdateTimer(
                GetSwitchValues,
                UpdateSwitchValues,
                profileService.ActiveProfile.ApplicationSettings.DevicePollingInterval
                );

            SetSwitchValueCommand = new AsyncCommand <bool>(SetSwitchValue);
        }
コード例 #7
0
ファイル: MeridianFlipVM.cs プロジェクト: daleghent/NINA
        public MeridianFlipVM(IProfileService profileService, ITelescopeMediator telescopeMediator, IGuiderMediator guiderMediator, IImagingMediator imagingMediator, IApplicationStatusMediator applicationStatusMediator) : base(profileService)
        {
            this.telescopeMediator         = telescopeMediator;
            this.guiderMediator            = guiderMediator;
            this.imagingMediator           = imagingMediator;
            this.applicationStatusMediator = applicationStatusMediator;

            CancelCommand = new RelayCommand(Cancel);
        }
コード例 #8
0
        public TelescopeVM(IProfileService profileService, ITelescopeMediator telescopeMediator, IApplicationStatusMediator applicationStatusMediator) : base(profileService)
        {
            this.profileService    = profileService;
            this.telescopeMediator = telescopeMediator;
            this.telescopeMediator.RegisterHandler(this);
            this.applicationStatusMediator = applicationStatusMediator;
            Title         = "LblTelescope";
            ImageGeometry = (System.Windows.Media.GeometryGroup)System.Windows.Application.Current.Resources["TelescopeSVG"];

            ChooseTelescopeCommand       = new AsyncCommand <bool>(() => ChooseTelescope());
            CancelChooseTelescopeCommand = new RelayCommand(CancelChooseTelescope);
            DisconnectCommand            = new AsyncCommand <bool>(() => DisconnectTelescope());
            ParkCommand                 = new AsyncCommand <bool>(ParkTelescope);
            UnparkCommand               = new RelayCommand(UnparkTelescope);
            SetParkPositionCommand      = new AsyncCommand <bool>(SetParkPosition);
            SlewToCoordinatesCommand    = new AsyncCommand <bool>(SlewToCoordinatesInternal);
            RefreshTelescopeListCommand = new RelayCommand(RefreshTelescopeList, o => !(Telescope?.Connected == true));

            MoveCommand     = new RelayCommand(Move);
            StopMoveCommand = new RelayCommand(StopMove);
            StopSlewCommand = new RelayCommand(StopSlew);

            updateTimer = new DeviceUpdateTimer(
                GetTelescopeValues,
                UpdateTelescopeValues,
                profileService.ActiveProfile.ApplicationSettings.DevicePollingInterval
                );

            profileService.ProfileChanged += (object sender, EventArgs e) => {
                RefreshTelescopeList(null);
            };

            progress = new Progress <ApplicationStatus>(p => {
                p.Source = this.Title;
                this.applicationStatusMediator.StatusUpdate(p);
            });
        }
コード例 #9
0
ファイル: WeatherDataVM.cs プロジェクト: daleghent/NINA
        public WeatherDataVM(IProfileService profileService, IWeatherDataMediator weatherDataMediator, IApplicationStatusMediator applicationStatusMediator) : base(profileService)
        {
            Title         = "LblWeather";
            ImageGeometry = (System.Windows.Media.GeometryGroup)System.Windows.Application.Current.Resources["CloudSVG"];

            this.weatherDataMediator = weatherDataMediator;
            this.weatherDataMediator.RegisterHandler(this);
            this.applicationStatusMediator = applicationStatusMediator;

            ChooseWeatherDataCommand       = new AsyncCommand <bool>(() => ChooseWeatherData());
            CancelChooseWeatherDataCommand = new RelayCommand(CancelChooseWeatherData);
            DisconnectCommand             = new AsyncCommand <bool>(() => DisconnectDiag());
            RefreshWeatherDataListCommand = new RelayCommand(RefreshWeatherDataList, o => !(WeatherData?.Connected == true));

            updateTimer = new DeviceUpdateTimer(
                GetWeatherDataValues,
                UpdateWeatherDataValues,
                profileService.ActiveProfile.ApplicationSettings.DevicePollingInterval
                );

            profileService.ProfileChanged += (object sender, EventArgs e) => {
                RefreshWeatherDataList(null);
            };
        }
コード例 #10
0
        public ImageControlVM(IProfileService profileService, ICameraMediator cameraMediator, ITelescopeMediator telescopeMediator, IApplicationStatusMediator applicationStatusMediator) : base(profileService)
        {
            Title         = "LblImage";
            ImageGeometry = (System.Windows.Media.GeometryGroup)System.Windows.Application.Current.Resources["PictureSVG"];

            this.cameraMediator = cameraMediator;
            this.cameraMediator.RegisterConsumer(this);

            this.telescopeMediator         = telescopeMediator;
            this.applicationStatusMediator = applicationStatusMediator;
            AutoStretch          = profileService.ActiveProfile.ImageSettings.AutoStretch;
            DetectStars          = profileService.ActiveProfile.ImageSettings.DetectStars;
            ShowCrossHair        = false;
            ShowBahtinovAnalyzer = false;
            ShowSubSampler       = false;

            _progress = new Progress <ApplicationStatus>(p => Status = p);

            PrepareImageCommand          = new AsyncCommand <bool>(() => ProcessImageHelper());
            PlateSolveImageCommand       = new AsyncCommand <bool>(() => PlateSolveImage(), (object o) => Image != null);
            CancelPlateSolveImageCommand = new RelayCommand(CancelPlateSolveImage);
            DragStartCommand             = new RelayCommand(BahtinovDragStart);
            DragStopCommand           = new RelayCommand(BahtinovDragStop);
            DragMoveCommand           = new RelayCommand(BahtinovDragMove);
            SubSampleDragStartCommand = new RelayCommand(SubSampleDragStart);
            SubSampleDragStopCommand  = new RelayCommand(SubSampleDragStop);
            SubSampleDragMoveCommand  = new RelayCommand(SubSampleDragMove);
            InspectAberrationCommand  = new AsyncCommand <bool>(() => InspectAberration(), (object o) => Image != null);

            PixelPeepStartCommand = new RelayCommand(PixelPeeperStart);
            PixelPeepMoveCommand  = new RelayCommand(PixelPeeperMove);
            PixelPeepEndCommand   = new RelayCommand(PixelPeeperStop);

            BahtinovRectangle  = new ObservableRectangle(-1, -1, 200, 200);
            SubSampleRectangle = new ObservableRectangle(-1, -1, 600, 600);
            BahtinovRectangle.PropertyChanged  += Rectangle_PropertyChanged;
            SubSampleRectangle.PropertyChanged += SubSampleRectangle_PropertyChanged;
        }
コード例 #11
0
        public FramingAssistantVM(IProfileService profileService, ICameraMediator cameraMediator, ITelescopeMediator telescopeMediator, IApplicationStatusMediator applicationStatusMediator) : base(profileService)
        {
            this.cameraMediator = cameraMediator;
            this.cameraMediator.RegisterConsumer(this);
            this.telescopeMediator         = telescopeMediator;
            this.applicationStatusMediator = applicationStatusMediator;

            Opacity = 0.2;

            SkyMapAnnotator = new SkyMapAnnotator(telescopeMediator);

            var defaultCoordinates = new Coordinates(0, 0, Epoch.J2000, Coordinates.RAType.Degrees);

            DSO = new DeepSkyObject(string.Empty, defaultCoordinates, profileService.ActiveProfile.ApplicationSettings.SkyAtlasImageRepository);

            FramingAssistantSource = profileService.ActiveProfile.FramingAssistantSettings.LastSelectedImageSource;

            CameraPixelSize = profileService.ActiveProfile.CameraSettings.PixelSize;
            FocalLength     = profileService.ActiveProfile.TelescopeSettings.FocalLength;

            _statusUpdate = new Progress <ApplicationStatus>(p => Status = p);

            LoadImageCommand = new AsyncCommand <bool>(async() => { return(await LoadImage()); });
            CancelLoadImageFromFileCommand = new RelayCommand((object o) => { CancelLoadImage(); });
            _progress = new Progress <int>((p) => DownloadProgressValue = p);
            CancelLoadImageCommand         = new RelayCommand((object o) => { CancelLoadImage(); });
            DragStartCommand               = new RelayCommand(DragStart);
            DragStopCommand                = new RelayCommand(DragStop);
            DragMoveCommand                = new RelayCommand(DragMove);
            ClearCacheCommand              = new RelayCommand(ClearCache, (object o) => Cache != null);
            RefreshSkyMapAnnotationCommand = new RelayCommand((object o) => SkyMapAnnotator.UpdateSkyMap(), (object o) => SkyMapAnnotator.Initialized);
            MouseWheelCommand              = new RelayCommand(MouseWheel);

            CoordsFromPlanetariumCommand = new AsyncCommand <bool>(() => Task.Run(CoordsFromPlanetarium));

            DeepSkyObjectSearchVM = new DeepSkyObjectSearchVM();
            DeepSkyObjectSearchVM.PropertyChanged += DeepSkyObjectSearchVM_PropertyChanged;

            SetSequenceCoordinatesCommand = new AsyncCommand <bool>(async(object parameter) => {
                var vm = (ApplicationVM)Application.Current.Resources["AppVM"];
                vm.ChangeTab(ApplicationTab.SEQUENCE);

                var deepSkyObjects = new List <DeepSkyObject>();
                foreach (var rect in CameraRectangles)
                {
                    var name     = rect.Id > 0 ? DSO?.Name + string.Format(" {0} ", Locale.Loc.Instance["LblPanel"]) + rect.Id : DSO?.Name;
                    var dso      = new DeepSkyObject(name, rect.Coordinates, profileService.ActiveProfile.ApplicationSettings.SkyAtlasImageRepository);
                    dso.Rotation = Rectangle.DisplayedRotation;
                    deepSkyObjects.Add(dso);
                }

                bool msgResult = false;
                if (parameter.ToString() == "Replace")
                {
                    msgResult = await vm.SeqVM.SetSequenceCoordiantes(deepSkyObjects);
                }
                else if (parameter.ToString() == "Add")
                {
                    msgResult = await vm.SeqVM.SetSequenceCoordiantes(deepSkyObjects, false);
                }

                ImageParameter = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
                return(msgResult);
            }, (object o) => Rectangle?.Coordinates != null);

            RecenterCommand = new AsyncCommand <bool>(async() => {
                DSO.Coordinates = Rectangle.Coordinates;
                await LoadImageCommand.ExecuteAsync(null);
                return(true);
            }, (object o) => Rectangle?.Coordinates != null);

            SlewToCoordinatesCommand = new AsyncCommand <bool>(async() => {
                return(await telescopeMediator.SlewToCoordinatesAsync(Rectangle.Coordinates));
            }, (object o) => Rectangle?.Coordinates != null);

            var appSettings = profileService.ActiveProfile.ApplicationSettings;

            appSettings.PropertyChanged += ApplicationSettings_PropertyChanged;

            profileService.ProfileChanged += (object sender, EventArgs e) => {
                appSettings.PropertyChanged -= ApplicationSettings_PropertyChanged;

                this.FocalLength     = profileService.ActiveProfile.TelescopeSettings.FocalLength;
                this.CameraPixelSize = profileService.ActiveProfile.CameraSettings.PixelSize;

                RaisePropertyChanged(nameof(CameraPixelSize));
                RaisePropertyChanged(nameof(FocalLength));
                RaisePropertyChanged(nameof(FieldOfView));
                RaisePropertyChanged(nameof(CameraWidth));
                RaisePropertyChanged(nameof(CameraHeight));
                appSettings = profileService.ActiveProfile.ApplicationSettings;
                appSettings.PropertyChanged += ApplicationSettings_PropertyChanged;
                ApplicationSettings_PropertyChanged(null, null);
            };

            resizeTimer          = new DispatcherTimer(DispatcherPriority.ApplicationIdle, _dispatcher);
            resizeTimer.Interval = TimeSpan.FromMilliseconds(500);
            resizeTimer.Tick    += ResizeTimer_Tick;

            ScrollViewerSizeChangedCommand = new RelayCommand((parameter) => {
                resizeTimer.Stop();
                if (ImageParameter != null && FramingAssistantSource == SkySurveySource.SKYATLAS)
                {
                    resizeTimer.Start();
                }
            });

            profileService.LocationChanged += (object sender, EventArgs e) => {
                DSO = new DeepSkyObject(DSO.Name, DSO.Coordinates, profileService.ActiveProfile.ApplicationSettings.SkyAtlasImageRepository);
            };

            InitializeCache();
        }
コード例 #12
0
ファイル: FlatWizardVM.cs プロジェクト: daleghent/NINA
        public FlatWizardVM(IProfileService profileService,
                            IImagingVM imagingVM,
                            ICameraMediator cameraMediator,
                            IFilterWheelMediator filterWheelMediator,
                            ITelescopeMediator telescopeMediator,
                            IFlatDeviceMediator flatDeviceMediator,
                            IApplicationResourceDictionary resourceDictionary,
                            IApplicationStatusMediator applicationStatusMediator) : base(profileService)
        {
            Title         = "LblFlatWizard";
            ImageGeometry = (System.Windows.Media.GeometryGroup)resourceDictionary["FlatWizardSVG"];

            ImagingVM = imagingVM;

            this.applicationStatusMediator = applicationStatusMediator;

            flatSequenceCts?.Dispose();
            flatSequenceCts = new CancellationTokenSource();
            var pauseTokenSource = new PauseTokenSource();

            Gain = -1;

            StartFlatSequenceCommand = new AsyncCommand <bool>(
                () => StartSingleFlatCapture(new Progress <ApplicationStatus>(p => Status = p), pauseTokenSource.Token),
                (object o) => cameraInfo.Connected
                );
            StartMultiFlatSequenceCommand = new AsyncCommand <bool>(
                () => StartMultiFlatCapture(new Progress <ApplicationStatus>(p => Status = p), pauseTokenSource.Token),
                (object o) => cameraInfo.Connected && filterWheelInfo.Connected
                );
            SlewToZenithCommand = new AsyncCommand <bool>(
                () => SlewToZenith(),
                (object o) => telescopeInfo.Connected
                );

            CancelFlatExposureSequenceCommand = new RelayCommand(CancelFindExposureTime);
            PauseFlatExposureSequenceCommand  = new RelayCommand(obj => { IsPaused = true; pauseTokenSource.IsPaused = IsPaused; });
            ResumeFlatExposureSequenceCommand = new RelayCommand(obj => { IsPaused = false; pauseTokenSource.IsPaused = IsPaused; });

            FlatCount     = profileService.ActiveProfile.FlatWizardSettings.FlatCount;
            DarkFlatCount = profileService.ActiveProfile.FlatWizardSettings.DarkFlatCount;
            BinningMode   = profileService.ActiveProfile.FlatWizardSettings.BinningMode;

            Filters = new ObservableCollection <FlatWizardFilterSettingsWrapper>();

            profileService.ProfileChanged += (sender, args) => {
                UpdateSingleFlatWizardFilterSettings(profileService);
                watchedFilterList.CollectionChanged -= FiltersCollectionChanged;
                watchedFilterList = profileService.ActiveProfile.FilterWheelSettings.FilterWheelFilters;
                watchedFilterList.CollectionChanged += FiltersCollectionChanged;
                UpdateFilterWheelsSettings();
            };

            watchedFilterList = profileService.ActiveProfile.FilterWheelSettings.FilterWheelFilters;
            watchedFilterList.CollectionChanged += FiltersCollectionChanged;

            // first update filters

            UpdateSingleFlatWizardFilterSettings(profileService);
            UpdateFilterWheelsSettings();

            // then register consumer and get the cameraInfo so it's populated to all filters including the singleflatwizardfiltersettings
            this.cameraMediator = cameraMediator;
            cameraMediator.RegisterConsumer(this);
            this.filterWheelMediator = filterWheelMediator;
            filterWheelMediator.RegisterConsumer(this);
            this.telescopeMediator = telescopeMediator;
            this.telescopeMediator.RegisterConsumer(this);

            // register the flat panel mediator
            _flatDeviceMediator = flatDeviceMediator;
            _flatDeviceMediator.RegisterConsumer(this);

            TargetName = "FlatWizard";
        }
コード例 #13
0
        public FilterWheelVM(IProfileService profileService, IFilterWheelMediator filterWheelMediator, IFocuserMediator focuserMediator, IApplicationStatusMediator applicationStatusMediator) : base(profileService)
        {
            Title         = "LblFilterWheel";
            ImageGeometry = (System.Windows.Media.GeometryGroup)System.Windows.Application.Current.Resources["FWSVG"];

            this.filterWheelMediator = filterWheelMediator;
            this.filterWheelMediator.RegisterHandler(this);

            this.focuserMediator           = focuserMediator;
            this.applicationStatusMediator = applicationStatusMediator;

            ChooseFWCommand       = new AsyncCommand <bool>(() => ChooseFW());
            CancelChooseFWCommand = new RelayCommand(CancelChooseFW);
            DisconnectCommand     = new AsyncCommand <bool>(() => DisconnectFW());
            RefreshFWListCommand  = new RelayCommand(RefreshFWList, o => !(FW?.Connected == true));
            ChangeFilterCommand   = new AsyncCommand <bool>(async() => {
                _changeFilterCancellationSource?.Dispose();
                _changeFilterCancellationSource = new CancellationTokenSource();
                await ChangeFilter(TargetFilter, _changeFilterCancellationSource.Token);
                return(true);
            }, (object o) => FilterWheelInfo.Connected && !FilterWheelInfo.IsMoving);

            profileService.ProfileChanged += (object sender, EventArgs e) => {
                RefreshFWList(null);
            };
        }
コード例 #14
0
        public FocuserVM(IProfileService profileService, IFocuserMediator focuserMediator, IApplicationStatusMediator applicationStatusMediator) : base(profileService)
        {
            Title         = "LblFocuser";
            ImageGeometry = (System.Windows.Media.GeometryGroup)System.Windows.Application.Current.Resources["FocusSVG"];

            this.focuserMediator = focuserMediator;
            this.focuserMediator.RegisterHandler(this);
            this.applicationStatusMediator = applicationStatusMediator;

            ChooseFocuserCommand       = new AsyncCommand <bool>(() => ChooseFocuser());
            CancelChooseFocuserCommand = new RelayCommand(CancelChooseFocuser);
            DisconnectCommand          = new AsyncCommand <bool>(() => DisconnectDiag());
            RefreshFocuserListCommand  = new RelayCommand(RefreshFocuserList, o => !(Focuser?.Connected == true));
            MoveFocuserInSmallCommand  = new AsyncCommand <int>(() => MoveFocuserRelativeInternal((int)Math.Round(profileService.ActiveProfile.FocuserSettings.AutoFocusStepSize / -2d)), (p) => FocuserInfo.Connected && !FocuserInfo.IsMoving);
            MoveFocuserInLargeCommand  = new AsyncCommand <int>(() => MoveFocuserRelativeInternal(profileService.ActiveProfile.FocuserSettings.AutoFocusStepSize * -5), (p) => FocuserInfo.Connected && !FocuserInfo.IsMoving);
            MoveFocuserOutSmallCommand = new AsyncCommand <int>(() => MoveFocuserRelativeInternal((int)Math.Round(profileService.ActiveProfile.FocuserSettings.AutoFocusStepSize / 2d)), (p) => FocuserInfo.Connected && !FocuserInfo.IsMoving);
            MoveFocuserOutLargeCommand = new AsyncCommand <int>(() => MoveFocuserRelativeInternal(profileService.ActiveProfile.FocuserSettings.AutoFocusStepSize * 5), (p) => FocuserInfo.Connected && !FocuserInfo.IsMoving);
            MoveFocuserCommand         = new AsyncCommand <int>(() => MoveFocuserInternal(TargetPosition), (p) => FocuserInfo.Connected && !FocuserInfo.IsMoving);
            HaltFocuserCommand         = new RelayCommand((object o) => _cancelMove?.Cancel());
            ToggleTempCompCommand      = new RelayCommand(ToggleTempComp);

            updateTimer = new DeviceUpdateTimer(
                GetFocuserValues,
                UpdateFocuserValues,
                profileService.ActiveProfile.ApplicationSettings.DevicePollingInterval
                );

            profileService.ProfileChanged += (object sender, EventArgs e) => {
                RefreshFocuserList(null);
            };

            progress = new Progress <ApplicationStatus>(p => {
                p.Source = this.Title;
                this.applicationStatusMediator.StatusUpdate(p);
            });
        }
コード例 #15
0
        public CameraVM(IProfileService profileService, ICameraMediator cameraMediator, ITelescopeMediator telescopeMediator, IApplicationStatusMediator applicationStatusMediator) : base(profileService)
        {
            Title         = "LblCamera";
            ImageGeometry = (System.Windows.Media.GeometryGroup)System.Windows.Application.Current.Resources["CameraSVG"];

            CameraChooserVM = new CameraChooserVM(profileService, telescopeMediator);
            CameraChooserVM.GetEquipment();

            this.cameraMediator = cameraMediator;
            this.cameraMediator.RegisterHandler(this);
            this.applicationStatusMediator = applicationStatusMediator;

            ChooseCameraCommand        = new AsyncCommand <bool>(ChooseCamera);
            CancelConnectCameraCommand = new RelayCommand(CancelConnectCamera);
            DisconnectCommand          = new AsyncCommand <bool>(() => DisconnectDiag());
            CoolCamCommand             = new AsyncCommand <bool>(() => {
                _cancelChangeTemperatureCts?.Dispose();
                _cancelChangeTemperatureCts = new CancellationTokenSource();
                return(CoolCamera(TargetTemp, TimeSpan.FromMinutes(CoolingDuration), new Progress <ApplicationStatus>(p => Status = p), _cancelChangeTemperatureCts.Token));
            }, (object o) => !TempChangeRunning);
            WarmCamCommand = new AsyncCommand <bool>(() => {
                _cancelChangeTemperatureCts?.Dispose();
                _cancelChangeTemperatureCts = new CancellationTokenSource();
                return(WarmCamera(TimeSpan.FromMinutes(WarmingDuration), new Progress <ApplicationStatus>(p => Status = p), _cancelChangeTemperatureCts.Token));
            }, (object o) => !TempChangeRunning);
            CancelCoolCamCommand     = new RelayCommand(CancelCoolCamera);
            RefreshCameraListCommand = new RelayCommand(RefreshCameraList, o => !(Cam?.Connected == true));

            TempChangeRunning        = false;
            CoolerPowerHistory       = new AsyncObservableLimitedSizedStack <KeyValuePair <DateTime, double> >(100);
            CCDTemperatureHistory    = new AsyncObservableLimitedSizedStack <KeyValuePair <DateTime, double> >(100);
            ToggleDewHeaterOnCommand = new RelayCommand(ToggleDewHeaterOn);

            updateTimer = new DeviceUpdateTimer(
                GetCameraValues,
                UpdateCameraValues,
                profileService.ActiveProfile.ApplicationSettings.DevicePollingInterval
                );

            profileService.ProfileChanged += (object sender, EventArgs e) => {
                RefreshCameraList(null);
            };
        }
コード例 #16
0
        public PolarAlignmentVM(
            IProfileService profileService,
            ICameraMediator cameraMediator,
            ITelescopeMediator telescopeMediator,
            IImagingMediator imagingMediator,
            IApplicationStatusMediator applicationStatusMediator
            ) : base(profileService)
        {
            Title = "LblPolarAlignment";

            ImageGeometry = (System.Windows.Media.GeometryGroup)System.Windows.Application.Current.Resources["PolarAlignSVG"];

            this.cameraMediator = cameraMediator;
            this.cameraMediator.RegisterConsumer(this);

            this.imagingMediator = imagingMediator;

            this.telescopeMediator = telescopeMediator;
            this.telescopeMediator.RegisterConsumer(this);
            this.applicationStatusMediator = applicationStatusMediator;

            updateValues          = new DispatcherTimer();
            updateValues.Interval = TimeSpan.FromSeconds(10);
            updateValues.Tick    += UpdateValues_Tick;

            MeasureAzimuthErrorCommand = new AsyncCommand <bool>(
                () => MeasurePolarError(new Progress <ApplicationStatus>(p => AzimuthPolarErrorStatus = p), Direction.AZIMUTH),
                (p) => (TelescopeInfo?.Connected == true && CameraInfo?.Connected == true));
            MeasureAltitudeErrorCommand = new AsyncCommand <bool>(
                () => MeasurePolarError(new Progress <ApplicationStatus>(p => AltitudePolarErrorStatus = p), Direction.ALTITUDE),
                (p) => (TelescopeInfo?.Connected == true && CameraInfo?.Connected == true));
            SlewToAltitudeMeridianOffsetCommand = new AsyncCommand <bool>(
                () => SlewToMeridianOffset(AltitudeMeridianOffset, AltitudeDeclination),
                (p) => (TelescopeInfo?.Connected == true));
            SlewToAzimuthMeridianOffsetCommand = new AsyncCommand <bool>(
                () => SlewToMeridianOffset(AzimuthMeridianOffset, AzimuthDeclination),
                (p) => (TelescopeInfo?.Connected == true));
            DARVSlewCommand = new AsyncCommand <bool>(
                () => Darvslew(new Progress <ApplicationStatus>(p => Status = p), new Progress <string>(p => DarvStatus = p)),
                (p) => (TelescopeInfo?.Connected == true && CameraInfo?.Connected == true));
            CancelDARVSlewCommand = new RelayCommand(
                Canceldarvslew,
                (p) => cancelDARVSlewToken != null);
            CancelMeasureAltitudeErrorCommand = new RelayCommand(
                CancelMeasurePolarError,
                (p) => cancelMeasureErrorToken != null);
            CancelMeasureAzimuthErrorCommand = new RelayCommand(
                CancelMeasurePolarError,
                (p) => cancelMeasureErrorToken != null);

            DARVSlewDuration     = 60;
            DARVSlewRate         = 0.01;
            SnapExposureDuration = 2;

            profileService.ProfileChanged += (object sender, EventArgs e) => {
                RaisePropertyChanged(nameof(AzimuthMeridianOffset));
                RaisePropertyChanged(nameof(AzimuthDeclination));
                RaisePropertyChanged(nameof(AltitudeMeridianOffset));
                RaisePropertyChanged(nameof(AltitudeDeclination));
            };
        }
コード例 #17
0
        public RotatorVM(IProfileService profileService, IRotatorMediator rotatorMediator, IApplicationStatusMediator applicationStatusMediator) : base(profileService)
        {
            Title         = "LblRotator";
            ImageGeometry = (System.Windows.Media.GeometryGroup)System.Windows.Application.Current.Resources["RotatorSVG"];

            this.rotatorMediator = rotatorMediator;
            this.rotatorMediator.RegisterHandler(this);
            this.applicationStatusMediator = applicationStatusMediator;

            ConnectCommand            = new AsyncCommand <bool>(() => Connect());
            CancelConnectCommand      = new RelayCommand(CancelConnectRotator);
            DisconnectCommand         = new AsyncCommand <bool>(() => DisconnectDiag());
            RefreshRotatorListCommand = new RelayCommand(RefreshRotatorList, o => !(rotator?.Connected == true));
            MoveCommand           = new AsyncCommand <float>(() => Move(TargetPosition), (p) => RotatorInfo.Connected && RotatorInfo.Synced);
            MoveMechanicalCommand = new AsyncCommand <float>(() => MoveMechanical(TargetPosition), (p) => RotatorInfo.Connected);
            HaltCommand           = new RelayCommand(Halt);
            ReverseCommand        = new RelayCommand(Reverse);

            updateTimer = new DeviceUpdateTimer(
                GetRotatorValues,
                UpdateRotatorValues,
                profileService.ActiveProfile.ApplicationSettings.DevicePollingInterval
                );

            profileService.ProfileChanged += (object sender, EventArgs e) => {
                RefreshRotatorList(null);
            };
        }
コード例 #18
0
ファイル: GuiderVM.cs プロジェクト: daleghent/NINA
        public GuiderVM(IProfileService profileService, IGuiderMediator guiderMediator, ICameraMediator cameraMediator, IApplicationStatusMediator applicationStatusMediator, ITelescopeMediator telescopeMediator) : base(profileService)
        {
            Title         = "LblGuider";
            ImageGeometry = (System.Windows.Media.GeometryGroup)System.Windows.Application.Current.Resources["GuiderSVG"];

            this.guiderMediator = guiderMediator;
            this.guiderMediator.RegisterHandler(this);

            this.applicationStatusMediator = applicationStatusMediator;

            ConnectGuiderCommand = new AsyncCommand <bool>(Connect);

            CancelConnectGuiderCommand = new RelayCommand(CancelConnectGuider);

            GuiderChooserVM = new GuiderChooserVM(profileService, cameraMediator, telescopeMediator);

            DisconnectGuiderCommand = new RelayCommand((object o) => Disconnect(), (object o) => Guider?.Connected == true);
            ClearGraphCommand       = new RelayCommand((object o) => ResetGraphValues());

            GuideStepsHistory = new GuideStepsHistory(HistorySize, GuiderScale, GuiderMaxY);

            profileService.ProfileChanged += (object sender, EventArgs e) => {
                GuiderChooserVM.GetEquipment();
            };
        }