예제 #1
0
        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";
        }
예제 #2
0
        public FocusTargetsVM(IProfileService profileService, ITelescopeMediator telescopeMediator, IApplicationResourceDictionary resourceDictionary) : base(profileService)
        {
            Title         = "LblManualFocusTargets";
            ImageGeometry = (System.Windows.Media.GeometryGroup)resourceDictionary["FocusTargetsSVG"];

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

            AsyncContext.Run(LoadFocusTargets);

            updateTimer = new Timer(TimeSpan.FromMinutes(1).TotalMilliseconds)
            {
                AutoReset = true
            };
            updateTimer.Elapsed += (sender, args) => CalculateVisibleStars();
            if (IsVisible)
            {
                updateTimer.Start();
            }

            SlewToCoordinatesCommand = new AsyncCommand <bool>(async() => await telescopeMediator.SlewToCoordinatesAsync(SelectedFocusTarget.Coordinates));
        }