From 9879f87a345bec10a3ee26e9ec669add2b5bfcd3 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 15 Feb 2018 15:04:39 +0200 Subject: Enable Diagnostics on connection. --- .../ViewModels/MainViewVM.cs | 202 +-------------------- .../Views/MainView.xaml | 103 +---------- 2 files changed, 15 insertions(+), 290 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer') 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 10c35b3b9..b2f6c3579 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 @@ -30,6 +30,8 @@ using Tango.Integration.Diagnostics; using Microsoft.Win32; using Tango.MachineStudio.Technician.ViewModels; using Tango.MachineStudio.Common.Diagnostics; +using Tango.MachineStudio.Common.Video; +using Tango.Integration.Services; namespace Tango.MachineStudio.Developer.ViewModels { @@ -45,32 +47,18 @@ namespace Tango.MachineStudio.Developer.ViewModels private int _fullScreenGraphIndex; private JobHandler _jobHandler; - #region Properties - private DiagnosticsFileRecorder _recorder; - /// - /// Gets or sets the diagnostics file recorder. - /// - public DiagnosticsFileRecorder Recorder - { - get { return _recorder; } - set { _recorder = value; RaisePropertyChangedAuto(); } - } + #region Properties - private DiagnosticsFilePlayer _player; /// - /// Gets or sets the diagnostics file player. + /// Gets or sets the application manager. /// - public DiagnosticsFilePlayer Player - { - get { return _player; } - set { _player = value; RaisePropertyChangedAuto(); } - } + public IStudioApplicationManager ApplicationManager { get; set; } /// - /// Gets or sets the application manager. + /// Gets or sets the video capture provider. /// - public IStudioApplicationManager ApplicationManager { get; set; } + public IVideoCaptureProvider VideoCaptureProvider { get; set; } /// /// Gets or sets observable entites database the adapter. @@ -321,11 +309,6 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _isJobCanceled = value; RaisePropertyChangedAuto(); } } - /// - /// Gets or sets the capture devices. - /// - public ObservableCollection CaptureDevices { get; set; } - private IMachineOperator _machineOperator; /// /// Gets or sets the machine operator. @@ -346,16 +329,6 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _fullScreenGraph = value; RaisePropertyChangedAuto(); } } - private MachineTechViewVM _machineTechViewVM; - /// - /// Gets or sets the machine tech view models. - /// - public MachineTechViewVM MachineTechViewVM - { - get { return _machineTechViewVM; } - set { _machineTechViewVM = value; RaisePropertyChangedAuto(); } - } - #endregion #region Commands @@ -445,31 +418,6 @@ namespace Tango.MachineStudio.Developer.ViewModels /// public RelayCommand ExitFullScreenCommand { 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; } - - /// - /// Gets or sets the media load command. - /// - public RelayCommand MediaLoadCommand { get; set; } - #endregion #region Constructors @@ -487,8 +435,6 @@ namespace Tango.MachineStudio.Developer.ViewModels Graphs = new ObservableCollection(); _controllers = new Dictionary(); - Recorder = new DiagnosticsFileRecorder(); - Player = new DiagnosticsFilePlayer(); } /// @@ -497,10 +443,11 @@ namespace Tango.MachineStudio.Developer.ViewModels /// The application manager. /// The notification provider. [PreferredConstructor] - public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IMainView view, IDiagnosticsFrameProvider diagnosticsFrameProvider) : this(view) + public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IMainView view, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider) : this(view) { _notification = notificationProvider; ApplicationManager = applicationManager; + VideoCaptureProvider = videoCaptureProvider; diagnosticsFrameProvider.FrameReceived += DiagnosticsFrameProvider_FrameReceived; //Initialize Commands... @@ -520,31 +467,10 @@ namespace Tango.MachineStudio.Developer.ViewModels StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning); CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar); 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); - - CaptureDevices = new ObservableCollection(); - var availableDevices = CaptureDevice.GetAvailableCaptureDevices(); - - for (int i = 0; i < 3; i++) - { - if (i > availableDevices.Count - 1) - { - CaptureDevices.Add(new CaptureDevice() { Device = null }); - } - else - { - CaptureDevices.Add(new CaptureDevice() { Device = availableDevices[i] }); - } - } ToggleCameraCommand = new RelayCommand(ToggleCamera); ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; - - MachineTechViewVM = new MachineTechViewVM(applicationManager, notificationProvider, false); } #endregion @@ -556,33 +482,9 @@ namespace Tango.MachineStudio.Developer.ViewModels PopulateDiagnosticsData(response); } - private void Player_FrameReceived(object sender, DataFileFrame frame) - { - PopulateDiagnosticsData(frame.PushDiagnosticsResponse); - } - - private void ApplicationManager_ConnectedMachineChanged(object sender, Integration.Services.IExternalBridgeClient machine) + private void ApplicationManager_ConnectedMachineChanged(object sender, IExternalBridgeClient machine) { MachineOperator = machine; - - if (MachineOperator != null) - { - MachineOperator.EnableDiagnostics = true; - MachineOperator.DiagnosticsDataAvailable += MachineOperator_DiagnosticsDataAvailable; - } - } - - private void MachineOperator_DiagnosticsDataAvailable(object sender, PushDiagnosticsResponse response) - { - //if (Recorder.IsRecording) - //{ - // Recorder.Write(response); - //} - - //if (!Player.IsPlaying) - //{ - // PopulateDiagnosticsData(response); - //} } /// @@ -631,7 +533,6 @@ namespace Tango.MachineStudio.Developer.ViewModels /// /// Called when the process parameters table group has been changed /// - /// private void OnProcessParametersTableGroupChanged() { if (RmlProcessParametersTableGroup != null && RmlProcessParametersTableGroup.ProcessParametersTables.Count > 0) @@ -720,89 +621,6 @@ namespace Tango.MachineStudio.Developer.ViewModels } } - private void DiagnosticsTogglePlayPause() - { - if (!Player.IsPlaying || Player.IsPaused) - { - if (!Player.IsPlaying) - { - ClearGraphs(); - } - Player.Play(); - } - else - { - Player.Pause(); - } - - InvalidateRelayCommands(); - } - - private async void LoadDiagnosticsRecordingFile() - { - OpenFileDialog dlg = new OpenFileDialog(); - dlg.Title = "Select Tango Diagnostics Recording File"; - dlg.Filter = "Tango Diagnostics Recording|*.tdr"; - if (dlg.ShowDialog().Value) - { - using (_notification.PushTaskItem("Loading Recording...")) - { - if (Player != null) - { - Player.Dispose(); - } - - Player = new DiagnosticsFilePlayer(); - Player.FrameReceived += Player_FrameReceived; - await Player.Load(dlg.FileName); - } - } - - InvalidateRelayCommands(); - } - - 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(); - } - - SaveFileDialog dlg = new SaveFileDialog(); - dlg.Title = "Select diagnostics file location"; - dlg.Filter = "Tango Diagnostics Recording|*.tdr"; - if (dlg.ShowDialog().Value) - { - using (_notification.PushTaskItem("Saving Recording...")) - { - await Recorder.Save(dlg.FileName); - } - } - - Recorder.Dispose(); - Recorder = new DiagnosticsFileRecorder(); - } - else if (Player.IsPlaying) - { - await Player.Stop(); - ClearGraphs(); - } - - InvalidateRelayCommands(); - } - private void ExitFullScreen() { if (FullScreenGraph != null) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml index 844a38917..b6d859cd4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml @@ -1651,102 +1651,9 @@ USB CAMERAS - - - - - - DATA RECORDER / PLAYER - - - - - - - - - - - - - - - - - / - - - - - - - - - Total Frames: - - - - File Size: - - - - - - - - - - - + + @@ -2051,7 +1958,7 @@