aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common
diff options
context:
space:
mode:
authorRoy <roy.mail.net@gmail.com>2018-02-14 22:51:52 +0200
committerRoy <roy.mail.net@gmail.com>2018-02-14 22:51:52 +0200
commitb934b152eea671fa06678baa0cdf7f8811e6d2d9 (patch)
tree35c092bff1e06905c70c23e60ed1a9fdf9825e5a /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common
parent12967bd645e92f7b08b8d323b93225e027ad69f0 (diff)
downloadTango-b934b152eea671fa06678baa0cdf7f8811e6d2d9.tar.gz
Tango-b934b152eea671fa06678baa0cdf7f8811e6d2d9.zip
MERGE.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common')
-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
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/BarItem.cs46
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs113
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Video/DefaultVideoCaptureProvider.cs44
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Video/IVideoCaptureProvider.cs21
6 files changed, 339 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);
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/BarItem.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/BarItem.cs
new file mode 100644
index 000000000..8d3cefa40
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/BarItem.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using Tango.Core;
+
+namespace Tango.MachineStudio.Common.Notifications
+{
+ public class BarItem : ExtendedObject, IDisposable
+ {
+ private INotificationProvider _notificationProvider;
+
+ public FrameworkElement Element { get; set; }
+
+ public BarItem(INotificationProvider notificationProvider)
+ {
+ _notificationProvider = notificationProvider;
+ }
+
+ /// <summary>
+ /// Removed this item from the queue.
+ /// </summary>
+ public void Pop()
+ {
+ _notificationProvider.PopBarItem(this);
+ }
+
+ /// <summary>
+ /// Pushes this item to the queue.
+ /// </summary>
+ public void Push()
+ {
+ _notificationProvider.PushBarItem(this);
+ }
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ public void Dispose()
+ {
+ Pop();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs
new file mode 100644
index 000000000..5c594ab70
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs
@@ -0,0 +1,113 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media.Imaging;
+using Tango.Integration.Observables;
+
+namespace Tango.MachineStudio.Common
+{
+ /// <summary>
+ /// Represents a base class for studio modules.
+ /// </summary>
+ /// <seealso cref="Tango.MachineStudio.Common.IStudioModule" />
+ public abstract class StudioModuleBase : IStudioModule
+ {
+ private bool _isInitialized;
+ private bool _isLoaded;
+
+ /// <summary>
+ /// Occurs when the user has navigated into or out of this module.
+ /// </summary>
+ public event EventHandler<bool> IsLoadedChanged;
+
+ /// <summary>
+ /// Gets the module name.
+ /// </summary>
+ public abstract string Name { get; }
+
+ /// <summary>
+ /// Gets the module description.
+ /// </summary>
+ public abstract string Description { get; }
+
+ /// <summary>
+ /// Gets the module cover image.
+ /// </summary>
+ public abstract BitmapSource Image { get; }
+
+ /// <summary>
+ /// Gets the module entry point view.
+ /// </summary>
+ public abstract FrameworkElement MainView { get; }
+
+ /// <summary>
+ /// Gets the permission required to see and load this module.
+ /// </summary>
+ public abstract Permissions Permission { get; }
+
+ /// <summary>
+ /// Gets a value indicating whether this module has been initialized.
+ /// </summary>
+ public bool IsInitialized
+ {
+ get
+ {
+ return _isInitialized;
+ }
+ private set
+ {
+ _isInitialized = value;
+ }
+ }
+
+ /// <summary>
+ /// Sets a value indicating whether this module is loaded.
+ /// </summary>
+ public bool IsLoaded
+ {
+ get
+ {
+ return _isLoaded;
+ }
+ set
+ {
+ _isLoaded = value;
+ IsLoadedChanged?.Invoke(this, value);
+ }
+ }
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ public abstract void Dispose();
+
+ /// <summary>
+ /// Perform any operations required to initialize this module.
+ /// </summary>
+ public void Initialize()
+ {
+ OnInitialized();
+ IsInitialized = true;
+ }
+
+ /// <summary>
+ /// Called when machine studio initializes this module.
+ /// </summary>
+ protected virtual void OnInitialized()
+ {
+
+ }
+
+ /// <summary>
+ /// Raises the <see cref="IsLoadedChanged"/> event.
+ /// </summary>
+ /// <param name="loaded">if set to <c>true</c> the module is loaded.</param>
+ protected virtual void OnLoadedChanged(bool loaded)
+ {
+
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Video/DefaultVideoCaptureProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Video/DefaultVideoCaptureProvider.cs
new file mode 100644
index 000000000..3aa9d4c88
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Video/DefaultVideoCaptureProvider.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Video.DirectCapture;
+
+namespace Tango.MachineStudio.Common.Video
+{
+ /// <summary>
+ /// Represents the default implementation of <see cref="IVideoCaptureProvider"/>.
+ /// </summary>
+ /// <seealso cref="Tango.MachineStudio.Common.Video.IVideoCaptureProvider" />
+ public class DefaultVideoCaptureProvider : IVideoCaptureProvider
+ {
+ /// <summary>
+ /// Gets the available capture devices.
+ /// </summary>
+ public ObservableCollection<CaptureDevice> AvailableCaptureDevices { get; private set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DefaultVideoCaptureProvider"/> class.
+ /// </summary>
+ public DefaultVideoCaptureProvider()
+ {
+ AvailableCaptureDevices = new ObservableCollection<CaptureDevice>();
+
+ var availableDevices = CaptureDevice.GetAvailableCaptureDevices();
+
+ for (int i = 0; i < 3; i++)
+ {
+ if (i > availableDevices.Count - 1)
+ {
+ AvailableCaptureDevices.Add(new CaptureDevice() { Device = null });
+ }
+ else
+ {
+ AvailableCaptureDevices.Add(new CaptureDevice() { Device = availableDevices[i] });
+ }
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Video/IVideoCaptureProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Video/IVideoCaptureProvider.cs
new file mode 100644
index 000000000..cd797dce2
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Video/IVideoCaptureProvider.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Video.DirectCapture;
+
+namespace Tango.MachineStudio.Common.Video
+{
+ /// <summary>
+ /// Represents a video capturing device provider.
+ /// </summary>
+ public interface IVideoCaptureProvider
+ {
+ /// <summary>
+ /// Gets the available capture devices.
+ /// </summary>
+ ObservableCollection<CaptureDevice> AvailableCaptureDevices { get; }
+ }
+}