Example #1
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);
            };
        }
Example #2
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);
            };
        }
Example #3
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();
        }
Example #4
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);
            });
        }
Example #5
0
        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);
            };
        }
Example #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);
        }
Example #7
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);
            });
        }