diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-06 17:33:00 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-06 17:33:00 +0200 |
| commit | 198a620cf30e86158c60cb632df740ca94b73b57 (patch) | |
| tree | a4ba88c9d5f359cdc822b41dee88b792cfc31c27 /Software/Visual_Studio/MachineStudio | |
| parent | 307cbc71bc5e4c79f9309acec0ae0d8a173a735f (diff) | |
| download | Tango-198a620cf30e86158c60cb632df740ca94b73b57.tar.gz Tango-198a620cf30e86158c60cb632df740ca94b73b57.zip | |
Diagnostics Recording Seems To Work.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
2 files changed, 141 insertions, 25 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) 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 e953ddbcb..33652f119 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 @@ -55,6 +55,7 @@ <localConverters:JobProgressToPositionConverter x:Key="JobProgressToPositionConverter" /> <localConverters:BrushStopToOffsetValueConverter x:Key="BrushStopToOffsetValueConverter" /> <converters:StringEllipsisConverter x:Key="StringEllipsisConverter" /> + <converters:NumberToFileSizeConverter x:Key="NumberToFileSizeConverter"/> <SolidColorBrush x:Key="SideBarBackground" Color="White"> @@ -1598,36 +1599,78 @@ <Grid DockPanel.Dock="Bottom" Height="120" Width="300"> <Border Background="#5DFFFFFF" CornerRadius="10" Padding="5" Margin="0 0 0 10" BorderThickness="1" BorderBrush="Gainsboro"> - <DockPanel> - <StackPanel Orientation="Horizontal" DockPanel.Dock="Top"> - <Image Source="../Images/tape.png" Width="25"></Image> - <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" Foreground="DimGray" FontSize="16" FontWeight="SemiBold">DATA RECORDER/PLAYER</TextBlock> - </StackPanel> - <Grid> - <DockPanel> - <DockPanel DockPanel.Dock="Top"> - <StackPanel Orientation="Horizontal" DockPanel.Dock="Left" Height="50" VerticalAlignment="Bottom" Margin="0 0 0 5"> + <DockPanel> + <StackPanel Orientation="Horizontal" DockPanel.Dock="Top"> + <Image Source="../Images/tape.png" Width="25"></Image> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" Foreground="DimGray" FontSize="16" FontWeight="SemiBold">DATA RECORDER / PLAYER</TextBlock> + </StackPanel> + <Grid> + <DockPanel> + <DockPanel DockPanel.Dock="Top"> + <StackPanel Orientation="Horizontal" DockPanel.Dock="Left" Height="50" VerticalAlignment="Bottom" Margin="0 0 0 5"> <Button Style="{StaticResource MaterialDesignFloatingActionButton}" Padding="0" Width="28" Height="28" Background="Transparent" ToolTip="Load Data File"> <materialDesign:PackIcon Width="20" Height="20" Kind="Eject" Foreground="{StaticResource AccentColorBrush}" /> - </Button> + </Button> <Button Margin="5 0 0 0" Style="{StaticResource MaterialDesignFloatingActionButton}" Padding="0" Width="35" Height="35" Background="Transparent"> <materialDesign:PackIcon Width="20" Height="20" Kind="Play" Foreground="{StaticResource AccentColorBrush}" /> - </Button> - <Button Margin="5 0 0 0" Style="{StaticResource MaterialDesignFloatingActionButton}" Padding="0" Width="28" Height="28" Background="Transparent"> + </Button> + <Button Command="{Binding MediaStopCommand}" Margin="5 0 0 0" Style="{StaticResource MaterialDesignFloatingActionButton}" Padding="0" Width="28" Height="28" Background="Transparent"> <materialDesign:PackIcon Width="20" Height="20" Kind="Stop" Foreground="{StaticResource AccentColorBrush}" /> - </Button> - <Button Margin="5 0 0 0" Style="{StaticResource MaterialDesignFloatingActionButton}" Foreground="#FF7A7A" BorderBrush="#FF8585" Padding="0" Width="20" Height="20" Background="Transparent" ToolTip="Start Recording"> - <materialDesign:PackIcon Width="10" Height="10" Kind="Record" /> - </Button> - </StackPanel> + </Button> + <Button Command="{Binding MediaRecordingCommand}" Margin="5 0 0 0" Style="{StaticResource MaterialDesignFloatingActionButton}" Foreground="#FF7A7A" BorderBrush="#FF8585" Padding="0" Width="20" Height="20" Background="Transparent" ToolTip="Start Recording"> + + <materialDesign:PackIcon Width="10" Height="10" Kind="Record" /> + </Button> + </StackPanel> + <Grid> + <TextBlock Text="00:00:00 / 00:00:00" Margin="0 -5 0 0" VerticalAlignment="Center" HorizontalAlignment="Right" Foreground="#FF8585" FontSize="20" FontFamily="{StaticResource digital-7}"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Setter Property="Opacity" Value="1"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Recorder.IsRecording}" Value="True"> + <DataTrigger.EnterActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Duration="00:00:01" RepeatBehavior="Forever"> + <DiscreteDoubleKeyFrame KeyTime="00:00:00" Value="1" /> + <DiscreteDoubleKeyFrame KeyTime="00:00:0.5" Value="0" /> + </DoubleAnimationUsingKeyFrames> + </Storyboard> + </BeginStoryboard> + </DataTrigger.EnterActions> + <DataTrigger.ExitActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Duration="00:00:01"> + <DiscreteDoubleKeyFrame KeyTime="00:00:00" Value="1" /> + </DoubleAnimationUsingKeyFrames> + </Storyboard> + </BeginStoryboard> + </DataTrigger.ExitActions> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + </Grid> + </DockPanel> <Grid> - <TextBlock Text="00:00:00 / 00:00:00" Margin="0 -5 0 0" VerticalAlignment="Center" HorizontalAlignment="Right" Foreground="#FF8585" FontSize="20" FontFamily="{StaticResource digital-7}"></TextBlock> + <Slider Visibility="{Binding Recorder.IsRecording,Converter={StaticResource BooleanToVisibilityInverseConverter}}"></Slider> + <DockPanel Visibility="{Binding Recorder.IsRecording,Converter={StaticResource BooleanToVisibilityConverter}}"> + <TextBlock DockPanel.Dock="Left"> + <Run FontWeight="SemiBold" FontStyle="Italic">Total Frames:</Run> + <Run FontStyle="Italic" Foreground="#545454" Text="{Binding Recorder.TotalFramesRecorded,StringFormat={}{0:N0},Mode=OneWay,TargetNullValue=0,FallbackValue=0}"></Run> + </TextBlock> + <TextBlock HorizontalAlignment="Right" Width="140"> + <Run FontWeight="SemiBold" FontStyle="Italic">File Size:</Run> + <Run FontStyle="Italic" Foreground="#545454" Text="{Binding Recorder.TotalBytesRecorded,Mode=OneWay,Converter={StaticResource NumberToFileSizeConverter},TargetNullValue=0,FallbackValue=0}"></Run> + </TextBlock> + </DockPanel> </Grid> </DockPanel> - <Slider></Slider> - </DockPanel> - </Grid> - </DockPanel> + </Grid> + </DockPanel> </Border> </Grid> |
