From b7b277736c7e3ec9258915cdd5a54e7b33ba1123 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 14 Feb 2018 19:14:06 +0200 Subject: Working on Data Capture Module. --- .../DataCaptureModule.cs | 84 ++++++ .../Images/capture-device.png | Bin 0 -> 1812 bytes .../Images/data-capture.jpg | Bin 0 -> 121309 bytes .../Images/recordings.png | Bin 0 -> 858 bytes .../Images/tape.png | Bin 0 -> 713 bytes .../Images/video-frame.png | Bin 0 -> 97254 bytes .../Properties/AssemblyInfo.cs | 18 ++ .../Properties/Resources.Designer.cs | 62 +++++ .../Properties/Resources.resx | 117 ++++++++ .../Properties/Settings.Designer.cs | 30 +++ .../Properties/Settings.settings | 7 + .../Recording/DataRecording.cs | 37 +++ .../Tango.MachineStudio.DataCapture.csproj | 174 ++++++++++++ .../ViewModelLocator.cs | 33 +++ .../ViewModels/MainViewVM.cs | 297 +++++++++++++++++++++ .../Views/MainView.xaml | 250 +++++++++++++++++ .../Views/MainView.xaml.cs | 28 ++ .../Views/RecordingBarView.xaml | 50 ++++ .../Views/RecordingBarView.xaml.cs | 28 ++ .../packages.config | 8 + 20 files changed, 1223 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/capture-device.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/data-capture.jpg create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/recordings.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/tape.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/video-frame.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Resources.resx create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Settings.settings create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Recording/DataRecording.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Tango.MachineStudio.DataCapture.csproj create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModelLocator.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/MainView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/MainView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/RecordingBarView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/RecordingBarView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/packages.config (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs new file mode 100644 index 000000000..ee650dc13 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs @@ -0,0 +1,84 @@ +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; +using Tango.MachineStudio.Common; +using Tango.MachineStudio.DataCapture.Views; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.DataCapture +{ + /// + /// Represents the machine studio data capturing and playing module. + /// + /// + public class DataCaptureModule : StudioModuleBase + { + /// + /// Gets the module name. + /// + public override string Name + { + get + { + return "Data Capture"; + } + } + + /// + /// Gets the module description. + /// + public override string Description + { + get + { + return "Capture and synchronize diagnostics machine data with video capturing devices for later analysis"; + } + } + + /// + /// Gets the module cover image. + /// + public override BitmapSource Image + { + get + { + return ResourceHelper.GetImageFromResources("Images/data-capture.jpg"); + } + } + + /// + /// Gets the module entry point view. + /// + public override FrameworkElement MainView + { + get + { + return new MainView(); + } + } + + /// + /// Gets the permission required to see and load this module. + /// + public override Permissions Permission + { + get + { + return Permissions.RunTechnicianModule; + } + } + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public override void Dispose() + { + + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/capture-device.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/capture-device.png new file mode 100644 index 000000000..5f04b660a Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/capture-device.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/data-capture.jpg b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/data-capture.jpg new file mode 100644 index 000000000..87524f07a Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/data-capture.jpg differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/recordings.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/recordings.png new file mode 100644 index 000000000..a965c62af Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/recordings.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/tape.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/tape.png new file mode 100644 index 000000000..8a4739b23 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/tape.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/video-frame.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/video-frame.png new file mode 100644 index 000000000..9c29dc438 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Images/video-frame.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..0fd6e93b2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/AssemblyInfo.cs @@ -0,0 +1,18 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +[assembly: AssemblyTitle("Tango - Machine Studio Data Capturing Module")] + +[assembly: ComVisible(false)] + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Resources.Designer.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Resources.Designer.cs new file mode 100644 index 000000000..fdd6d78b8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Resources.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.MachineStudio.DataCapture.Properties { + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if ((resourceMan == null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.MachineStudio.DataCapture.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Resources.resx b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Settings.Designer.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Settings.Designer.cs new file mode 100644 index 000000000..8a9ab67ad --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.MachineStudio.DataCapture.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Settings.settings b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Recording/DataRecording.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Recording/DataRecording.cs new file mode 100644 index 000000000..a191c244e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Recording/DataRecording.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.MachineStudio.DataCapture.Recording +{ + public class DataRecording : ExtendedObject + { + private DateTime _date; + + public DateTime Date + { + get { return _date; } + set { _date = value; RaisePropertyChangedAuto(); } + } + + private String _name; + + public String Name + { + get { return _name; } + set { _name = value; RaisePropertyChangedAuto(); } + } + + private String _file; + + public String FilePath + { + get { return _file; } + set { _file = value; RaisePropertyChangedAuto(); } + } + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Tango.MachineStudio.DataCapture.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Tango.MachineStudio.DataCapture.csproj new file mode 100644 index 000000000..1c13be809 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Tango.MachineStudio.DataCapture.csproj @@ -0,0 +1,174 @@ + + + + + Debug + AnyCPU + {FC337A7F-1214-41D8-9992-78092A3B961E} + library + Tango.MachineStudio.DataCapture + Tango.MachineStudio.DataCapture + v4.6 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + true + full + false + ..\..\..\Build\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Extras.dll + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll + + + ..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll + + + ..\..\..\packages\MaterialDesignColors.1.1.2\lib\net45\MaterialDesignColors.dll + + + ..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll + + + ..\..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll + + + + + ..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll + + + + + + + + + 4.0 + + + + + + + + + + + MainView.xaml + + + GlobalVersionInfo.cs + + + + RecordingBarView.xaml + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {4206ac58-3b57-4699-8835-90bf6db01a61} + Tango.Integration + + + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} + Tango.Logging + + + {e4927038-348d-4295-aaf4-861c58cb3943} + Tango.PMR + + + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} + Tango.Settings + + + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} + Tango.SharedUI + + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + + + {9652f972-2bd1-4283-99cb-fc6240434c17} + Tango.Video + + + {cb0b0aa2-bb24-4bca-a720-45e397684e12} + Tango.MachineStudio.Common + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModelLocator.cs new file mode 100644 index 000000000..98c5db8fe --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModelLocator.cs @@ -0,0 +1,33 @@ +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Ioc; +using Microsoft.Practices.ServiceLocation; +using Tango.MachineStudio.DataCapture.ViewModels; +using Tango.MachineStudio.DataCapture.Views; + +namespace Tango.MachineStudio.DataCapture +{ + /// + /// This class contains static references to all the view models in the + /// application and provides an entry point for the bindings. + /// + public static class ViewModelLocator + { + /// + /// Initializes a new instance of the ViewModelLocator class. + /// + static ViewModelLocator() + { + ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); + + SimpleIoc.Default.Register(); + } + + public static MainViewVM MainViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs new file mode 100644 index 000000000..b63ee51d0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs @@ -0,0 +1,297 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; +using Tango.Core.Commands; +using Tango.Integration.Diagnostics; +using Tango.Integration.Operators; +using Tango.MachineStudio.Common.Diagnostics; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.StudioApplication; +using Tango.MachineStudio.Common.Video; +using Tango.MachineStudio.DataCapture.Recording; +using Tango.MachineStudio.DataCapture.Views; +using Tango.PMR.Diagnostics; +using Tango.Settings; +using Tango.SharedUI; +using Tango.Video.DirectCapture; + +namespace Tango.MachineStudio.DataCapture.ViewModels +{ + /// + /// Represents the data capture main view, view model. + /// + /// + public class MainViewVM : ViewModel + { + private INotificationProvider _notification; + private IStudioApplicationManager _applicationManager; + private IDiagnosticsFrameProvider _frameProvider; + private String _recordingsFolder; + + #region Properties + + private ObservableCollection _recordings; + /// + /// Gets or sets the recordings collection. + /// + public ObservableCollection Recordings + { + get { return _recordings; } + set { _recordings = value; RaisePropertyChangedAuto(); } + } + + private DataRecording _selectedRecording; + /// + /// Gets or sets the selected recording. + /// + public DataRecording SelectedRecording + { + get { return _selectedRecording; } + set { _selectedRecording = value; RaisePropertyChangedAuto(); } + } + + /// + /// Gets or sets the video capture provider. + /// + public IVideoCaptureProvider VideoCaptureProvider { get; set; } + + private DiagnosticsFileRecorder _recorder; + /// + /// Gets or sets the diagnostics file recorder. + /// + public DiagnosticsFileRecorder Recorder + { + get { return _recorder; } + set { _recorder = value; RaisePropertyChangedAuto(); } + } + + private DiagnosticsFilePlayer _player; + /// + /// Gets or sets the diagnostics file player. + /// + public DiagnosticsFilePlayer Player + { + get { return _player; } + set { _player = value; RaisePropertyChangedAuto(); } + } + + /// + /// Gets or sets the machine operator. + /// + public IMachineOperator MachineOperator { get; set; } + + #endregion + + #region Commands + + /// + /// Gets or sets the remove recording command. + /// + public RelayCommand RemoveRecordingCommand { get; set; } + + /// + /// Gets or sets the toggle camera command. + /// + public RelayCommand ToggleCameraCommand { get; set; } + + /// + /// Gets or sets the media recording command. + /// + public RelayCommand MediaRecordingCommand { get; set; } + + /// + /// Gets or sets the media stop command. + /// + public RelayCommand MediaStopCommand { get; set; } + + /// + /// Gets or sets the media toggle play pause command. + /// + public RelayCommand MediaTogglePlayPauseCommand { get; set; } + + /// + /// Gets or sets the media play pause command. + /// + public RelayCommand MediaPlayPauseCommand { get; set; } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public MainViewVM(IVideoCaptureProvider videoCaptureProvider, INotificationProvider notification, IStudioApplicationManager applicationManager, IDiagnosticsFrameProvider frameProvider) + { + _notification = notification; + _applicationManager = applicationManager; + _frameProvider = frameProvider; + + Recorder = new DiagnosticsFileRecorder(); + Player = new DiagnosticsFilePlayer(); + + VideoCaptureProvider = videoCaptureProvider; + Recordings = new ObservableCollection(); + + ToggleCameraCommand = new RelayCommand(ToggleCamera); + + Recordings.Add(new DataRecording() + { + Name = "Recording 1" + }); + Recordings.Add(new DataRecording() + { + Name = "Recording 2" + }); + Recordings.Add(new DataRecording() + { + Name = "Recording 3" + }); + + RemoveRecordingCommand = new RelayCommand(RemoveRecording); + + MediaRecordingCommand = new RelayCommand(StartDiagnosticsRecording, () => !Recorder.IsRecording && MachineOperator != null && !Player.IsPlaying); + MediaStopCommand = new RelayCommand(StopRecorderOrPlayer, () => Recorder.IsRecording || Player.IsPlaying); + MediaPlayPauseCommand = new RelayCommand(DiagnosticsTogglePlayPause, () => !Recorder.IsRecording && Player.IsLoaded); + + _recordingsFolder = Path.Combine(SettingsManager.DefaultFolder, "Recordings"); + Directory.CreateDirectory(_recordingsFolder); + + _frameProvider.FrameReceived += _frameProvider_FrameReceived; + + _notification.PushBarItem(new RecordingBarView() { DataContext = this }); + + applicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; + } + + private void ApplicationManager_ConnectedMachineChanged(object sender, Integration.Services.IExternalBridgeClient machine) + { + MachineOperator = machine; + InvalidateRelayCommands(); + } + + private void _frameProvider_FrameReceived(object sender, PushDiagnosticsResponse frame) + { + if (!_frameProvider.Disable) + { + if (Recorder.IsRecording) + { + Recorder.Write(frame); + } + } + } + + #endregion + + #region Private Methods + + /// + /// Removes the recording. + /// + /// The recording. + private void RemoveRecording(DataRecording recording) + { + Recordings.Remove(recording); + } + + /// + /// Toggles the camera. + /// + /// The capture device. + private void ToggleCamera(CaptureDevice captureDevice) + { + if (captureDevice.Device != null) + { + captureDevice.IsStarted = !captureDevice.IsStarted; + } + } + + private void DiagnosticsTogglePlayPause() + { + if (!Player.IsPlaying || Player.IsPaused) + { + _frameProvider.Disable = true; + Player.Play(); + } + else + { + Player.Pause(); + } + + InvalidateRelayCommands(); + } + + private async void LoadSelectedRecording() + { + using (_notification.PushTaskItem("Loading Recording...")) + { + if (Player != null) + { + Player.Dispose(); + } + + Player = new DiagnosticsFilePlayer(); + Player.FrameReceived += Player_FrameReceived; + await Player.Load(SelectedRecording.FilePath); + } + + InvalidateRelayCommands(); + } + + private void Player_FrameReceived(object sender, DataFileFrame frame) + { + if (_frameProvider.Disable) + { + _frameProvider.PushFrame(frame.PushDiagnosticsResponse); + } + } + + private void StartDiagnosticsRecording() + { + using (_notification.PushTaskItem("Starting Recording...")) + { + Recorder.Start(); + } + + InvalidateRelayCommands(); + } + + private async void StopRecorderOrPlayer() + { + if (Recorder.IsRecording) + { + using (_notification.PushTaskItem("Stopping Recording...")) + { + await Recorder.Stop(); + } + + String recordingName = _notification.ShowTextInput("Enter recording name", "Recording name"); + + if (!String.IsNullOrWhiteSpace(recordingName)) + { + using (_notification.PushTaskItem("Saving Recording...")) + { + await Recorder.Save(Path.Combine(_recordingsFolder, recordingName + ".tdr")); + } + } + + Recorder.Dispose(); + Recorder = new DiagnosticsFileRecorder(); + } + else if (Player.IsPlaying) + { + await Player.Stop(); + _frameProvider.Disable = false; + } + + InvalidateRelayCommands(); + } + + #endregion + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/MainView.xaml new file mode 100644 index 000000000..74addf942 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/MainView.xaml @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + RECORDINGS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CAPTURE DEVICES + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Total Frames: + + + + File Size: + + + + + + + + + + + + + + + + + + + + / + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/MainView.xaml.cs new file mode 100644 index 000000000..624840d66 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/MainView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.DataCapture.Views +{ + /// + /// Interaction logic for MainView.xaml + /// + public partial class MainView : UserControl + { + public MainView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/RecordingBarView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/RecordingBarView.xaml new file mode 100644 index 000000000..d076eb631 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/RecordingBarView.xaml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/RecordingBarView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/RecordingBarView.xaml.cs new file mode 100644 index 000000000..97389a1e5 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/RecordingBarView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.DataCapture.Views +{ + /// + /// Interaction logic for RecordingBarView.xaml + /// + public partial class RecordingBarView : UserControl + { + public RecordingBarView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/packages.config new file mode 100644 index 000000000..4fd672b32 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file -- cgit v1.3.1