From b934b152eea671fa06678baa0cdf7f8811e6d2d9 Mon Sep 17 00:00:00 2001 From: Roy Date: Wed, 14 Feb 2018 22:51:52 +0200 Subject: MERGE. --- .../Tango.MachineStudio.DataCapture.csproj | 174 +++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Tango.MachineStudio.DataCapture.csproj (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Tango.MachineStudio.DataCapture.csproj') 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 -- cgit v1.3.1 From e4c917c43e90a4453c6cd5b1842a418dc0f1b514 Mon Sep 17 00:00:00 2001 From: Roy Date: Thu, 15 Feb 2018 00:29:13 +0200 Subject: Working on Data Capture Module.. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../Recording/DataRecording.cs | 23 +++++- .../Tango.MachineStudio.DataCapture.csproj | 7 ++ .../ViewModels/MainViewVM.cs | 83 ++++++++++++++------- .../Views/MainView.xaml | 5 +- .../Views/PlayingBarView.xaml | 53 +++++++++++++ .../Views/PlayingBarView.xaml.cs | 28 +++++++ .../ViewModels/MainViewVM.cs | 31 +++++--- .../Notifications/BarItem.cs | 5 ++ .../Diagnostics/DiagnosticsFilePlayer.cs | 7 +- 11 files changed, 195 insertions(+), 47 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/PlayingBarView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/PlayingBarView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Tango.MachineStudio.DataCapture.csproj') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index da65c19c8..11640e60d 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index c6adffec8..ecbb1e3f1 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ 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 index a191c244e..ddf24e113 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Recording/DataRecording.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Recording/DataRecording.cs @@ -1,14 +1,31 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core; +using Tango.Integration.Diagnostics; namespace Tango.MachineStudio.DataCapture.Recording { public class DataRecording : ExtendedObject { + public DataRecording() + { + Date = DateTime.Now; + } + + public DataRecording(String filePath) : this() + { + FilePath = filePath; + } + + public DataRecording(String filePath, DateTime date) : this(filePath) + { + Date = date; + } + private DateTime _date; public DateTime Date @@ -17,12 +34,9 @@ namespace Tango.MachineStudio.DataCapture.Recording set { _date = value; RaisePropertyChangedAuto(); } } - private String _name; - public String Name { - get { return _name; } - set { _name = value; RaisePropertyChangedAuto(); } + get { return Path.GetFileNameWithoutExtension(FilePath); } } private String _file; @@ -33,5 +47,6 @@ namespace Tango.MachineStudio.DataCapture.Recording set { _file = value; RaisePropertyChangedAuto(); } } + public DiagnosticsFilePlayer Player { get; set; } } } 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 index 1c13be809..8936a66db 100644 --- 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 @@ -81,6 +81,9 @@ GlobalVersionInfo.cs + + PlayingBarView.xaml + RecordingBarView.xaml @@ -88,6 +91,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile 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 index b63ee51d0..269007dac 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using System.Windows.Controls; @@ -32,6 +33,8 @@ namespace Tango.MachineStudio.DataCapture.ViewModels private IStudioApplicationManager _applicationManager; private IDiagnosticsFrameProvider _frameProvider; private String _recordingsFolder; + private BarItem _recordingBarItem; + private BarItem _playerBarItem; #region Properties @@ -52,7 +55,7 @@ namespace Tango.MachineStudio.DataCapture.ViewModels public DataRecording SelectedRecording { get { return _selectedRecording; } - set { _selectedRecording = value; RaisePropertyChangedAuto(); } + set { _selectedRecording = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } /// @@ -140,35 +143,29 @@ namespace Tango.MachineStudio.DataCapture.ViewModels 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); + MediaPlayPauseCommand = new RelayCommand(DiagnosticsTogglePlayPause, () => !Recorder.IsRecording && SelectedRecording != null); _recordingsFolder = Path.Combine(SettingsManager.DefaultFolder, "Recordings"); Directory.CreateDirectory(_recordingsFolder); _frameProvider.FrameReceived += _frameProvider_FrameReceived; - _notification.PushBarItem(new RecordingBarView() { DataContext = this }); - applicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; + + _recordingBarItem = new BarItem(_notification, new RecordingBarView() { DataContext = this }); + _playerBarItem = new BarItem(_notification, new PlayingBarView() { DataContext = this }); + + LoadRecordings(); } + #endregion + + #region Event Handlers + private void ApplicationManager_ConnectedMachineChanged(object sender, Integration.Services.IExternalBridgeClient machine) { MachineOperator = machine; @@ -186,10 +183,19 @@ namespace Tango.MachineStudio.DataCapture.ViewModels } } + #endregion #region Private Methods + private void LoadRecordings() + { + foreach (var file in Directory.GetFiles(_recordingsFolder, "*.tdr")) + { + Recordings.Add(new DataRecording(file, File.GetCreationTime(file))); + } + } + /// /// Removes the recording. /// @@ -211,11 +217,28 @@ namespace Tango.MachineStudio.DataCapture.ViewModels } } - private void DiagnosticsTogglePlayPause() + private async void DiagnosticsTogglePlayPause() { if (!Player.IsPlaying || Player.IsPaused) { _frameProvider.Disable = true; + + if (SelectedRecording.Player == null) + { + using (_notification.PushTaskItem("Loading Recording...")) + { + SelectedRecording.Player = new DiagnosticsFilePlayer(); + await SelectedRecording.Player.Load(SelectedRecording.FilePath); + } + } + + RegisterPlayer(SelectedRecording.Player); + + if (!Player.IsPlaying) + { + _playerBarItem.Push(); + } + Player.Play(); } else @@ -226,21 +249,21 @@ namespace Tango.MachineStudio.DataCapture.ViewModels InvalidateRelayCommands(); } - private async void LoadSelectedRecording() + private void RegisterPlayer(DiagnosticsFilePlayer player) { - using (_notification.PushTaskItem("Loading Recording...")) + foreach (var recording in Recordings) { - if (Player != null) + if (recording.Player != null) { - Player.Dispose(); + recording.Player.FrameReceived -= Player_FrameReceived; } + } - Player = new DiagnosticsFilePlayer(); + if (player != null) + { + Player = player; Player.FrameReceived += Player_FrameReceived; - await Player.Load(SelectedRecording.FilePath); } - - InvalidateRelayCommands(); } private void Player_FrameReceived(object sender, DataFileFrame frame) @@ -256,6 +279,8 @@ namespace Tango.MachineStudio.DataCapture.ViewModels using (_notification.PushTaskItem("Starting Recording...")) { Recorder.Start(); + + _recordingBarItem.Push(); } InvalidateRelayCommands(); @@ -268,6 +293,7 @@ namespace Tango.MachineStudio.DataCapture.ViewModels using (_notification.PushTaskItem("Stopping Recording...")) { await Recorder.Stop(); + _recordingBarItem.Pop(); } String recordingName = _notification.ShowTextInput("Enter recording name", "Recording name"); @@ -276,7 +302,9 @@ namespace Tango.MachineStudio.DataCapture.ViewModels { using (_notification.PushTaskItem("Saving Recording...")) { - await Recorder.Save(Path.Combine(_recordingsFolder, recordingName + ".tdr")); + String filePath = Path.Combine(_recordingsFolder, recordingName + ".tdr"); + await Recorder.Save(filePath); + Recordings.Insert(0, new DataRecording(filePath)); } } @@ -287,6 +315,7 @@ namespace Tango.MachineStudio.DataCapture.ViewModels { await Player.Stop(); _frameProvider.Disable = false; + _playerBarItem.Pop(); } InvalidateRelayCommands(); 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 index 74addf942..72f7da03d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/MainView.xaml @@ -17,6 +17,7 @@ + @@ -38,7 +39,7 @@ - + @@ -50,7 +51,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/PlayingBarView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/PlayingBarView.xaml new file mode 100644 index 000000000..3e76ce6ef --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/PlayingBarView.xaml @@ -0,0 +1,53 @@ + + + + + + + + / + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/PlayingBarView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/PlayingBarView.xaml.cs new file mode 100644 index 000000000..f9e502f8b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/Views/PlayingBarView.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 PlayingBarView : UserControl + { + public PlayingBarView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 148e4375c..10c35b3b9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -29,6 +29,7 @@ using Tango.Integration.Printing; using Tango.Integration.Diagnostics; using Microsoft.Win32; using Tango.MachineStudio.Technician.ViewModels; +using Tango.MachineStudio.Common.Diagnostics; namespace Tango.MachineStudio.Developer.ViewModels { @@ -496,10 +497,11 @@ namespace Tango.MachineStudio.Developer.ViewModels /// The application manager. /// The notification provider. [PreferredConstructor] - public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IMainView view) : this(view) + public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IMainView view, IDiagnosticsFrameProvider diagnosticsFrameProvider) : this(view) { _notification = notificationProvider; ApplicationManager = applicationManager; + diagnosticsFrameProvider.FrameReceived += DiagnosticsFrameProvider_FrameReceived; //Initialize Commands... EditMachineCommand = new RelayCommand(EditMachine, () => SelectedMachine != null); @@ -520,8 +522,8 @@ namespace Tango.MachineStudio.Developer.ViewModels ExitFullScreenCommand = new RelayCommand(ExitFullScreen); MediaRecordingCommand = new RelayCommand(StartDiagnosticsRecording, () => !Recorder.IsRecording && MachineOperator != null && !Player.IsPlaying); MediaStopCommand = new RelayCommand(StopRecorderOrPlayer, () => Recorder.IsRecording || Player.IsPlaying); - MediaLoadCommand = new RelayCommand(LoadDiagnosticsRecordingFile,() => !Recorder.IsRecording && !Player.IsPlaying); - MediaPlayPauseCommand = new RelayCommand(DiagnosticsTogglePlayPause,() => !Recorder.IsRecording && Player.IsLoaded); + MediaLoadCommand = new RelayCommand(LoadDiagnosticsRecordingFile, () => !Recorder.IsRecording && !Player.IsPlaying); + MediaPlayPauseCommand = new RelayCommand(DiagnosticsTogglePlayPause, () => !Recorder.IsRecording && Player.IsLoaded); CaptureDevices = new ObservableCollection(); var availableDevices = CaptureDevice.GetAvailableCaptureDevices(); @@ -549,6 +551,11 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Event Handlers + private void DiagnosticsFrameProvider_FrameReceived(object sender, PushDiagnosticsResponse response) + { + PopulateDiagnosticsData(response); + } + private void Player_FrameReceived(object sender, DataFileFrame frame) { PopulateDiagnosticsData(frame.PushDiagnosticsResponse); @@ -567,15 +574,15 @@ namespace Tango.MachineStudio.Developer.ViewModels private void MachineOperator_DiagnosticsDataAvailable(object sender, PushDiagnosticsResponse response) { - if (Recorder.IsRecording) - { - Recorder.Write(response); - } + //if (Recorder.IsRecording) + //{ + // Recorder.Write(response); + //} - if (!Player.IsPlaying) - { - PopulateDiagnosticsData(response); - } + //if (!Player.IsPlaying) + //{ + // PopulateDiagnosticsData(response); + //} } /// @@ -1085,7 +1092,7 @@ namespace Tango.MachineStudio.Developer.ViewModels if (SelectedBrushStop != null && SelectedSegment != null) { SelectedSegment.BrushStops.Remove(SelectedBrushStop); - + if (SelectedSegment.BrushStops.Count > 1) { SelectedSegment.BrushStops.Last().OffsetPercent = 100; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/BarItem.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/BarItem.cs index 8d3cefa40..d46bf5b5d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/BarItem.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/BarItem.cs @@ -19,6 +19,11 @@ namespace Tango.MachineStudio.Common.Notifications _notificationProvider = notificationProvider; } + public BarItem(INotificationProvider notificationProvider, FrameworkElement element) : this(notificationProvider) + { + Element = element; + } + /// /// Removed this item from the queue. /// diff --git a/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFilePlayer.cs b/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFilePlayer.cs index 7e5927648..1900e49e1 100644 --- a/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFilePlayer.cs +++ b/Software/Visual_Studio/Tango.Integration/Diagnostics/DiagnosticsFilePlayer.cs @@ -122,9 +122,9 @@ namespace Tango.Integration.Diagnostics /// /// Absolute file path. /// - public Task Load(String fileName) + public async Task Load(String fileName) { - return Task.Factory.StartNew(() => + Task task = new Task(() => { try { @@ -161,6 +161,9 @@ namespace Tango.Integration.Diagnostics throw LogManager.Log(ex); } }); + + task.Start(); + await task; } /// -- cgit v1.3.1