From 35cef16ffc96b06f68f122361ea84030169bb730 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 10 Feb 2020 13:33:02 +0200 Subject: Some fixes on transport layer. Fix on machine operator upgrade firmware.. Fix on SessionFileLogger. Fix on PPC jobs view. Fix on Tech Catalog View. --- .../Machine Studio Installer.aip | 37 +- .../Advanced Installer Projects/PPC Installer.aip | 578 ++++++++++++-------- .../PPC Installer.back.aip | 598 +++++++++++++++++++++ .../DefaultStudioApplicationManager.cs | 30 +- .../Tango.PPC.Browser/ViewModels/BrowserViewVM.cs | 17 +- .../PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml | 14 +- .../Tango.PPC.Technician/Views/CatalogView.xaml | 151 +++--- .../PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs | 2 +- .../Tango.Integration/Operation/MachineOperator.cs | 3 +- .../Tango.Logging/SessionFileLogger.cs | 14 +- .../Tango.Transport/Tango.Transport.csproj | 2 +- .../Tango.Transport/TransportAdapterBase.cs | 7 +- .../Tango.Transport/TransporterBase.cs | 67 ++- 13 files changed, 1160 insertions(+), 360 deletions(-) create mode 100644 Software/Visual_Studio/Advanced Installer Projects/PPC Installer.back.aip (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip index bfc3229b5..f46fca7d5 100644 --- a/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip +++ b/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip @@ -16,10 +16,10 @@ - + - + @@ -79,6 +79,7 @@ + @@ -120,7 +121,6 @@ - @@ -273,11 +273,11 @@ + - + - @@ -287,6 +287,7 @@ + @@ -302,14 +303,14 @@ - + - + - + @@ -625,8 +626,6 @@ - - @@ -721,9 +720,6 @@ - - - @@ -795,6 +791,14 @@ + + + + + + + + @@ -806,7 +810,7 @@ - + @@ -1143,7 +1147,6 @@ - @@ -1180,7 +1183,6 @@ - @@ -1267,6 +1269,9 @@ + + + diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip index 6000cea68..5a12ce7cd 100644 --- a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip +++ b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip @@ -1,5 +1,5 @@ - + @@ -18,10 +18,10 @@ - + - + @@ -49,6 +49,7 @@ + @@ -66,6 +67,7 @@ + @@ -186,222 +188,224 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -411,7 +415,7 @@ - + @@ -478,6 +482,7 @@ + @@ -511,6 +516,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.back.aip b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.back.aip new file mode 100644 index 000000000..6000cea68 --- /dev/null +++ b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.back.aip @@ -0,0 +1,598 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index 2c3c9ccb9..ed5f8b394 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -42,6 +42,7 @@ namespace Tango.MachineStudio.UI.StudioApplication private INotificationProvider _notification; private List _openedWindows; private List _notified_view_models; + private bool _isDialogShown; /// /// Occurs when the application is ready. @@ -139,19 +140,28 @@ namespace Tango.MachineStudio.UI.StudioApplication { String failed_reason = (sender as IMachineOperator).FailedStateException.Message; - ConnectionLostViewVM vm = new ConnectionLostViewVM() + if (!_isDialogShown) { - Exception = failed_reason, - AutoReconnect = reconnect, - }; + _isDialogShown = true; - InvokeUI(() => - { - _notification.ShowModalDialog(vm, (x) => + ConnectionLostViewVM vm = new ConnectionLostViewVM() + { + Exception = failed_reason, + AutoReconnect = reconnect, + }; + + InvokeUI(() => { - ReconnectionRequired?.Invoke(this, new EventArgs()); - }, () => { }); - }); + _notification.ShowModalDialog(vm, (x) => + { + _isDialogShown = false; + ReconnectionRequired?.Invoke(this, new EventArgs()); + }, () => + { + _isDialogShown = false; + }); + }); + } } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/BrowserViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/BrowserViewVM.cs index 9650aa342..0f5a49639 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/BrowserViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/BrowserViewVM.cs @@ -1,4 +1,5 @@ -using System; +using CefSharp; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -95,6 +96,20 @@ namespace Tango.PPC.Browser.ViewModels } + public override void OnApplicationShuttingDown() + { + base.OnApplicationShuttingDown(); + + try + { + Cef.Shutdown(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error shutting down cef."); + } + } + private void Go() { if (View != null) diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml index cabcb44b9..94abe6b83 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml @@ -214,14 +214,14 @@ - + - + @@ -235,7 +235,7 @@ - + @@ -314,21 +314,21 @@ - + - + - + @@ -342,7 +342,7 @@ - + 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 0eab521e1..8f4bc9f0b 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 @@ -23,100 +23,101 @@ Technician - + + + - + + + - - - + The technician module enables additional diagnostic tools. - The technician module enables additional diagnostic tools. - - - - - - Logging - + + + + + Logging + Display and investigate issues using application and embedded device logs. - + + - - + - - - - - System - + + + + + System + Display system properties, perform system actions, reset, shutdown etc... - + + - - + - - - - - Dispensers - + + + + + Dispensers + Perform manual dispensers homing priming. - + + - - + - - - - - Installed Packages - + + + + + Installed Packages + View the history of update packages installation. - + + - - + - - - - - Updates & Synchronization - + + + + + Updates & Synchronization + View the current status and history of update and synchronization operations. - + + - - + - - - - - Browser - + + + + + Browser + Open the browser module and navigate the web. - + + - - - - + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs index cfe0a03a0..f5b3d427f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs @@ -8,4 +8,4 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango PPC Application")] -[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyVersion("1.1.1.0")] diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 2528746f8..9db3f17e2 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -1236,6 +1236,7 @@ namespace Tango.Integration.Operation } catch (Exception ex) { + SessionLogger.EndSession(); await base.Disconnect(); throw ex; } @@ -3384,7 +3385,7 @@ namespace Tango.Integration.Operation { if (FirmwareUpgradeMode.HasFlag(FirmwareUpgradeModes.DFU)) { - if (!package_info.ContainsMcu()) + if (package_info.ContainsMcu()) { LogManager.Log("DFU enabled. Starting upgrade via DFU..."); LogManager.Log("Extracting MCU file..."); diff --git a/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs b/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs index 079f7f7b5..4e378bfbf 100644 --- a/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs +++ b/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs @@ -57,7 +57,7 @@ namespace Tango.Logging static SessionFileLogger() { DefaultLogsFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "Logs", Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName), "Session"); - + } public SessionFileLogger(String folder, String tag) @@ -82,6 +82,7 @@ namespace Tango.Logging /// public void CreateSession() { + _writeCount = 0; RemoveOldLogFile(); LogFile = CreateLogFileName(); _inInSession = true; @@ -105,17 +106,16 @@ namespace Tango.Logging { try { - if (++_writeCount > FILE_SIZE_CHECK_COUNT && new FileInfo(LogFile).Length > MaxFileSizeLimit) + if (!File.Exists(LogFile) || (++_writeCount > FILE_SIZE_CHECK_COUNT && new FileInfo(LogFile).Length > MaxFileSizeLimit)) { - _writeCount = 0; CreateSession(); - File.AppendAllText(LogFile, "### This log file is a continuation of a previous log file ###" + Environment.NewLine + Environment.NewLine); } + File.AppendAllText(LogFile, output.ToString() + Environment.NewLine); } - catch + catch (Exception ex) { - Debug.WriteLine("Error Writing To Session Log File!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + Debug.WriteLine($"Error Writing To Session Log File!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n{ex.ToString()}"); } } } @@ -160,7 +160,7 @@ namespace Tango.Logging { Debug.WriteLine(ex); } - } + } #endregion } diff --git a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj index 066faea91..260a1e4f7 100644 --- a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj +++ b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj @@ -181,7 +181,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Transport/TransportAdapterBase.cs b/Software/Visual_Studio/Tango.Transport/TransportAdapterBase.cs index b3310a600..d17bde261 100644 --- a/Software/Visual_Studio/Tango.Transport/TransportAdapterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransportAdapterBase.cs @@ -91,8 +91,11 @@ namespace Tango.Transport get { return _state; } protected set { - _state = value; - OnStateChanged(_state); + if (_state != value) + { + _state = value; + OnStateChanged(_state); + } } } diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs index aec7654b1..70feb05f6 100644 --- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs @@ -244,12 +244,41 @@ namespace Tango.Transport /// Called when the component has failed. /// /// The ex. - protected virtual void OnFailed(Exception ex) + protected virtual async void OnFailed(Exception ex) { - FailedStateException = ex; - State = TransportComponentState.Failed; - LogManager.Log(ex, $"{GetExtendedComponentName()}: Transporter failed."); - Disconnect().Wait(); + if (State != TransportComponentState.Failed) + { + FailedStateException = ex; + LogManager.Log(ex, $"{GetExtendedComponentName()}: Transporter failed."); + State = TransportComponentState.Failed; + + await OnPostDisconnection(); + } + else + { + LogManager.Log(ex, LogCategory.Warning, $"{GetExtendedComponentName()}: OnFailed called while state is already failed!"); + } + } + + protected virtual async Task OnPostDisconnection() + { + try + { + if (_pullThread != null) + { + _pullThread.Abort(); + _pushThread.Abort(); + _keepAliveThread.Abort(); + } + } + catch { } + + if (Adapter != null) + { + await Adapter.Disconnect(); + } + + NotifyContinuousRequestMessagesDisconnection(); } /// @@ -419,26 +448,14 @@ namespace Tango.Transport /// public virtual async Task Disconnect() { - State = TransportComponentState.Disconnected; - - try + if (State == TransportComponentState.Connected) { - if (_pullThread != null) - { - _pullThread.Abort(); - _pushThread.Abort(); - _keepAliveThread.Abort(); - } - } - catch { } + State = TransportComponentState.Disconnected; - if (Adapter != null) - { - await Adapter.Disconnect(); - } - LogManager.Log($"{GetExtendedComponentName()}: Transporter Disconnected..."); + await OnPostDisconnection(); - NotifyContinuousRequestMessagesDisconnection(); + LogManager.Log($"{GetExtendedComponentName()}: Transporter Disconnected..."); + } } #endregion @@ -1352,7 +1369,11 @@ namespace Tango.Transport if (container.Type == MessageType.KeepAliveRequest && EnableKeepAliveAutoResponse) { LogManager.Log($"{GetExtendedComponentName()}: Submitting keep alive response...", LogCategory.Debug); - SendResponse(new KeepAliveResponse(), container.Token); + try + { + SendResponse(new KeepAliveResponse(), container.Token); + } + catch { } } else { -- cgit v1.3.1