diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-14 19:14:06 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-14 19:14:06 +0200 |
| commit | b7b277736c7e3ec9258915cdd5a54e7b33ba1123 (patch) | |
| tree | 57e83d678e2221083b73a5289b506773868e1c63 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common | |
| parent | 2dfa224ed624075752defff77ef96961ec766bff (diff) | |
| download | Tango-b7b277736c7e3ec9258915cdd5a54e7b33ba1123.tar.gz Tango-b7b277736c7e3ec9258915cdd5a54e7b33ba1123.zip | |
Working on Data Capture Module.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common')
6 files changed, 212 insertions, 1 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/Notifications/INotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs index 8161ce885..e1b6275bd 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs @@ -21,6 +21,11 @@ namespace Tango.MachineStudio.Common.Notifications ObservableCollection<TaskItem> TaskItems { get; } /// <summary> + /// Gets the collection of active bar items. + /// </summary> + ObservableCollection<BarItem> BarItems { get; } + + /// <summary> /// Gets the current displayed task item. /// </summary> TaskItem CurrentTaskItem { get; } @@ -44,12 +49,32 @@ namespace Tango.MachineStudio.Common.Notifications TaskItem PushTaskItem(String message); /// <summary> + /// Creates and push a new bar item from the specified framework element. + /// </summary> + /// <param name="element">The element.</param> + /// <returns></returns> + BarItem PushBarItem(FrameworkElement element); + + /// <summary> + /// Pushes the specified bar item. + /// </summary> + /// <param name="barItem">The bar item.</param> + /// <returns></returns> + BarItem PushBarItem(BarItem barItem); + + /// <summary> /// Removed the specified task item from the queue. /// </summary> /// <param name="taskItem">The task item.</param> void PopTaskItem(TaskItem taskItem); /// <summary> + /// Removed the specified bar item. + /// </summary> + /// <param name="barItem">The bar item.</param> + void PopBarItem(BarItem barItem); + + /// <summary> /// Creates a new instance of the specified View type and displays it as a modal dialog. /// </summary> /// <typeparam name="View">The type of the view.</typeparam> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index 20079ff68..ba4fbab84 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -83,7 +83,10 @@ </Compile> <Compile Include="Controls\TableGrid.cs" /> <Compile Include="Converters\SecondsToGraphPointsConverter.cs" /> + <Compile Include="Diagnostics\DefaultDiagnosticsFrameProvider.cs" /> + <Compile Include="Diagnostics\IDiagnosticsFrameProvider.cs" /> <Compile Include="Helpers\GraphsHelper.cs" /> + <Compile Include="Notifications\BarItem.cs" /> <Compile Include="Notifications\DialogViewVM.cs" /> <Compile Include="StudioApplication\IModuleRequestListener.cs" /> <Compile Include="StudioApplication\IShutdownListener.cs" /> @@ -186,6 +189,10 @@ <Project>{4206ac58-3b57-4699-8835-90bf6db01a61}</Project> <Name>Tango.Integration</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.PMR\Tango.PMR.csproj"> + <Project>{e4927038-348d-4295-aaf4-861c58cb3943}</Project> + <Name>Tango.PMR</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.Settings\Tango.Settings.csproj"> <Project>{d8f1ad85-526a-4f50-b6dc-d437af63d8d8}</Project> <Name>Tango.Settings</Name> @@ -194,6 +201,10 @@ <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> <Name>Tango.SharedUI</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.Transport\Tango.Transport.csproj"> + <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project> + <Name>Tango.Transport</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.Video\Tango.Video.csproj"> <Project>{9652f972-2bd1-4283-99cb-fc6240434c17}</Project> <Name>Tango.Video</Name> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Video/DefaultVideoCaptureProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Video/DefaultVideoCaptureProvider.cs index 5aace7705..3aa9d4c88 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Video/DefaultVideoCaptureProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Video/DefaultVideoCaptureProvider.cs @@ -24,7 +24,21 @@ namespace Tango.MachineStudio.Common.Video /// </summary> public DefaultVideoCaptureProvider() { - AvailableCaptureDevices = CaptureDevice.GetAvailableCaptureDevices().Select(device => new CaptureDevice() { Device = device }).ToObservableCollection(); + 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] }); + } + } } } } |
