From e774f9a90fd812a9de8c3efe966a759bee8be703 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Wed, 11 Mar 2020 03:41:20 +0200 Subject: Working on FSE/PPC performance provider. Implemented resolution service. a lot of work! --- .../ViewModels/ConsoleViewVM.cs | 29 ++- .../Tango.FSE.PPCConsole/ViewModels/MainViewVM.cs | 24 +++ .../Tango.FSE.PPCConsole/Views/ConsoleView.xaml | 4 +- .../Tango.FSE.PPCConsole/Views/MainView.xaml | 49 +++-- .../Views/RemoteDesktopView.xaml | 149 ++++++++++++-- .../Tango.FSE.Common/Console/IConsoleService.cs | 16 ++ .../FSE/Tango.FSE.Common/Controls/FSETabControl.cs | 106 ++++++++++ .../Tango.FSE.Common/Controls/FSETabControl.xaml | 106 ++++++++++ .../Tango.FSE.Common/Controls/TextIconButton.cs | 34 +++ .../Tango.FSE.Common/Controls/TextIconButton.xaml | 32 +++ .../FSE/Tango.FSE.Common/FSEViewModel.cs | 14 ++ .../FSE/Tango.FSE.Common/Fonts/Caveat-Bold.ttf | Bin 0 -> 335416 bytes .../FSE/Tango.FSE.Common/Fonts/Caveat-Regular.ttf | Bin 0 -> 330800 bytes .../Performance/IPerformanceProvider.cs | 13 ++ .../Performance/PerformancePackageEventArgs.cs | 14 ++ .../Resolution/IResolutionService.cs | 20 ++ .../Resolution/ResolutionHelper.cs | 227 +++++++++++++++++++++ .../Tango.FSE.Common/Resolution/ResolutionMode.cs | 15 ++ .../FSE/Tango.FSE.Common/Resources/Colors.xaml | 2 + .../FSE/Tango.FSE.Common/Resources/Controls.xaml | 2 + .../FSE/Tango.FSE.Common/Resources/Converters.xaml | 1 + .../FSE/Tango.FSE.Common/Resources/Fonts.xaml | 1 + .../FSE/Tango.FSE.Common/Resources/Styles.xaml | 64 ++++++ .../FSE/Tango.FSE.Common/Tango.FSE.Common.csproj | 27 +++ .../FSE/Tango.FSE.Common/Themes/Generic.xaml | 6 + .../Tango.FSE.UI/Console/DefaultConsoleService.cs | 53 +++++ .../Visual_Studio/FSE/Tango.FSE.UI/MainWindow.xaml | 8 +- .../Performance/DefaultPerformanceProvider.cs | 46 +++++ .../Resolution/DefaultResolutionService.cs | 121 +++++++++++ .../FSE/Tango.FSE.UI/Tango.FSE.UI.csproj | 8 + .../FSE/Tango.FSE.UI/ViewModelLocator.cs | 12 ++ .../FSE/Tango.FSE.UI/ViewModels/LoadingViewVM.cs | 5 - .../Installers/VS Extensions/PropMan.vsix | Bin 0 -> 45195 bytes .../Console/DefaultConsoleEngineService.cs | 22 +- .../Performance/DefaultPerformanceService.cs | 227 +++++++++++++++++++++ .../Performance/IPerformanceService.cs | 14 ++ .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 4 +- .../PPC/Tango.PPC.UI/ViewModelLocator.cs | 3 + .../Tango.Console/ConsoleCommandDTO.cs | 15 -- .../Tango.Console/ConsoleExecutionEngine.cs | 21 +- .../Tango.Console/Network/ConsoleCommandRequest.cs | 15 ++ .../Network/ConsoleCommandResponse.cs | 20 ++ .../Network/GetCurrentDirectoryRequest.cs | 13 ++ .../Network/GetCurrentDirectoryResponse.cs | 13 ++ .../Tango.Console/Tango.Console.csproj | 5 +- .../Information/GetMachineInformationRequest.cs | 12 ++ .../Information/GetMachineInformationResponse.cs | 12 ++ .../Network/Information/InformationPackage.cs | 18 ++ .../Network/Information/MachineProperty.cs | 14 ++ .../Network/Performance/PerformancePackage.cs | 25 +++ .../Performance/StartPerformanceUpdatesRequest.cs | 12 ++ .../Performance/StartPerformanceUpdatesResponse.cs | 13 ++ .../Tango.Integration/Tango.Integration.csproj | 9 +- .../Tango.SharedUI/Binding/BindingEventArgs.cs | 39 ++++ .../Binding/BindingEventContainer.cs | 95 +++++++++ .../Tango.SharedUI/Binding/BindingProperty.cs | 38 ++++ .../Tango.SharedUI/Controls/NavigationControl.cs | 26 ++- .../Converters/StringToTitleCaseConverter.cs | 30 +++ .../Tango.SharedUI/Tango.SharedUI.csproj | 4 + 59 files changed, 1831 insertions(+), 96 deletions(-) create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Console/IConsoleService.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FSETabControl.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FSETabControl.xaml create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/TextIconButton.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/TextIconButton.xaml create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Fonts/Caveat-Bold.ttf create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Fonts/Caveat-Regular.ttf create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Performance/IPerformanceProvider.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Performance/PerformancePackageEventArgs.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Resolution/IResolutionService.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Resolution/ResolutionHelper.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Resolution/ResolutionMode.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Themes/Generic.xaml create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.UI/Console/DefaultConsoleService.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.UI/Performance/DefaultPerformanceProvider.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.UI/Resolution/DefaultResolutionService.cs create mode 100644 Software/Visual_Studio/Installers/VS Extensions/PropMan.vsix create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/DefaultPerformanceService.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/IPerformanceService.cs delete mode 100644 Software/Visual_Studio/Tango.Console/ConsoleCommandDTO.cs create mode 100644 Software/Visual_Studio/Tango.Console/Network/ConsoleCommandRequest.cs create mode 100644 Software/Visual_Studio/Tango.Console/Network/ConsoleCommandResponse.cs create mode 100644 Software/Visual_Studio/Tango.Console/Network/GetCurrentDirectoryRequest.cs create mode 100644 Software/Visual_Studio/Tango.Console/Network/GetCurrentDirectoryResponse.cs create mode 100644 Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/GetMachineInformationRequest.cs create mode 100644 Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/GetMachineInformationResponse.cs create mode 100644 Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/InformationPackage.cs create mode 100644 Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/MachineProperty.cs create mode 100644 Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Performance/PerformancePackage.cs create mode 100644 Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Performance/StartPerformanceUpdatesRequest.cs create mode 100644 Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Performance/StartPerformanceUpdatesResponse.cs create mode 100644 Software/Visual_Studio/Tango.SharedUI/Binding/BindingEventArgs.cs create mode 100644 Software/Visual_Studio/Tango.SharedUI/Binding/BindingEventContainer.cs create mode 100644 Software/Visual_Studio/Tango.SharedUI/Binding/BindingProperty.cs create mode 100644 Software/Visual_Studio/Tango.SharedUI/Converters/StringToTitleCaseConverter.cs (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/ConsoleViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/ConsoleViewVM.cs index fd1567e0d..3ccab26da 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/ConsoleViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/ConsoleViewVM.cs @@ -4,7 +4,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Console; +using Tango.Console.Network; +using Tango.Core.DI; using Tango.FSE.Common; +using Tango.FSE.Common.Console; namespace Tango.FSE.PPCConsole.ViewModels { @@ -12,6 +15,9 @@ namespace Tango.FSE.PPCConsole.ViewModels { private List _lastSuggestions; + [TangoInject] + public IConsoleService ConsoleService { get; set; } + private ConsoleControlVM _consoleVM; public ConsoleControlVM ConsoleVM { @@ -27,17 +33,34 @@ namespace Tango.FSE.PPCConsole.ViewModels ConsoleVM.Clear(); } + public override void OnApplicationStarted() + { + ConsoleService.Initialized += ConsoleService_Initialized; + } + + private void ConsoleService_Initialized(object sender, EventArgs e) + { + ConsoleVM.Clear(); + ConsoleVM.CurrentCommand.WorkingFolder = ConsoleService.CurrentDirectory; + } + private async void ConsoleVM_CommandExecuting(object sender, ConsoleCommandExecutingEventArgs e) { try { - var result = await MachineProvider.MachineOperator.SendGenericRequest(new ConsoleCommandDTO() + var response = await ConsoleService.ExecuteCommand(new ConsoleCommandRequest() { Command = e.Command.CommandText, WorkingFolder = e.Command.WorkingFolder, }); - _lastSuggestions = result.Suggestions; - e.Complete(result); + + _lastSuggestions = response.Suggestions; + e.Complete(new ConsoleCommandExecutionResult() + { + Output = response.Output, + Suggestions = response.Suggestions, + WorkingFolder = response.WorkingFolder + }); } catch (Exception ex) { diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MainViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MainViewVM.cs index cd12bcdd9..8b9c4169a 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MainViewVM.cs @@ -13,6 +13,30 @@ namespace Tango.FSE.PPCConsole.ViewModels { public class MainViewVM : FSEViewModel { + public enum NavigationView + { + ConsoleView, + RemoteDesktopView, + } + + private NavigationView _selectedView; + public NavigationView SelectedView + { + get { return _selectedView; } + set + { + _selectedView = value; + RaisePropertyChangedAuto(); + } + } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + SelectedView = NavigationView.RemoteDesktopView; + } + + public override void OnApplicationReady() { base.OnApplicationReady(); diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/ConsoleView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/ConsoleView.xaml index 0a26fc8b4..1aad6fa58 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/ConsoleView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/ConsoleView.xaml @@ -11,8 +11,8 @@ mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:ConsoleViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.ConsoleViewVM}"> - - + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml index 1f47bf832..1b7a6ceea 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml @@ -4,42 +4,41 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:global="clr-namespace:Tango.FSE.PPCConsole" + xmlns:resolution="clr-namespace:Tango.FSE.Common.Resolution;assembly=Tango.FSE.Common" xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz" xmlns:vm="clr-namespace:Tango.FSE.PPCConsole.ViewModels" xmlns:local="clr-namespace:Tango.FSE.PPCConsole.Views" xmlns:console="clr-namespace:Tango.Console;assembly=Tango.Console" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:commonControls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" + xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" mc:Ignorable="d" d:DesignHeight="720" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> - + + + + + + + + + + + - - - - - - - - - - - - - - - - + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml index 110fcbcbd..644bfabba 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml @@ -5,11 +5,13 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:global="clr-namespace:Tango.FSE.PPCConsole" xmlns:vm="clr-namespace:Tango.FSE.PPCConsole.ViewModels" + xmlns:resolution="clr-namespace:Tango.FSE.Common.Resolution;assembly=Tango.FSE.Common" xmlns:local="clr-namespace:Tango.FSE.PPCConsole.Views" + xmlns:controls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" xmlns:console="clr-namespace:Tango.Console;assembly=Tango.Console" xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" mc:Ignorable="d" - d:DesignHeight="800" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:RemoteDesktopViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.RemoteDesktopViewVM}" Foreground="{StaticResource FSE_PrimaryForegroundBrush}"> + d:DesignHeight="720" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:RemoteDesktopViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.RemoteDesktopViewVM}" Foreground="{StaticResource FSE_PrimaryForegroundBrush}"> @@ -39,36 +41,147 @@ - + - + + + + - REMOTE DESKTOP - - - - + REMOTE DESKTOP + + + + + + + + + - + + + + Remote desktop allows you to view and control the currently connected machine tablet PC screen. + + Press 'start' to start a remote desktop session. + + + + + + + + + + + + + + + + + + + + + + + + + STOP + START + + + + + Actions + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/FileSystemView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/FileSystemView.xaml.cs new file mode 100644 index 000000000..87fc7e30c --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/FileSystemView.xaml.cs @@ -0,0 +1,42 @@ +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.FSE.PPCConsole.Views +{ + /// + /// Interaction logic for FileSystemView.xaml + /// + public partial class FileSystemView : UserControl + { + private object _lastSelectedItem; + + public FileSystemView() + { + InitializeComponent(); + } + + private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (listView.SelectedItem != null) + { + _lastSelectedItem = listView.SelectedItem; + } + else + { + listView.SelectedItem = _lastSelectedItem; + } + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml index e046340fc..e11014515 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml @@ -33,7 +33,7 @@ - + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FileSystemControl.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FileSystemControl.cs new file mode 100644 index 000000000..dc1da7384 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FileSystemControl.cs @@ -0,0 +1,26 @@ +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; +using Tango.FileSystem; + +namespace Tango.FSE.Common.Controls +{ + public class FileSystemControl : FileExplorerControl + { + static FileSystemControl() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(FileSystemControl), new FrameworkPropertyMetadata(typeof(FileSystemControl))); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FileSystemControl.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FileSystemControl.xaml new file mode 100644 index 000000000..ec490e893 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FileSystemControl.xaml @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Controls.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Controls.xaml index 76c5184e8..420af935c 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Controls.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Controls.xaml @@ -8,6 +8,7 @@ + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml index f19f7a9ab..5ff141bd7 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml @@ -466,6 +466,7 @@ + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj index b879449c5..f61b59da3 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj @@ -91,6 +91,7 @@ ConnectedMachineIcon.xaml + @@ -145,6 +146,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -286,6 +291,10 @@ {63561e19-ff5a-414b-a5ef-e30711543e1d} Tango.Emulations + + {c6ebbbbe-2123-44dc-aef7-a0d47d736ac0} + Tango.FileSystem + {4206ac58-3b57-4699-8835-90bf6db01a61} Tango.Integration diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/ByteArrayToFileSizeConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/ByteArrayToFileSizeConverter.cs index 5a2975535..d26ea5a0a 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Converters/ByteArrayToFileSizeConverter.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/ByteArrayToFileSizeConverter.cs @@ -39,7 +39,7 @@ namespace Tango.SharedUI.Converters long bytes = Math.Abs(byteCount); int place = System.Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024))); double num = Math.Round(bytes / Math.Pow(1024, place), 1); - return (Math.Sign(byteCount) * num).ToString() + suf[place]; + return (Math.Sign(byteCount) * num).ToString() + " " + suf[place]; } } } -- cgit v1.3.1 From b188d7bfd91062f65474bd139bb8a434694f117b Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 15 Mar 2020 15:46:03 +0200 Subject: Fixed issue with job run start date. Fixed issue with ActionLogs busy indication. --- .../ViewModels/MainViewVM.cs | 71 ++++++++++++---------- .../Views/MainView.xaml | 2 +- .../ViewModels/JobRunsViewVM.cs | 23 ++++--- .../JobRuns/BasicJobRunsLogger.cs | 4 +- .../Tango.Integration/Operation/MachineOperator.cs | 9 +++ .../Operation/PrintingEventArgs.cs | 1 + 6 files changed, 63 insertions(+), 47 deletions(-) (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs index 534bb364f..df2643d88 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs @@ -16,12 +16,15 @@ using Tango.BL.ValueObjects; using Tango.Core.Commands; using Tango.Core.ExtensionMethods; using Tango.MachineStudio.Common; +using Tango.MachineStudio.Common.Notifications; using Tango.SharedUI.Components; namespace Tango.MachineStudio.ActionLogs.ViewModels { public class MainViewVM : StudioViewModel { + private INotificationProvider _notification; + #region Properties private DateTime _startSelectedDate; @@ -83,30 +86,23 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels set { _differenceObject = value; RaisePropertyChangedAuto(); } } - - private bool _isRunning; - public bool IsRunning - { - get { return _isRunning; } - set { _isRunning = value; } - } - #endregion public RelayCommand SearchCommand { get; set; } public RelayCommand CopyToClipBoardCommand { get; set; } public RelayCommand CopyRelateObjectIDCommand { get; set; } - public MainViewVM() + public MainViewVM(INotificationProvider notification) { + _notification = notification; + ActionLogs = new ObservableCollection(); - SearchCommand = new RelayCommand(GetActionLogs, () => !IsRunning); + SearchCommand = new RelayCommand(GetActionLogs, () => IsFree); CopyRelateObjectIDCommand = new RelayCommand(CopyRelateObjectID); CopyToClipBoardCommand = new RelayCommand(CopyToClipBoard, () => SelectedActionLog != null && SelectedActionLog.DifferenceObject != null); DateTime now = DateTime.Now; StartSelectedDate = now.AddMonths(-1); EndSelectedDate = now; - _isRunning = false; var source = Enum.GetValues(typeof(ActionLogType)).Cast().ToObservableCollection(); var syncedSource = Enum.GetValues(typeof(ActionLogType)).Cast().ToObservableCollection(); @@ -139,27 +135,40 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels if (String.IsNullOrWhiteSpace(filter)) filter = null; - using (ObservablesContext db = ObservablesContext.CreateDefault()) + try + { + IsFree = false; + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + + DateTime startUtc = new DateTime(StartSelectedDate.Date.Ticks, DateTimeKind.Utc); + TimeSpan offsetTime = (EndSelectedDate.Date == DateTime.Now.Date) ? DateTime.Now.TimeOfDay : new TimeSpan(24, 0, 0); + DateTime endUtc = new DateTime(EndSelectedDate.Date.Ticks + offsetTime.Ticks, DateTimeKind.Utc); + + Debug.Write($"TEST TIME {startUtc} from {endUtc} " + System.Environment.NewLine); + + ActionLogs = await new ActionLogsCollectionBuilder(db).Set(x => x.LastUpdated <= DbFunctions.TruncateTime(endUtc) && x.LastUpdated >= DbFunctions.TruncateTime(startUtc)) + .WithUsers() + .WithActionType(SelectedActionLogTypes.SynchedSource.ToArray()) + .Query(y => y.Where + (x => filter == null || + (x.ID.ToString().ToLower().StartsWith(filter) + || (x.RelatedObjectName != null && x.RelatedObjectName.ToLower().StartsWith(filter)) + || (x.RelatedObjectGuid != null && x.RelatedObjectGuid.ToLower().StartsWith(filter)) + || (x.User != null && x.User.Contact != null && x.User.Contact.FullName.ToLower().StartsWith(filter))))) + .BuildAsync(); + } + } + catch (Exception ex) + { + IsFree = true; + LogManager.Log(ex, "Error getting action logs."); + _notification.ShowError($"Error occurred while trying to retrieve the action logs.\n{ex.Message}"); + } + finally { - - DateTime startUtc = new DateTime(StartSelectedDate.Date.Ticks, DateTimeKind.Utc); - TimeSpan offsetTime = (EndSelectedDate.Date == DateTime.Now.Date) ? DateTime.Now.TimeOfDay : new TimeSpan(24, 0, 0); - DateTime endUtc = new DateTime(EndSelectedDate.Date.Ticks + offsetTime.Ticks, DateTimeKind.Utc); - - Debug.Write($"TEST TIME {startUtc} from {endUtc} " + System.Environment.NewLine); - - IsRunning = true; - ActionLogs = await new ActionLogsCollectionBuilder(db).Set(x => x.LastUpdated <= DbFunctions.TruncateTime(endUtc) && x.LastUpdated >= DbFunctions.TruncateTime(startUtc)) - .WithUsers() - .WithActionType(SelectedActionLogTypes.SynchedSource.ToArray()) - .Query(y => y.Where - (x => filter == null || - (x.ID.ToString().ToLower().StartsWith(filter) - || (x.RelatedObjectName != null && x.RelatedObjectName.ToLower().StartsWith(filter)) - || (x.RelatedObjectGuid != null && x.RelatedObjectGuid.ToLower().StartsWith(filter)) - || (x.User != null && x.User.Contact != null && x.User.Contact.FullName.ToLower().StartsWith(filter))))) - .BuildAsync(); - IsRunning = false; + IsFree = true; } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml index 3a7eaa802..fd640bae5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml @@ -207,7 +207,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs index d57a1c96c..9bf69137d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs @@ -188,7 +188,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels RaisePropertyChangedAuto(); } } - + public StatisticsValueCollection StatisticsValueCollection { get; set; } #endregion @@ -253,7 +253,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels { using (ObservablesContext db = ObservablesContext.CreateDefault()) { - return db.Jobs.Where(x => x.Name!= null && x.Name.ToLower().Contains(filter.ToLower())).ToList(); + return db.Jobs.Where(x => x.Name != null && x.Name.ToLower().Contains(filter.ToLower())).ToList(); } } else @@ -267,7 +267,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels return null; } }); - + StatisticsValueCollection = new StatisticsValueCollection(); } @@ -326,7 +326,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels .WithJobStatus(JobRunSelectedStatuses.SynchedSource) .WithGradient(IsGradientSelection.SynchedSource) .WithRmls(SelectedThreads.SynchedSource.Select(x => x.Guid).ToList()) - .Query(y => y.Where(x => ( String.IsNullOrEmpty(jobName) || x.JobName.ToLower().StartsWith(jobName.ToLower())) + .Query(y => y.Where(x => (String.IsNullOrEmpty(jobName) || x.JobName.ToLower().StartsWith(jobName.ToLower())) && (x.JobLength < LengthUpperValue && x.JobLength >= LengthLowerValue))) .BuildListAsync(); @@ -343,7 +343,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels GenerateStatistics(); } - + } catch (Exception ex) { @@ -387,9 +387,8 @@ namespace Tango.MachineStudio.Statistics.ViewModels protected void GenerateUploadDuration() { - var val = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.UploadDuration != null).Average(x => x.UploadDuration.Value.Ticks); - TimeSpan ts = new TimeSpan(Convert.ToInt64(val)); - StatisticsValueCollection.AddStatisticsValue("Average Upload Duration", Math.Max(ts.TotalMinutes, 0), " minutes"); + var val = (long)JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.UploadDuration != null).Average(x => x.UploadDuration.Value.TotalMilliseconds); + StatisticsValueCollection.AddStatisticsValue("Average Upload Duration", Math.Max(TimeSpan.FromMilliseconds(val).TotalMinutes, 0), " minutes"); } protected void GenerateHeatingDuration() @@ -425,18 +424,18 @@ namespace Tango.MachineStudio.Statistics.ViewModels protected void CreateThreadConsumptionPerThread() { var temp = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.Rml != null).GroupBy(x => x.Rml.Name); - List result = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.Rml != null && !String.IsNullOrEmpty(z.Rml.Name)).GroupBy(x => x.Rml.Name).Select(y => new StatisticsValue { Name = y.Key, Value = y.Sum(x => x.JobRun.EndPosition), Unit="m" }).ToList(); + List result = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.Rml != null && !String.IsNullOrEmpty(z.Rml.Name)).GroupBy(x => x.Rml.Name).Select(y => new StatisticsValue { Name = y.Key, Value = y.Sum(x => x.JobRun.EndPosition), Unit = "m" }).ToList(); StatisticsValueCollection.CreateThreadConsumptionPerThread(result); } protected void GenerateAllLiquidQuantities() { - var db_liquidQuantities = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.JobRun.LiquidQuantities.Count > 0).Select(y=> y.JobRun.LiquidQuantities).ToList(); + var db_liquidQuantities = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.JobRun.LiquidQuantities.Count > 0).Select(y => y.JobRun.LiquidQuantities).ToList(); List allLiquidQuantities = new List(); - + foreach (LiquidTypes ltype in (LiquidTypes[])Enum.GetValues(typeof(LiquidTypes))) { - var liquidQuantityByTypeList = db_liquidQuantities.Select(x => x.SingleOrDefault(y => y.LiquidType == ltype)).Where(x=>x!=null); + var liquidQuantityByTypeList = db_liquidQuantities.Select(x => x.SingleOrDefault(y => y.LiquidType == ltype)).Where(x => x != null); var count = liquidQuantityByTypeList != null ? liquidQuantityByTypeList.Sum(x => x.Quantity) : 0; JobRunLiquidQuantity lq = new JobRunLiquidQuantity() { LiquidType = ltype, Quantity = count }; allLiquidQuantities.Add(lq); diff --git a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs index f2fb2f16e..0fadd1baa 100644 --- a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs +++ b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs @@ -17,7 +17,6 @@ namespace Tango.Integration.JobRuns /// public class BasicJobRunsLogger : ExtendedObject, IJobRunsLogger { - private DateTime _start_date; private Job _job; #region Properties @@ -96,7 +95,7 @@ namespace Tango.Integration.JobRuns JobRun run = new JobRun(); run.UserGuid = _job.UserGuid; - run.StartDate = _start_date; + run.StartDate = e.StartDate; run.UploadingStartDate = e.UploadingStartTime; run.HeatingStartDate = e.HeatingStartTime; run.ActualStartDate = e.ActualStartTime; @@ -187,7 +186,6 @@ namespace Tango.Integration.JobRuns private void Machine_PrintingStarted(object sender, PrintingEventArgs e) { _job = e.Job; - _start_date = DateTime.UtcNow; } #endregion diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 9768498c6..b17321942 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -75,6 +75,8 @@ namespace Tango.Integration.Operation private List _currentJobLiquidQuantities; private DateTime _diagnosticsTime; private MachineStatus _machineStatusBeforeJobStart; + + private DateTime _jobStartDate; private DateTime? _jobUploadingStartDate; private DateTime? _jobHeatingStartDate; private DateTime? _jobActualStartDate; @@ -1050,6 +1052,7 @@ namespace Tango.Integration.Operation PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, job) { LiquidQuantities = _currentJobLiquidQuantities.ToList(), + StartDate = _jobStartDate, }); } @@ -1063,6 +1066,7 @@ namespace Tango.Integration.Operation PrintingCompleted?.Invoke(this, new PrintingEventArgs(handler, job) { LiquidQuantities = _currentJobLiquidQuantities.ToList(), + StartDate = _jobStartDate, UploadingStartTime = _jobUploadingStartDate, HeatingStartTime = _jobHeatingStartDate, ActualStartTime = _jobActualStartDate, @@ -1082,6 +1086,7 @@ namespace Tango.Integration.Operation PrintingFailed?.Invoke(this, new PrintingFailedEventArgs(handler, job, exception) { LiquidQuantities = _currentJobLiquidQuantities.ToList(), + StartDate = _jobStartDate, UploadingStartTime = _jobUploadingStartDate, HeatingStartTime = _jobHeatingStartDate, ActualStartTime = _jobActualStartDate, @@ -1099,6 +1104,7 @@ namespace Tango.Integration.Operation PrintingAborted?.Invoke(this, new PrintingEventArgs(handler, job) { LiquidQuantities = _currentJobLiquidQuantities.ToList(), + StartDate = _jobStartDate, UploadingStartTime = _jobUploadingStartDate, HeatingStartTime = _jobHeatingStartDate, ActualStartTime = _jobActualStartDate, @@ -1116,6 +1122,7 @@ namespace Tango.Integration.Operation PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, job) { LiquidQuantities = _currentJobLiquidQuantities.ToList(), + StartDate = _jobStartDate, UploadingStartTime = _jobUploadingStartDate, HeatingStartTime = _jobHeatingStartDate, ActualStartTime = _jobActualStartDate, @@ -2159,6 +2166,8 @@ namespace Tango.Integration.Operation throw new InvalidOperationException("Could not print while status = " + Status); } + _jobStartDate = DateTime.UtcNow; + LogManager.Log($"Executing job '{job.Name}'..."); _currentJobLiquidQuantities = new List(); diff --git a/Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs b/Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs index f68204127..b088b9046 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs @@ -13,6 +13,7 @@ namespace Tango.Integration.Operation public JobHandler JobHandler { get; private set; } public Job Job { get; private set; } public List LiquidQuantities { get; set; } + public DateTime StartDate { get; set; } public DateTime? UploadingStartTime { get; set; } public DateTime? HeatingStartTime { get; set; } public DateTime? ActualStartTime { get; set; } -- cgit v1.3.1