/// <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> /// 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); }