From dc519b8dbd294a2a956f051bca63a30eb9c07986 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Fri, 14 Aug 2020 16:41:24 +0300 Subject: PPC Technician Module -> Remote Connections. --- .../Images/remote_connections.png | Bin 0 -> 4186 bytes .../Tango.PPC.Technician.csproj | 11 +++ .../Tango.PPC.Technician/ViewModelLocator.cs | 12 +++ .../ViewModels/RemoteConnectionsViewVM.cs | 64 +++++++++++++++ .../Tango.PPC.Technician/Views/CatalogView.xaml | 12 +++ .../Tango.PPC.Technician/Views/MainView.xaml | 1 + .../Views/RemoteConnectionsView.xaml | 88 +++++++++++++++++++++ .../Views/RemoteConnectionsView.xaml.cs | 28 +++++++ 8 files changed, 216 insertions(+) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/remote_connections.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/RemoteConnectionsViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/RemoteConnectionsView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/RemoteConnectionsView.xaml.cs (limited to 'Software/Visual_Studio/PPC/Modules') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/remote_connections.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/remote_connections.png new file mode 100644 index 000000000..d9d4a1d45 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/remote_connections.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj index e8eec7b2f..7f36b7b17 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj @@ -106,11 +106,15 @@ + CatalogView.xaml + + RemoteConnectionsView.xaml + UpdatesView.xaml @@ -219,6 +223,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -272,5 +280,8 @@ + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs index d50df6a01..9a8b63c91 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs @@ -22,6 +22,7 @@ namespace Tango.PPC.Technician TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); + TangoIOC.Default.Register(); } /// @@ -100,5 +101,16 @@ namespace Tango.PPC.Technician return TangoIOC.Default.GetInstance(); } } + + /// + /// Gets the remote connections view vm. + /// + public static RemoteConnectionsViewVM RemoteConnectionsViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/RemoteConnectionsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/RemoteConnectionsViewVM.cs new file mode 100644 index 000000000..2d8857329 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/RemoteConnectionsViewVM.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.Integration.ExternalBridge; +using Tango.PPC.Common; + +namespace Tango.PPC.Technician.ViewModels +{ + public class RemoteConnectionsViewVM : PPCViewModel + { + public RelayCommand DisconnectCommand { get; set; } + + private ExternalBridgeReceiver _selectedReceiver; + public ExternalBridgeReceiver SelectedReceiver + { + get { return _selectedReceiver; } + set + { + if (value != null) + { + _selectedReceiver = value; + InvalidateRelayCommands(); + } + } + } + + public RemoteConnectionsViewVM() + { + DisconnectCommand = new RelayCommand(DisconnectReceiver, () => SelectedReceiver != null); + } + + private async void DisconnectReceiver() + { + if (SelectedReceiver != null) + { + try + { + await Task.Factory.StartNew(() => + { + SelectedReceiver.Disconnect().Wait(); + }); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error disconnecting the specified receiver."); + } + finally + { + _selectedReceiver = null; + RaisePropertyChanged(nameof(SelectedReceiver)); + InvalidateRelayCommands(); + } + } + } + + public override void OnApplicationStarted() + { + + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml index 8f4bc9f0b..f954e461f 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml @@ -105,6 +105,18 @@ + + + + + Remote Connections + + View the current status of remote connections to this machine. + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml index d669de187..d4235341c 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml @@ -19,6 +19,7 @@ + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/RemoteConnectionsView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/RemoteConnectionsView.xaml new file mode 100644 index 000000000..af93a56e5 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/RemoteConnectionsView.xaml @@ -0,0 +1,88 @@ + + + + + + + + + + + + Remote Connections + + + + + + DISCONNECT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/RemoteConnectionsView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/RemoteConnectionsView.xaml.cs new file mode 100644 index 000000000..5d8e32444 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/RemoteConnectionsView.xaml.cs @@ -0,0 +1,28 @@ +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.PPC.Technician.Views +{ + /// + /// Interaction logic for RemoteConnectionsView.xaml + /// + public partial class RemoteConnectionsView : UserControl + { + public RemoteConnectionsView() + { + InitializeComponent(); + } + } +} -- cgit v1.3.1 From 9d5f73560e6629634965291f7fe2895fa59e34ab Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Fri, 14 Aug 2020 19:45:44 +0300 Subject: Added application start logs viewing to FSE & PPC using LogSafe. --- .../FSE/Tango.FSE.Common/Helpers/LogsHelper.cs | 24 +++++++++++++ .../FSE/Tango.FSE.Common/Tango.FSE.Common.csproj | 1 + .../Visual_Studio/FSE/Tango.FSE.UI/App.xaml.cs | 4 +-- .../FSE/Tango.FSE.UI/Panes/LogViewerPaneVM.cs | 8 +++++ .../ViewModels/LoggingViewVM.cs | 8 +++++ .../PPC/Tango.PPC.Common/Helpers/LogsHelper.cs | 24 +++++++++++++ .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 3 +- .../Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs | 9 +++-- Software/Visual_Studio/Tango.Logging/LogManager.cs | 9 +++++ Software/Visual_Studio/Tango.Logging/LogSafe.cs | 39 ++++++++++++++++++++++ .../Tango.Logging/Tango.Logging.csproj | 3 +- 11 files changed, 126 insertions(+), 6 deletions(-) create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Helpers/LogsHelper.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Helpers/LogsHelper.cs create mode 100644 Software/Visual_Studio/Tango.Logging/LogSafe.cs (limited to 'Software/Visual_Studio/PPC/Modules') diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Helpers/LogsHelper.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Helpers/LogsHelper.cs new file mode 100644 index 000000000..eac030fb8 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Helpers/LogsHelper.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Logging; + +namespace Tango.FSE.Common.Helpers +{ + public static class LogsHelper + { + private static LogSafe _logSafe; + + public static void SetLogSafe(LogSafe logSafe) + { + _logSafe = logSafe; + } + + public static LogSafe GetLogSafe() + { + return _logSafe; + } + } +} 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 a4668edb4..6c7ffb7ed 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 @@ -192,6 +192,7 @@ + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/App.xaml.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/App.xaml.cs index e0c6de0e1..6bec431fa 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/App.xaml.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/App.xaml.cs @@ -84,8 +84,8 @@ namespace Tango.FSE.UI operatorLogger.EnableMaxFileSizeLimit = true; } - LogManager.Log("Application Started..."); - LogManager.Log($"Application Version: '{AssemblyHelper.GetCurrentAssemblyVersion()}'."); + LogsHelper.SetLogSafe(LogManager.CreateLogSafe()); + LogManager.Log($"Application Started... Version: '{AssemblyHelper.GetCurrentAssemblyVersion()}'."); WebRequest.DefaultWebProxy = null; diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/LogViewerPaneVM.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/LogViewerPaneVM.cs index 050b17dcc..2add8f473 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/LogViewerPaneVM.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/LogViewerPaneVM.cs @@ -12,6 +12,7 @@ using Tango.Core.DI; using Tango.FSE.Common; using Tango.FSE.Common.Connection; using Tango.FSE.Common.Dialogs; +using Tango.FSE.Common.Helpers; using Tango.Integration.Logging; using Tango.Logging; using Tango.SharedUI.Components; @@ -232,6 +233,13 @@ namespace Tango.FSE.UI.Panes TangoIOC.Default.Inject(this); + var appStartLogs = LogsHelper.GetLogSafe().EmptyAndDispose(); + + foreach (var log in appStartLogs) + { + FSELogs.Insert(0, log); + } + LoggingProvider.FSELogAvailable += LoggingProvider_FSELogAvailable; LoggingProvider.ApplicationLogAvailable += LoggingProvider_ApplicationLogAvailable; LoggingProvider.FirmwareLogAvailable += LoggingProvider_FirmwareLogAvailable; diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs index a0110b18a..2aee7f561 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs @@ -12,6 +12,7 @@ using Tango.Integration.Logging; using Tango.Integration.Operation; using Tango.Logging; using Tango.PPC.Common; +using Tango.PPC.Common.Helpers; using Tango.PPC.Technician.Dialogs; namespace Tango.PPC.Technician.ViewModels @@ -86,6 +87,13 @@ namespace Tango.PPC.Technician.ViewModels paused_logs = new List(); paused_embedded_logs = new List(); + var appStartLogs = LogsHelper.GetLogSafe().EmptyAndDispose(); + + foreach (var log in appStartLogs) + { + ApplicationLogs.Insert(0, log); + } + LogManager.NewLog += LogManager_NewLog; MachineOperator.EmbeddedLogManager.NewLog += EmbeddedLogManager_NewLog; ClearCommand = new RelayCommand(ClearLogs); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Helpers/LogsHelper.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Helpers/LogsHelper.cs new file mode 100644 index 000000000..b7ab2d5b8 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Helpers/LogsHelper.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Logging; + +namespace Tango.PPC.Common.Helpers +{ + public static class LogsHelper + { + private static LogSafe _logSafe; + + public static void SetLogSafe(LogSafe logSafe) + { + _logSafe = logSafe; + } + + public static LogSafe GetLogSafe() + { + return _logSafe; + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 32f3b865b..b15ca60bd 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -160,6 +160,7 @@ + @@ -476,7 +477,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs index 7d8304209..78536803c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs @@ -17,6 +17,7 @@ using Tango.Integration.Operation; using Tango.Logging; using Tango.PPC.Common; using Tango.PPC.Common.EventLogging; +using Tango.PPC.Common.Helpers; using Tango.PPC.Common.Notifications; using Tango.PPC.Common.WatchDog; using Tango.Settings; @@ -55,7 +56,10 @@ namespace Tango.PPC.UI //LogManager.RegisterLogger(new ConsoleLogger("Tango PPC Debug")); LogManager.RegisterLogger(new FileLogger() { EnableAutoLogRemoval = true, EnableMaxFileSizeLimit = true }); + +#if DEBUG LogManager.RegisterLogger(new VSOutputLogger()); +#endif //Configure machine operator logger. var operatorLogger = MachineOperator.EmbeddedLogManager.RegisteredLoggers.SingleOrDefault(x => x is FileLogger) as FileLogger; @@ -65,8 +69,9 @@ namespace Tango.PPC.UI operatorLogger.EnableMaxFileSizeLimit = true; } - LogManager.Log("Application Started..."); - LogManager.Log($"Application Version: '{AssemblyHelper.GetCurrentAssemblyVersion()}'."); + + LogsHelper.SetLogSafe(LogManager.CreateLogSafe()); + LogManager.Log($"Application Started... Version: '{AssemblyHelper.GetCurrentAssemblyVersion()}'."); base.OnStartup(e); diff --git a/Software/Visual_Studio/Tango.Logging/LogManager.cs b/Software/Visual_Studio/Tango.Logging/LogManager.cs index 55264164a..4148fa342 100644 --- a/Software/Visual_Studio/Tango.Logging/LogManager.cs +++ b/Software/Visual_Studio/Tango.Logging/LogManager.cs @@ -259,5 +259,14 @@ namespace Tango.Logging NewLog?.Invoke(this, log); } } + + /// + /// Creates a new log safe which can be used to keep logs and then be disposed. + /// + /// + public LogSafe CreateLogSafe() + { + return new LogSafe(this); + } } } diff --git a/Software/Visual_Studio/Tango.Logging/LogSafe.cs b/Software/Visual_Studio/Tango.Logging/LogSafe.cs new file mode 100644 index 000000000..2da51e90c --- /dev/null +++ b/Software/Visual_Studio/Tango.Logging/LogSafe.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Logging +{ + public class LogSafe : IDisposable + { + private LogManager _logManager; + private List Logs { get; set; } + + public LogSafe(LogManager logManager) + { + _logManager = logManager; + Logs = new List(); + logManager.NewLog += LogManager_NewLog; + } + + private void LogManager_NewLog(object sender, LogItemBase log) + { + Logs.Add(log); + } + + public List EmptyAndDispose() + { + var list = Logs.ToList(); + Dispose(); + return list; + } + + public void Dispose() + { + _logManager.NewLog -= LogManager_NewLog; + Logs.Clear(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj b/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj index e2e2b1edd..d9a2e1139 100644 --- a/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj +++ b/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj @@ -63,6 +63,7 @@ + @@ -82,7 +83,7 @@ - + \ No newline at end of file -- cgit v1.3.1