aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-09-10 20:53:53 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-09-10 20:53:53 +0300
commita133762c08f1bb5c413ae3baa553b7b8d99cd4f3 (patch)
tree2410f1fc716b7273957e4498d634dc72273648cd /Software/Visual_Studio/MachineStudio
parente318068258baf07b4d1d70725a5c35232aee8547 (diff)
downloadTango-a133762c08f1bb5c413ae3baa553b7b8d99cd4f3.tar.gz
Tango-a133762c08f1bb5c413ae3baa553b7b8d99cd4f3.zip
Implemented Machine Studio TechBoard frames processing via concurrent queue to prevent thread collision.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs24
1 files changed, 22 insertions, 2 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
index 4205e5246..8f5c67f96 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
@@ -41,6 +41,7 @@ using RealTimeGraphX.WPF;
using Tango.Core.ExtensionMethods;
using System.Diagnostics;
using Tango.BL.Builders;
+using Tango.Core;
namespace Tango.MachineStudio.Technician.ViewModels
{
@@ -83,6 +84,9 @@ namespace Tango.MachineStudio.Technician.ViewModels
private DateTime _diagnosticsStartTime;
private DateTime _diagnosticsNowTime;
+ private ProducerConsumerQueue<StartDiagnosticsResponse> _framesQueue;
+ private Thread _populateFramesThread;
+
#region Properties
private ObservableCollection<MachineTechTabVM> _tabs;
@@ -314,6 +318,8 @@ namespace Tango.MachineStudio.Technician.ViewModels
/// <param name="notificationProvider">The notification provider.</param>
public MachineTechViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IEventLogger eventLogger)
{
+ _framesQueue = new ProducerConsumerQueue<StartDiagnosticsResponse>();
+
Tabs = new ObservableCollection<MachineTechTabVM>();
Tabs.Add(new MachineTechTabVM() { IsSelected = true, Name = "Untitled" });
SelectedTab = Tabs.First();
@@ -448,13 +454,22 @@ namespace Tango.MachineStudio.Technician.ViewModels
/// <param name="response">The response.</param>
private void DiagnosticsFrameProvider_FrameReceived(object sender, StartDiagnosticsResponse response)
{
- PopulateDiagnosticsData(response);
+ _framesQueue.BlockEnqueue(response);
}
#endregion
#region Populate Diagnostics Data
+ private void PopulateFramesThreadMethod()
+ {
+ while (!ApplicationManager.IsShuttingDown)
+ {
+ var frame = _framesQueue.BlockDequeue();
+ PopulateDiagnosticsData(frame);
+ }
+ }
+
/// <summary>
/// Populates the diagnostics data to the proper elements.
/// </summary>
@@ -2308,7 +2323,12 @@ namespace Tango.MachineStudio.Technician.ViewModels
public override void OnApplicationReady()
{
-
+ if (_populateFramesThread == null)
+ {
+ _populateFramesThread = new Thread(PopulateFramesThreadMethod);
+ _populateFramesThread.IsBackground = true;
+ _populateFramesThread.Start();
+ }
}
#endregion