diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs | 79 |
1 files changed, 76 insertions, 3 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 4e7c5ec12..edc6274c3 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 @@ -26,6 +26,8 @@ using Tango.PMR.Common; using Tango.SharedUI.Helpers; using Tango.Transport; using Tango.Integration.Printing; +using Tango.Integration.Diagnostics; +using Microsoft.Win32; namespace Tango.MachineStudio.Developer.ViewModels { @@ -43,6 +45,16 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Properties + private DiagnosticsFileRecorder _recorder; + /// <summary> + /// Gets or sets the diagnostics file recorder. + /// </summary> + public DiagnosticsFileRecorder Recorder + { + get { return _recorder; } + set { _recorder = value; RaisePropertyChangedAuto(); } + } + /// <summary> /// Gets or sets the application manager. /// </summary> @@ -411,6 +423,26 @@ 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 load file command. + /// </summary> + public RelayCommand MediaLoadFileCommand { get; set; } + #endregion #region Constructors @@ -428,6 +460,7 @@ namespace Tango.MachineStudio.Developer.ViewModels Graphs = new ObservableCollection<IRealTimeGraph>(); _controllers = new Dictionary<String, GraphControllerBase>(); + Recorder = new DiagnosticsFileRecorder(); } /// <summary> @@ -458,6 +491,8 @@ 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); + MediaStopCommand = new RelayCommand(StopRecorderOrPlayer, () => Recorder.IsRecording); CaptureDevices = new ObservableCollection<CaptureDevice>(); var availableDevices = CaptureDevice.GetAvailableCaptureDevices(); @@ -479,6 +514,10 @@ namespace Tango.MachineStudio.Developer.ViewModels ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; } + #endregion + + #region Event Handlers + private void ApplicationManager_ConnectedMachineChanged(object sender, Integration.Services.IExternalBridgeClient machine) { MachineOperator = machine; @@ -492,6 +531,11 @@ namespace Tango.MachineStudio.Developer.ViewModels private void MachineOperator_DiagnosticsDataAvailable(object sender, PushDiagnosticsResponse response) { + if (Recorder.IsRecording) + { + Recorder.PushData(response); + } + foreach (var prop in response.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) { GraphControllerBase controller = null; @@ -512,9 +556,6 @@ namespace Tango.MachineStudio.Developer.ViewModels } } - #endregion - - #region Event Handlers /// <summary> /// Handles the Saved event of the SelectedMachine. @@ -624,6 +665,38 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Private Methods + private void StartDiagnosticsRecording() + { + using (_notification.PushTaskItem("Starting Recording...")) + { + Recorder.Start(); + } + + InvalidateRelayCommands(); + } + + private async void StopRecorderOrPlayer() + { + 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(); + } + private void ExitFullScreen() { if (FullScreenGraph != null) |
