public DiagnosticsViewModel(SubsystemDataConfig config) : base("DiagnosticsViewModel") { // Set Subsystem _Config = config; _pm = IoC.Get <PulseManager>(); _pm.RegisterDisplayVM(this); // Get the Event Aggregator _events = IoC.Get <IEventAggregator>(); _isProcessingBuffer = false; _buffer = new ConcurrentQueue <DataSet.Ensemble>(); _ensemble = new DataSet.Ensemble(); // Close the VM CloseVMCommand = ReactiveCommand.Create(); CloseVMCommand.Subscribe(_ => _events.PublishOnUIThread(new CloseVmEvent(_Config))); // Update the display _displayTimer = new System.Timers.Timer(250); _displayTimer.Elapsed += _displayTimer_Elapsed; _displayTimer.AutoReset = true; _displayTimer.Enabled = true; _displayTimer.Start(); Init(); _events.Subscribe(this); }
/// <summary> /// Initialize the view model with the configuration. /// </summary> /// <param name="config">Subsystem Configuration.</param> public ScreenDataViewModel(SubsystemDataConfig config) : base("ScreenDataViewModel") { _Config = config; _pm = IoC.Get <PulseManager>(); TabDesc = config.IndexCodeString(); // Get the Event Aggregator _events = IoC.Get <IEventAggregator>(); // Initialize previous values _prevBtEast = DataSet.Ensemble.BAD_VELOCITY; _prevBtNorth = DataSet.Ensemble.BAD_VELOCITY; _prevBtVert = DataSet.Ensemble.BAD_VELOCITY; _prevBtRange = DataSet.Ensemble.BAD_RANGE; _prevRangeTrackRange = DataSet.Ensemble.BAD_RANGE; _prevHeading = 0.0f; //SelectedHeadingSource = Transform.HeadingSource.ADCP; HeadingSourceList = Enum.GetValues(typeof(Transform.HeadingSource)).Cast <Transform.HeadingSource>().ToList(); // Initialize the options GetOptionsFromDatabase(); // Close the VM CloseVMCommand = ReactiveCommand.Create(); CloseVMCommand.Subscribe(_ => _events.PublishOnUIThread(new CloseVmEvent(_Config))); }
/// <summary> /// Initialize the view model. /// </summary> public ViewDataProfile3DViewModel(SubsystemDataConfig config) : base("3D Profile") { // Set Subsystem _Config = config; //_displayCounter = 0; // Get PulseManager _pm = IoC.Get <PulseManager>(); _pm.RegisterDisplayVM(this); // Get the Event Aggregator _events = IoC.Get <IEventAggregator>(); _buffer = new ConcurrentQueue <DataSet.Ensemble>(); // Initialize the thread _continue = true; _eventWaitData = new EventWaitHandle(false, EventResetMode.AutoReset); _processDataThread = new Thread(ProcessDataThread); _processDataThread.Name = string.Format("3D Profile Plot View: {0}", config.DescString()); _processDataThread.Start(); // Get the options from the database GetOptionsFromDatabase(); VelPlot = new Profile3DPlotViewModel(); // Close the VM CloseVMCommand = ReactiveCommand.Create(); CloseVMCommand.Subscribe(_ => _events.PublishOnUIThread(new CloseVmEvent(_Config))); // Register to receive data _events.Subscribe(this); }
/// <summary> /// Handle event when EnsembleEvent is received. /// This will create the displays for each config /// if it has not been created already. It will also /// display the latest ensemble. /// </summary> /// <param name="ensEvent">Ensemble event.</param> public override void Handle(EnsembleEvent ensEvent) { if (ensEvent.Ensemble != null && ensEvent.Ensemble.IsEnsembleAvail) { // Create the config var ssDataConfig = new SubsystemDataConfig(ensEvent.Ensemble.EnsembleData.SubsystemConfig, ensEvent.Source); if (!_validationTestVMDict.ContainsKey(ssDataConfig)) { Application.Current.Dispatcher.BeginInvoke(new System.Action(() => AddConfig(ssDataConfig))); } } // Check if record button was already pressed if (IsTesting != _adcpConn.IsValidationTestRecording) { IsTesting = _adcpConn.IsValidationTestRecording; } // Update timer if (!_adcpConn.IsRecording && // Not recording !_adcpConn.IsValidationTestRecording && // Not Validation test recording ensEvent.Source != EnsembleSource.Playback) // Not playing back data { _warningRecordTimer.Enabled = true; } else { _warningRecordTimer.Enabled = false; } }
/// <summary> /// Check if the given object is /// equal to this object. /// </summary> /// <param name="obj">Object to check.</param> /// <returns>If the codes are the same, then they are equal.</returns> public override bool Equals(object obj) { //Check for null and compare run-time types. if (obj == null || GetType() != obj.GetType()) { return(false); } SubsystemDataConfig p = (SubsystemDataConfig)obj; return(SubSystem == p.SubSystem && CepoIndex == p.CepoIndex && SubsystemConfigIndex == p.SubsystemConfigIndex && Source == p.Source); }
/// <summary> /// Handle event when EnsembleEvent is received. /// This will create the displays for each config /// if it has not been created already. It will also /// display the latest ensemble. /// </summary> /// <param name="ensEvent">Ensemble event.</param> public override void Handle(EnsembleEvent ensEvent) { if (ensEvent.Ensemble != null && ensEvent.Ensemble.IsEnsembleAvail) { // Create the config var ssDataConfig = new SubsystemDataConfig(ensEvent.Ensemble.EnsembleData.SubsystemConfig, ensEvent.Source); if (!_textVMDict.ContainsKey(ssDataConfig)) { Application.Current.Dispatcher.BeginInvoke(new System.Action(() => AddConfig(ssDataConfig))); } } }
/// <summary> /// Display the bulk ensemble event async. /// </summary> private void BulkEnsembleDisplayExecute(BulkEnsembleEvent ensEvent) { // Find all the configurations for (int x = 0; x < ensEvent.Ensembles.Count(); x++) { // There can only be 12 configurations if (x > 12) { break; } // Get the ensemble DataSet.Ensemble ens = ensEvent.Ensembles.IndexValue(x); // Verify the ensemble if (ens != null && ens.IsEnsembleAvail) { // Create the config var ssDataConfig = new SubsystemDataConfig(ens.EnsembleData.SubsystemConfig, ensEvent.Source); // Check if the config exist in the table if (!_validationTestVMDict.ContainsKey(ssDataConfig)) { Application.Current.Dispatcher.BeginInvoke(new System.Action(() => AddConfig(ssDataConfig))); } //Wait for the dispatcher to add the config // Monitor for any timeouts int timeout = 0; while (!_validationTestVMDict.ContainsKey(ssDataConfig)) { // Set a timeout and wait for the config timeout++; if (timeout > 10) { break; } System.Threading.Thread.Sleep(250); } //_events.PublishOnUIThread(new EnsembleEvent(ens, EnsembleSource.Playback)); } } // Pass the ensembles to the displays foreach (var vm in _validationTestVMDict.Values) { vm.DisplayBulkData(ensEvent.Ensembles); } }
/// <summary> /// Handle event when EnsembleEvent is received. /// This will create the displays for each config /// if it has not been created already. It will also /// display the latest ensemble. /// </summary> /// <param name="ensEvent">Ensemble event.</param> public override void Handle(EnsembleEvent ensEvent) { if (ensEvent.Ensemble != null && ensEvent.Ensemble.IsEnsembleAvail) { // Create the config var ssDataConfig = new SubsystemDataConfig(ensEvent.Ensemble.EnsembleData.SubsystemConfig, ensEvent.Source); // Don't add a STA or LTA config to average averaged data if (ensEvent.Source != EnsembleSource.STA && ensEvent.Source != EnsembleSource.LTA) { // Check if the config exist in the table if (!_averagingVMDict.ContainsKey(ssDataConfig)) { Application.Current.Dispatcher.BeginInvoke(new System.Action(() => AddConfig(ssDataConfig))); } } } }
/// <summary> /// Display the ensemble information. /// <param name="config">Configuration containing data source and SubsystemConfiguration.</param> /// </summary> public ViewDataTextEnsembleViewModel(SubsystemDataConfig config) : base("ViewDataTextEnsembleViewModel") { // Set Subsystem _Config = config; // Get PulseManager _pm = IoC.Get <PulseManager>(); _pm.RegisterDisplayVM(this); // Set GPS data default SetGpsDataDefault(); // Update the display _displayTimer = new System.Timers.Timer(500); _displayTimer.Elapsed += _displayTimer_Elapsed; _displayTimer.AutoReset = true; _displayTimer.Enabled = true; }
/// <summary> /// Add a configuration. This will create the ViewModel based /// off the configuration given. /// </summary> /// <param name="config">Configuration to use to create the ViewModel.</param> private void AddConfig(SubsystemDataConfig config) { if (!_backscatterVMDict.ContainsKey(config)) { if (_backscatterVMDict.TryAdd(config, new BackscatterViewModel(config))) { this.NotifyOfPropertyChange(() => this.BackscatterVMList); // Select a tab is nothing is selected if (_SelectedBackscatterVM == null) { if (BackscatterVMList.Count > 0) { SelectedBackscatterVM = BackscatterVMList[0]; } } } } }
/// <summary> /// Add a configuration. This will create the ViewModel based /// off the configuration given. /// </summary> /// <param name="config">Configuration to use to create the ViewModel.</param> private void AddConfig(SubsystemDataConfig config) { if (!_profile3DVMDict.ContainsKey(config)) { if (_profile3DVMDict.TryAdd(config, new ViewDataProfile3DViewModel(config))) { this.NotifyOfPropertyChange(() => this.Profile3DVMList); // Select a tab is nothing is selected if (_SelecteProfile3dVM == null) { if (Profile3DVMList.Count > 0) { SelecteProfile3DVM = Profile3DVMList[0]; } } } } }
/// <summary> /// Add a configuration. This will create the ViewModel based /// off the configuration given. /// </summary> /// <param name="config">Configuration to use to create the ViewModel.</param> private void AddConfig(SubsystemDataConfig config) { if (!_diagVMDict.ContainsKey(config)) { if (_diagVMDict.TryAdd(config, new DiagnosticsViewModel(config))) { this.NotifyOfPropertyChange(() => this.DiagVMList); // Select a tab is nothing is selected if (_SelectedDiagVM == null) { if (DiagVMList.Count > 0) { SelectedDiagVM = DiagVMList[0]; } } } } }
/// <summary> /// Add a configuration. This will create the ViewModel based /// off the configuration given. /// </summary> /// <param name="config">Configuration to use to create the ViewModel.</param> private void AddConfig(SubsystemDataConfig config) { if (!_graphicalVMDict.ContainsKey(config)) { if (_graphicalVMDict.TryAdd(config, new ViewDataGraphicalViewModel(config))) { this.NotifyOfPropertyChange(() => this.GraphicalVMList); // Select a tab is nothing is selected if (_SelectedGraphicalVM == null) { if (GraphicalVMList.Count > 0) { SelectedGraphicalVM = GraphicalVMList[0]; } } } } }
/// <summary> /// Add a configuration. This will create the ViewModel based /// off the configuration given. /// </summary> /// <param name="config">Configuration to use to create the ViewModel.</param> private void AddConfig(SubsystemDataConfig config) { if (!_validationTestVMDict.ContainsKey(config)) { if (_validationTestVMDict.TryAdd(config, new ValidationTestViewModel(config))) { this.NotifyOfPropertyChange(() => this.ValidationTestVMList); // Select a tab is nothing is selected if (SelectedValidationTestVM == null) { if (ValidationTestVMList.Count > 0) { SelectedValidationTestVM = ValidationTestVMList[0]; } } } } }
/// <summary> /// Add a configuration. This will create the ViewModel based /// off the configuration given. /// </summary> /// <param name="config">Configuration to use to create the ViewModel.</param> private void AddConfig(SubsystemDataConfig config) { // Do not screen the averaged data, it has already been averaged if (!_screenDataVMDict.ContainsKey(config) && config.Source != EnsembleSource.STA && config.Source != EnsembleSource.LTA) { if (_screenDataVMDict.TryAdd(config, new ScreenDataViewModel(config))) { this.NotifyOfPropertyChange(() => this.ScreenDataVMList); // Select a tab is nothing is selected if (_SelectedScreenDataVM == null) { if (ScreenDataVMList.Count > 0) { SelectedScreenDataVM = ScreenDataVMList[0]; } } } } }
/// <summary> /// Add a configuration. This will create the ViewModel based /// off the configuration given. /// </summary> /// <param name="config">Configuration to use to create the ViewModel.</param> private void AddConfig(SubsystemDataConfig config) { //_averagingVMTable.Add(config); //AveragingVMList.Add(new AveragingViewModel(config)); if (!_averagingVMDict.ContainsKey(config)) { if (_averagingVMDict.TryAdd(config, new AveragingViewModel(config))) { this.NotifyOfPropertyChange(() => this.AveragingVMList); // Select a tab is nothing is selected if (_SelectedAveragingVM == null) { if (AveragingVMList.Count > 0) { SelectedAveragingVM = AveragingVMList[0]; } } } } }
/// <summary> /// Initialize the view model. /// </summary> public BackscatterViewModel(SubsystemDataConfig config) : base("Backscatter") { // Set Subsystem _Config = config; //_displayCounter = 0; // Get PulseManager _pm = IoC.Get <PulseManager>(); _pm.RegisterDisplayVM(this); // Get the Event Aggregator _events = IoC.Get <IEventAggregator>(); _buffer = new ConcurrentQueue <DataSet.Ensemble>(); // Initialize the thread _continue = true; _eventWaitData = new EventWaitHandle(false, EventResetMode.AutoReset); _processDataThread = new Thread(ProcessDataThread); _processDataThread.Name = string.Format("Backscatter View: {0}", config.DescString()); _processDataThread.Start(); // Get the options from the database GetOptionsFromDatabase(); AmpltiduePlot = new HeatmapPlotViewModel(HeatmapPlotSeries.HeatmapPlotType.Amplitude, _options.AmplitudeSeriesOptions); AmpltiduePlot.AddSeries(_options.AmplitudeSeriesOptions); AmpltiduePlot.UpdateOptionsEvent += AmplitudeVelPlot_UpdateOptionsEvent; // Close the VM CloseVMCommand = ReactiveCommand.Create(); CloseVMCommand.Subscribe(_ => _events.PublishOnUIThread(new CloseVmEvent(_Config))); _events.Subscribe(this); }
/// <summary> /// Display the bulk ensemble event async. /// </summary> private void BulkEnsembleDisplayExecute() { while (_buffer.Count > 0) { _isProcessingBuffer = true; BulkEnsembleEvent ensEvent = null; if (_buffer.TryDequeue(out ensEvent)) { //// Set the maximum display for each VM //foreach (var vm in GraphicalVMList) //{ // vm.ClearPlots(); // vm.DisplayMaxEnsembles = ensEvent.Ensembles.Count(); //} // Look for all the configurations // 12 is maximum configurations if (ensEvent.Ensembles.Count() > 0) { for (int x = 0; x < ensEvent.Ensembles.Count(); x++) { // Check 12 ensembles, because there can be up to 12 different configurations if (x > 12) { break; } var ensemble = ensEvent.Ensembles.IndexValue(x); // Verify the ensemble if (ensemble != null && ensemble.IsEnsembleAvail) { // Create the config var ssDataConfig = new SubsystemDataConfig(ensemble.EnsembleData.SubsystemConfig, ensEvent.Source); // Check if the config exist in the table if (!_graphicalVMDict.ContainsKey(ssDataConfig)) { Application.Current.Dispatcher.BeginInvoke(new System.Action(() => AddConfig(ssDataConfig))); } //Wait for the dispatcher to add the config // Monitor for any timeouts int timeout = 0; while (!_graphicalVMDict.ContainsKey(ssDataConfig)) { // Set a timeout and wait for the config timeout++; if (timeout > 10) { break; } System.Threading.Thread.Sleep(250); } } } // Get the number of ensembles and use it to set the max display int maxEnsembles = 0; if (_pm.IsProjectSelected) { maxEnsembles = _pm.SelectedProject.GetNumberOfEnsembles(); } // Pass the ensembles to the displays foreach (var vm in _graphicalVMDict.Values) { vm.DisplayBulkData(ensEvent.Ensembles, maxEnsembles); } } } } _isProcessingBuffer = false; }
/// <summary> /// Calculate all the data at once. /// </summary> /// <param name="cache"></param> public void Calculate(Cache <long, DataSet.Ensemble> cache, Subsystem subsystem, SubsystemDataConfig ssConfig) { for (int x = 0; x < cache.Count(); x++) { DataSet.Ensemble ensemble = cache.Get(x); if (ensemble != null) { // Verify the subsystem matches this viewmodel's subystem. if ((subsystem == ensemble.EnsembleData.GetSubSystem()) && // Check if Subsystem matches (ssConfig == ensemble.EnsembleData.SubsystemConfig)) // Check if Subsystem Config matches { AccumulateData(ensemble); } } } }