aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-12 17:15:11 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-12 17:15:11 +0200
commit755f37e3e3e553a91dd2c5a7f0ddad8359287a3b (patch)
tree0f9fe447c75a86ff4b647df31bf49b64dd12ee42 /Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs
parente774f9a90fd812a9de8c3efe966a759bee8be703 (diff)
downloadTango-755f37e3e3e553a91dd2c5a7f0ddad8359287a3b.tar.gz
Tango-755f37e3e3e553a91dd2c5a7f0ddad8359287a3b.zip
Working on FSE/PPC monitoring/system info.
Diffstat (limited to 'Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs')
-rw-r--r--Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs114
1 files changed, 98 insertions, 16 deletions
diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs
index 328f0736e..1b452df57 100644
--- a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs
+++ b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs
@@ -47,6 +47,8 @@ namespace RealTimeGraphX
public int RenderedItems { get; set; }
public bool IsClearSeries { get; set; }
+
+ public bool IsUpdateSeries { get; set; }
}
#endregion
@@ -113,8 +115,10 @@ namespace RealTimeGraphX
get { return _surface; }
set
{
+ var previous = _surface;
_surface = value;
RequestVirtualRangeChange();
+ OnSurfaceChanged(previous, _surface);
}
}
@@ -227,11 +231,8 @@ namespace RealTimeGraphX
{
List<List<PendingSeries>> pending_lists = new List<List<PendingSeries>>();
- if (_pending_series_collection.Count == 0)
- {
- Thread.Sleep(TimeSpan.FromSeconds(1));
- continue;
- }
+ var pending_list_first = _pending_series_collection.BlockDequeue();
+ pending_lists.Add(pending_list_first);
while (_pending_series_collection.Count > 0)
{
@@ -247,24 +248,24 @@ namespace RealTimeGraphX
{
_pending_series_collection = new GraphDataQueue<List<PendingSeries>>();
_to_render.Clear();
- break;
}
-
- if (_to_render.ContainsKey(pending_series.Series))
+ else if (!pending_series.IsUpdateSeries)
{
- var s = _to_render[pending_series.Series];
- s.XX.AddRange(pending_series.XX);
- s.YY.AddRange(pending_series.YY);
- }
- else
- {
- _to_render[pending_series.Series] = pending_series;
+ if (_to_render.ContainsKey(pending_series.Series))
+ {
+ var s = _to_render[pending_series.Series];
+ s.XX.AddRange(pending_series.XX);
+ s.YY.AddRange(pending_series.YY);
+ }
+ else
+ {
+ _to_render[pending_series.Series] = pending_series;
+ }
}
}
}
if (_to_render.Count > 0)
- //if (DateTime.Now > _last_render_time.AddMilliseconds(RefreshRate.TotalMilliseconds) && _to_render.Count > 0)
{
GraphDataPoint min_x = _range.MaximumX - _range.MaximumX;
GraphDataPoint max_x = _range.MaximumX;
@@ -346,6 +347,11 @@ namespace RealTimeGraphX
foreach (var item in to_render)
{
+ if (item.YY.Count > 0)
+ {
+ item.Series.CurrentValue = item.YY.Last().GetValue();
+ }
+
var points = Renderer.Render(Surface, item.Series, _range, item.XX, item.YY, min_x, max_x, min_y, max_y);
to_draw.Add(new Tuple<TDataSeries, IEnumerable<PointF>>(item.Series, points));
}
@@ -385,6 +391,26 @@ namespace RealTimeGraphX
#region Protected Methods
/// <summary>
+ /// Called when the surface has changed.
+ /// </summary>
+ /// <param name="previous">The previous.</param>
+ /// <param name="surface">The surface.</param>
+ protected virtual void OnSurfaceChanged(IGraphSurface<TDataSeries> previous, IGraphSurface<TDataSeries> surface)
+ {
+ if (previous != null)
+ {
+ previous.SurfaceSizeChanged += Surface_SurfaceSizeChanged;
+ previous.ZoomRectChanged += Surface_ZoomRectChanged;
+ }
+
+ if (surface != null)
+ {
+ surface.SurfaceSizeChanged += Surface_SurfaceSizeChanged;
+ surface.ZoomRectChanged += Surface_ZoomRectChanged;
+ }
+ }
+
+ /// <summary>
/// Raises the <see cref="EffectiveRangeChanged"/> event.
/// </summary>
/// <param name="minimumX">The minimum x.</param>
@@ -431,6 +457,62 @@ namespace RealTimeGraphX
#endregion
+ #region Surface Event Handlers
+
+ /// <summary>
+ /// Handles the ZoomRectChanged event of the Surface control.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
+ private void Surface_ZoomRectChanged(object sender, EventArgs e)
+ {
+ if (!_pending_series_collection.ToList().SelectMany(x => x).ToList().Exists(x => x.IsUpdateSeries))
+ {
+ List<PendingSeries> updateSeries = new List<PendingSeries>();
+
+ foreach (var pending_Series in _to_render)
+ {
+ updateSeries.Add(new PendingSeries()
+ {
+ IsUpdateSeries = true,
+ Series = pending_Series.Value.Series,
+ XX = new List<GraphDataPoint>(),
+ YY = new List<GraphDataPoint>(),
+ });
+ }
+
+ _pending_series_collection.BlockEnqueue(updateSeries);
+ }
+ }
+
+ /// <summary>
+ /// Handles the SurfaceSizeChanged event of the Surface control.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
+ private void Surface_SurfaceSizeChanged(object sender, EventArgs e)
+ {
+ if (!_pending_series_collection.ToList().SelectMany(x => x).ToList().Exists(x => x.IsUpdateSeries))
+ {
+ List<PendingSeries> updateSeries = new List<PendingSeries>();
+
+ foreach (var pending_Series in _to_render)
+ {
+ updateSeries.Add(new PendingSeries()
+ {
+ IsUpdateSeries = true,
+ Series = pending_Series.Value.Series,
+ XX = new List<GraphDataPoint>(),
+ YY = new List<GraphDataPoint>(),
+ });
+ }
+
+ _pending_series_collection.BlockEnqueue(updateSeries);
+ }
+ }
+
+ #endregion
+
#region Public Methods
/// <summary>