diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-15 15:04:39 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-15 15:04:39 +0200 |
| commit | 9879f87a345bec10a3ee26e9ec669add2b5bfcd3 (patch) | |
| tree | d2e70aac5e15edff8f58f76a2c450132dc562db3 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels | |
| parent | 63cb3aa2350a10e6db68e4dc181b2ee7e500061a (diff) | |
| download | Tango-9879f87a345bec10a3ee26e9ec669add2b5bfcd3.tar.gz Tango-9879f87a345bec10a3ee26e9ec669add2b5bfcd3.zip | |
Enable Diagnostics on connection.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs | 202 |
1 files changed, 10 insertions, 192 deletions
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; - /// <summary> - /// Gets or sets the diagnostics file recorder. - /// </summary> - public DiagnosticsFileRecorder Recorder - { - get { return _recorder; } - set { _recorder = value; RaisePropertyChangedAuto(); } - } + #region Properties - private DiagnosticsFilePlayer _player; /// <summary> - /// Gets or sets the diagnostics file player. + /// Gets or sets the application manager. /// </summary> - public DiagnosticsFilePlayer Player - { - get { return _player; } - set { _player = value; RaisePropertyChangedAuto(); } - } + public IStudioApplicationManager ApplicationManager { get; set; } /// <summary> - /// Gets or sets the application manager. + /// Gets or sets the video capture provider. /// </summary> - public IStudioApplicationManager ApplicationManager { get; set; } + public IVideoCaptureProvider VideoCaptureProvider { get; set; } /// <summary> /// Gets or sets observable entites database the adapter. @@ -321,11 +309,6 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _isJobCanceled = value; RaisePropertyChangedAuto(); } } - /// <summary> - /// Gets or sets the capture devices. - /// </summary> - public ObservableCollection<CaptureDevice> CaptureDevices { get; set; } - private IMachineOperator _machineOperator; /// <summary> /// Gets or sets the machine operator. @@ -346,16 +329,6 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _fullScreenGraph = value; RaisePropertyChangedAuto(); } } - private MachineTechViewVM _machineTechViewVM; - /// <summary> - /// Gets or sets the machine tech view models. - /// </summary> - public MachineTechViewVM MachineTechViewVM - { - get { return _machineTechViewVM; } - set { _machineTechViewVM = value; RaisePropertyChangedAuto(); } - } - #endregion #region Commands @@ -445,31 +418,6 @@ namespace Tango.MachineStudio.Developer.ViewModels /// </summary> public RelayCommand ExitFullScreenCommand { get; set; } - /// <summary> - /// Gets or sets the media recording command. - /// </summary> - public RelayCommand MediaRecordingCommand { get; set; } - - /// <summary> - /// Gets or sets the media stop command. - /// </summary> - public RelayCommand MediaStopCommand { get; set; } - - /// <summary> - /// Gets or sets the media toggle play pause command. - /// </summary> - public RelayCommand MediaTogglePlayPauseCommand { get; set; } - - /// <summary> - /// Gets or sets the media play pause command. - /// </summary> - public RelayCommand MediaPlayPauseCommand { get; set; } - - /// <summary> - /// Gets or sets the media load command. - /// </summary> - public RelayCommand MediaLoadCommand { get; set; } - #endregion #region Constructors @@ -487,8 +435,6 @@ namespace Tango.MachineStudio.Developer.ViewModels Graphs = new ObservableCollection<IRealTimeGraph>(); _controllers = new Dictionary<String, GraphControllerBase>(); - Recorder = new DiagnosticsFileRecorder(); - Player = new DiagnosticsFilePlayer(); } /// <summary> @@ -497,10 +443,11 @@ namespace Tango.MachineStudio.Developer.ViewModels /// <param name="applicationManager">The application manager.</param> /// <param name="notificationProvider">The notification provider.</param> [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<CaptureDevice>(); - 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<CaptureDevice>(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); - //} } /// <summary> @@ -631,7 +533,6 @@ namespace Tango.MachineStudio.Developer.ViewModels /// <summary> /// Called when the process parameters table group has been changed /// </summary> - /// <exception cref="NotImplementedException"></exception> 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) |
