/// <summary>
        /// Initialize the object.
        /// </summary>
        public PlaybackViewModel()
            : base("PlaybackViewModel")
        {
            // Get Project Manager
            _pm     = IoC.Get <PulseManager>();
            _events = IoC.Get <IEventAggregator>();
            _events.Subscribe(this);
            _adcpConn = IoC.Get <AdcpConnection>();

            _buffer = new ConcurrentQueue <PlaybackArgs>();

            IsAdmin = Pulse.Commons.IsAdmin();

            // Get ScreenData VM
            _screenDataVM = IoC.Get <ScreenDataBaseViewModel>();

            // Get Averaging VM
            _averagingVM = IoC.Get <AveragingBaseViewModel>();

            // Set the record image
            SetRecorderImage();

            // Initialize the total number of ensembles
            CurrentFileSize = MathHelper.MemorySizeString(0);

            PlaybackSpeed = DEFAULT_PLAYBACK_SPEED;
            PlaybackIndex = DEFAULT_PLAYBACK_INDEX;
            SetPlaybackSpeedIndicatorImage();

            // Timer to move the slider
            _timer              = new Timer();
            _timer.AutoReset    = true;
            _timer.Interval     = _PlaybackSpeed;
            _timer.Elapsed     += new ElapsedEventHandler(On_TimerElapsed);
            IsLooping           = false;
            IsLoading           = false;
            _isProcessingBuffer = false;

            // Recorder Timer
            _recorderTimer           = new Timer();
            _recorderTimer.AutoReset = true;
            _recorderTimer.Interval  = 2000;
            _recorderTimer.Elapsed  += new ElapsedEventHandler(On_recorderTimerElapsed);
            _recorderTimer.Start();

            // Command to set recording on or off
            RecordCommand = ReactiveCommand.Create();
            RecordCommand.Subscribe(_ => { IsRecordEnabled = !IsRecordEnabled; });

            // Command to begin playing back data
            PlayCommand = ReactiveCommand.Create();                          // Start the playback
            PlayCommand.Subscribe(_ => PlaybackCommandExecute());

            // Command to move the ensemble forward
            StepEnsembleFowardCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => StepEnsembleForward()));

            // Command to move the ensemble backward
            StepEnsembleBackwardCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => StepEnsembleBackward()));

            // Command to increase playback speed
            // Reduce the timer interval
            IncreaseSpeedCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => IncreasePlaybackSpeedCommandExec()));

            // Command to decrease playback speed
            // Reduce the timer interval
            DecreaseSpeedCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => DecreasePlaybackSpeedCommandExec()));

            // Blink Record image in background
            BlinkRecordImageCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => BlinkRecordImage()));

            // Command to display all the data in the project
            DisplayAllDataCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => DisplayAllData()));
        }
        /// <summary>
        /// Initialize the values.
        /// </summary>
        public ExportDataViewModel()
            : base("ExportViewModel")
        {
            // Initialize values
            _pm = IoC.Get <PulseManager>();
            _eventAggregator = IoC.Get <IEventAggregator>();
            _eventAggregator.Subscribe(this);
            _screenDataVM = IoC.Get <ScreenDataBaseViewModel>();                 // Get ScreenData VM

            IsExporting = false;

            _numEns = 0;
            if (_pm.IsProjectSelected)
            {
                ProjectName = _pm.SelectedProject.ProjectName;
                _numEns     = _pm.SelectedProject.GetNumberOfEnsembles();
            }

            // Bins
            MinimumBin = 0;
            if (_pm.IsProjectSelected && _numEns > 0)
            {
                MaximumBin = _pm.SelectedProject.GetFirstEnsemble().EnsembleData.NumBins - 1;
            }
            else
            {
                MaximumBin = DataSet.Ensemble.MAX_NUM_BINS;
            }

            // Ensemble Numbers
            MinEnsembleNumberEntry = 0;
            if (_pm.IsProjectSelected)
            {
                MaxEnsembleNumberEntry = (uint)_numEns - 1;
            }
            else
            {
                MaxEnsembleNumberEntry = 0;
            }

            // Coordinate Transform list
            CoordinateTransformList = new List <string>();
            CoordinateTransformList.Add(XFORM_BEAM);
            CoordinateTransformList.Add(XFORM_INSTRUMENT);
            CoordinateTransformList.Add(XFORM_EARTH);

            // Set the options
            _Options = _pm.AppConfiguration.GetExportDataOptions();
            UpdateProperties();

            // Check if options are set
            CheckOptions();

            // Export to CSV Command
            ExportCsvCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x._numEns, x => x.Value > 0),
                                                               _ => ExportCsv());              // Load if there are ensembles in the project

            // Export to Matlab command
            ExportMatlabCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x._numEns, x => x.Value > 0),
                                                                  _ => ExportMatlab());        // Load if there are ensembles in the project

            // Export to PD0 command
            ExportPd0Command = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x._numEns, x => x.Value > 0),
                                                               _ => ExportPd0());              // Load if there are ensembles in the project

            // Export to ENS command
            ExportEnsCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x._numEns, x => x.Value > 0),
                                                               _ => ExportEns());              // Load if there are ensembles in the project
        }
Beispiel #3
0
        /// <summary>
        /// Shutdown the view model.
        /// </summary>
        /// <param name="close"></param>
        void IDeactivate.Deactivate(bool close)
        {
            // Shutdown the pulse manager
            PulseManager pm = IoC.Get <PulseManager>();

            if (pm != null)
            {
                pm.Dispose();
            }

            // Shutdown the singleton HomeViewModels
            HomeViewModel homeVM = IoC.Get <HomeViewModel>();

            if (homeVM != null)
            {
                homeVM.Dispose();
            }

            // Shutdown the singleton ViewDataBaseViewModel
            ViewDataBaseViewModel viewDataVM = IoC.Get <ViewDataBaseViewModel>();

            if (viewDataVM != null)
            {
                viewDataVM.Dispose();
            }

            // Shutdown the singleton PlaybackViewModel
            PlaybackViewModel playbackVM = IoC.Get <PlaybackViewModel>();

            if (playbackVM != null)
            {
                playbackVM.Dispose();
            }

            // Shutdown the singleton ValidationTestViewModel
            ValidationTestViewModel vtVM = IoC.Get <ValidationTestViewModel>();

            if (vtVM != null)
            {
                vtVM.Dispose();
            }

            // Shutdown the singleton CompassCalViewModel
            CompassCalViewModel ccVM = IoC.Get <CompassCalViewModel>();

            if (ccVM != null)
            {
                ccVM.Dispose();
            }

            // Shutdown the singleton ViewDataBaseGraphicalViewModel
            ViewDataBaseGraphicalViewModel vdGraph = IoC.Get <ViewDataBaseGraphicalViewModel>();

            if (vdGraph != null)
            {
                vdGraph.Dispose();
            }

            // Shutdown the singleton ViewDataBaseTextViewModel
            ViewDataBaseTextViewModel vdText = IoC.Get <ViewDataBaseTextViewModel>();

            if (vdText != null)
            {
                vdText.Dispose();
            }

            // Shutdown the singleton ScreenDataBaseViewModel
            ScreenDataBaseViewModel sdVM = IoC.Get <ScreenDataBaseViewModel>();

            if (sdVM != null)
            {
                sdVM.Dispose();
            }

            // Shutdown the singleton AveragingBaseViewModel
            AveragingBaseViewModel abVM = IoC.Get <AveragingBaseViewModel>();

            if (abVM != null)
            {
                abVM.Dispose();
            }

            // Shutdown the singleton ValidationTestBaseViewModel
            ValidationTestBaseViewModel vtbVM = IoC.Get <ValidationTestBaseViewModel>();

            if (vtbVM != null)
            {
                vtbVM.Dispose();
            }

            // Shutdown the singleton DownloadDataViewModel
            DownloadDataViewModel ddVM = IoC.Get <DownloadDataViewModel>();

            if (ddVM != null)
            {
                ddVM.Dispose();
            }

            // Shutdown the singleton UpdateFirmwareViewModel
            UpdateFirmwareViewModel ufVM = IoC.Get <UpdateFirmwareViewModel>();

            if (ufVM != null)
            {
                ufVM.Dispose();
            }

            // Shutdown the singleton CompassUtilityViewModel
            CompassUtilityViewModel cuVM = IoC.Get <CompassUtilityViewModel>();

            if (cuVM != null)
            {
                cuVM.Dispose();
            }

            // Shutdown the singleton RtiCompassCalViewModel
            RtiCompassCalViewModel rtiCcVM = IoC.Get <RtiCompassCalViewModel>();

            if (rtiCcVM != null)
            {
                rtiCcVM.Dispose();
            }

            //// Shutdown the singleton TerminalViewModel
            //TerminalViewModel termVM = IoC.Get<TerminalViewModel>();
            //if (termVM != null)
            //{
            //    termVM.Dispose();
            //}

            //// Shutdown the singleton TerminalAdcpViewModel
            //TerminalAdcpViewModel tadcpVM = IoC.Get<TerminalAdcpViewModel>();
            //if (tadcpVM != null)
            //{
            //    tadcpVM.Dispose();
            //}

            //// Shutdown the singleton TerminalNavViewModel
            //TerminalNavViewModel tnavVM = IoC.Get<TerminalNavViewModel>();
            //if (tnavVM != null)
            //{
            //    tnavVM.Dispose();
            //}

            // Shutdown the singleton AboutViewModel
            AboutViewModel aboutVM = IoC.Get <AboutViewModel>();

            if (aboutVM != null)
            {
                aboutVM.Dispose();
            }

            // Shutdown the singleton VesselMountViewModel
            VesselMountViewModel vmVM = IoC.Get <VesselMountViewModel>();

            if (vmVM != null)
            {
                vmVM.Dispose();
            }

            // Shutdown the singleton VesselMountViewModel
            DataOutputViewModel vmDO = IoC.Get <DataOutputViewModel>();

            if (vmDO != null)
            {
                vmDO.Dispose();
            }

            // Shutdown the singleton VesselMountViewModel
            WpMagDirOutputViewModel vmWMD = IoC.Get <WpMagDirOutputViewModel>();

            if (vmWMD != null)
            {
                vmWMD.Dispose();
            }

            // Shutdown the last active item
            DeactivateItem(ActiveItem, true);

            // MAKE THIS THE LAST THING TO SHUTDOWN
            // Shutdown the ADCP connection
            AdcpConnection adcp = IoC.Get <AdcpConnection>();

            if (adcp != null)
            {
                adcp.Dispose();
            }

            // Shutdown the applicaton and all the threads
            Environment.Exit(Environment.ExitCode);
        }