/// <summary> /// Update the DMG PlotModel with the latest data. /// </summary> private void DisplayDmgPlogExecute() { try { // Process the all the data in the buffer while (!_DmgPlotBuffer.IsEmpty) { // Set the flag _isProcessDmgPlot = true; // Remove the data from the buffer DmgPlotData prt = null; if (_DmgPlotBuffer.TryDequeue(out prt)) { // Lock the plot for an update lock (Plot.SyncRoot) { if (prt != null) { // GPS // Verify points exist if (prt.GpsLs.Points.Count > 0) { _plot.Series[0] = prt.GpsLs; } // Bottom Track Earth // Verify points exist if (prt.BtEarthLs.Points.Count > 0) { _plot.Series[1] = prt.BtEarthLs; } } } // Display plot _plot.InvalidatePlot(true); } } // Reset the flag _isProcessDmgPlot = false; } catch (Exception e) { Debug.WriteLine(e.ToString()); log.Error("Error updating DMG plot.", e); } }
/// <summary> /// Add the Distance Made Good values to the plot. /// This will keep a list of the last MAX_DATASETS ranges /// and plot them. /// </summary> /// <param name="data">Get the latest data.</param> public async Task AddIncomingData(DmgPlotData data) { // Update the plot try { // Enqueue the data to the buffer _DmgPlotBuffer.Enqueue(data); if (!_isProcessDmgPlot) { //DisplayDmgPlotCommand.Execute(null); await Task.Run(() => DisplayDmgPlogExecute()); } } catch (Exception e) { // When shutting down, can get a null reference Debug.WriteLine(e.ToString()); } }