aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Diagnostics
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-02-14 19:14:06 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-02-14 19:14:06 +0200
commitb7b277736c7e3ec9258915cdd5a54e7b33ba1123 (patch)
tree57e83d678e2221083b73a5289b506773868e1c63 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Diagnostics
parent2dfa224ed624075752defff77ef96961ec766bff (diff)
downloadTango-b7b277736c7e3ec9258915cdd5a54e7b33ba1123.tar.gz
Tango-b7b277736c7e3ec9258915cdd5a54e7b33ba1123.zip
Working on Data Capture Module.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Diagnostics')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Diagnostics/DefaultDiagnosticsFrameProvider.cs84
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Diagnostics/IDiagnosticsFrameProvider.cs31
2 files changed, 115 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Diagnostics/DefaultDiagnosticsFrameProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Diagnostics/DefaultDiagnosticsFrameProvider.cs
new file mode 100644
index 000000000..b77619ac2
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Diagnostics/DefaultDiagnosticsFrameProvider.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Integration.Operators;
+using Tango.MachineStudio.Common.StudioApplication;
+using Tango.PMR.Diagnostics;
+
+namespace Tango.MachineStudio.Common.Diagnostics
+{
+ /// <summary>
+ /// Represents the default diagnostics frame provider.
+ /// </summary>
+ /// <seealso cref="Tango.MachineStudio.Common.Diagnostics.IDiagnosticsFrameProvider" />
+ public class DefaultDiagnosticsFrameProvider : IDiagnosticsFrameProvider
+ {
+ /// <summary>
+ /// Disables the frame delivery from the current connected machine and enables the manual push frame method.
+ /// </summary>
+ public bool Disable { get; set; }
+
+ /// <summary>
+ /// Occurs when a new data frame is available.
+ /// </summary>
+ public event EventHandler<PushDiagnosticsResponse> FrameReceived;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DefaultDiagnosticsFrameProvider"/> class.
+ /// </summary>
+ /// <param name="applicationManager">The application manager.</param>
+ public DefaultDiagnosticsFrameProvider(IStudioApplicationManager applicationManager)
+ {
+ applicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged;
+ }
+
+ /// <summary>
+ /// Applications the manager connected machine changed.
+ /// </summary>
+ /// <param name="sender">The sender.</param>
+ /// <param name="machine">The machine.</param>
+ private void ApplicationManager_ConnectedMachineChanged(object sender, Integration.Services.IExternalBridgeClient machine)
+ {
+ if (machine != null)
+ {
+ (machine as MachineOperator).DiagnosticsDataAvailable += DefaultDiagnosticsFrameProvider_DiagnosticsDataAvailable;
+ }
+ }
+
+ /// <summary>
+ /// Defaults the diagnostics frame provider diagnostics data available.
+ /// </summary>
+ /// <param name="sender">The sender.</param>
+ /// <param name="frame">The frame.</param>
+ private void DefaultDiagnosticsFrameProvider_DiagnosticsDataAvailable(object sender, PushDiagnosticsResponse frame)
+ {
+ if (!Disable)
+ {
+ OnFrameReceived(frame);
+ }
+ }
+
+ /// <summary>
+ /// Push frames manual. (Only when Disable = true)
+ /// </summary>
+ /// <param name="frame">The frame.</param>
+ public void PushFrame(PushDiagnosticsResponse frame)
+ {
+ if (Disable)
+ {
+ OnFrameReceived(frame);
+ }
+ }
+
+ /// <summary>
+ /// Raises the <see cref="FrameReceived"/> event.
+ /// </summary>
+ /// <param name="frame">The frame.</param>
+ protected virtual void OnFrameReceived(PushDiagnosticsResponse frame)
+ {
+ FrameReceived?.Invoke(this, frame);
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Diagnostics/IDiagnosticsFrameProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Diagnostics/IDiagnosticsFrameProvider.cs
new file mode 100644
index 000000000..0d63b59b6
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Diagnostics/IDiagnosticsFrameProvider.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.PMR.Diagnostics;
+
+namespace Tango.MachineStudio.Common.Diagnostics
+{
+ /// <summary>
+ /// Represents a tango machine diagnostics frame provider.
+ /// </summary>
+ public interface IDiagnosticsFrameProvider
+ {
+ /// <summary>
+ /// Occurs when a new data frame is available.
+ /// </summary>
+ event EventHandler<PushDiagnosticsResponse> FrameReceived;
+
+ /// <summary>
+ /// Disables the frame delivery from the current connected machine and enables the manual push frame method.
+ /// </summary>
+ bool Disable { get; set; }
+
+ /// <summary>
+ /// Push frames manual. (Only when Disable = true)
+ /// </summary>
+ /// <param name="frame">The frame.</param>
+ void PushFrame(PushDiagnosticsResponse frame);
+ }
+}