Example #1
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 #2
0
 private void RefreshCameraList(object obj)
 {
     CameraChooserVM.GetEquipment();
 }