diff options
| author | Roy <Roy.mail.net@gmail.com> | 2023-04-02 17:24:38 +0300 |
|---|---|---|
| committer | Roy <Roy.mail.net@gmail.com> | 2023-04-02 17:24:38 +0300 |
| commit | ee27897f2d0fbc3a4468b0d8944e532bb9d4275e (patch) | |
| tree | 17439a942c36f95a871d8c58374574dc32f23da6 | |
| parent | 9d278c2e476c383535ee9028e08e229aac4d0237 (diff) | |
| download | Tango-ee27897f2d0fbc3a4468b0d8944e532bb9d4275e.tar.gz Tango-ee27897f2d0fbc3a4468b0d8944e532bb9d4275e.zip | |
Bug fixes.
7 files changed, 57 insertions, 22 deletions
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSESettings.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSESettings.cs index 3c5b4c24a..d6b8bd492 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSESettings.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSESettings.cs @@ -26,6 +26,7 @@ namespace Tango.FSE.Common public ExternalBridgeLoginIntent Intent { get; set; } public bool RequireSafetyLevelOperations { get; set; } public String Password { get; set; } + public bool AutoReconnection { get; set; } } public class StatisticsStreamingConfiguration : ExtendedObject diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs index ffc0e8e60..cf4337508 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs @@ -43,6 +43,7 @@ namespace Tango.FSE.UI.Connection private DateTime _connectionStartTime; private System.Timers.Timer _connectionTimer; private FSEMachineEventsStateProvider _machineEventsStateProvider; + private bool _autoReconnect; [TangoInject] private INotificationProvider NotificationProvider { get; set; } @@ -190,6 +191,8 @@ namespace Tango.FSE.UI.Connection { try { + _autoReconnect = false; + LogManager.Log($"Connecting to machine '{machine.GetType().Name}' => '{machine.SerialNumber}' => '{machine.Adapter?.Address}'..."); IsBusy = true; @@ -213,6 +216,7 @@ namespace Tango.FSE.UI.Connection if (machine.GetType() == typeof(ExternalBridgeTcpClient)) { vm = await NotificationProvider.ShowDialog(new MachineConnectionWifiViewVM(secureClient)); + _autoReconnect = (vm as MachineConnectionWifiViewVM).AutoReconnection; } else { @@ -365,24 +369,27 @@ namespace Tango.FSE.UI.Connection /// <returns></returns> public async Task DisconnectAndWaitForReconnection(TimeSpan beginDelay, TimeSpan timeout, String message = null) { - LogManager.Log("Starting disconnect and wait for machine procedure..."); - LogManager.Log("Disconnecting from current machine..."); - IsBusy = true; - try - { - IsConnected = false; - await MachineOperator.Disconnect(); - LogManager.Log("Machine disconnected."); - } - catch (Exception ex) + if (!_autoReconnect) { - LogManager.Log(ex, "Error disconnecting machine. Never mind..."); - } - finally - { - OnMachineDisconnected(MachineOperator, null); + LogManager.Log("Starting disconnect and wait for machine procedure..."); + LogManager.Log("Disconnecting from current machine..."); + + try + { + IsConnected = false; + await MachineOperator.Disconnect(); + LogManager.Log("Machine disconnected."); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error disconnecting machine. Never mind..."); + } + finally + { + OnMachineDisconnected(MachineOperator, null); + } } bool aborted = false; @@ -484,6 +491,8 @@ namespace Tango.FSE.UI.Connection OnMachineDisconnected(MachineOperator, MachineOperator.FailedStateException); + if (_autoReconnect) return; + InvokeUI(async () => { var vm = await NotificationProvider.ShowDialog<MachineConnectionLostViewVM>(new MachineConnectionLostViewVM(MachineOperator, MachineOperator.FailedStateException.FlattenMessage(), Settings.AutoMachineReconnectionTimeoutSeconds)); @@ -578,6 +587,16 @@ namespace Tango.FSE.UI.Connection MachineOperator = machineOperator, Exception = exception }); + + if (_autoReconnect && exception != null) + { + LogManager.Log("Auto reconnection is activated, trying to reconnect."); + + InvokeUI(async () => + { + await DisconnectAndWaitForReconnection(TimeSpan.FromSeconds(10), TimeSpan.FromHours(1), "The connection with the remote machine has lost, trying to reconnect."); + }); + } } #endregion diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionWifiView.xaml b/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionWifiView.xaml index 0d037e939..5d9a5f74f 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionWifiView.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionWifiView.xaml @@ -31,8 +31,10 @@ <TextBlock Margin="25 0 0 0" Foreground="{StaticResource FSE_WifiBrush}">Machine Password</TextBlock> <StackPanel Orientation="Horizontal" Margin="0 5 0 0"> <materialDesign:PackIcon Kind="LockOpen" Width="20" Height="20" VerticalAlignment="Center" /> - <PasswordBox materialDesign:HintAssist.Hint="●●●●●●●●●●●" Width="300" Margin="5 0 0 0" FontSize="{StaticResource FSE_LargerFontSize}" helpers:PasswordHelper.Attach="True" helpers:PasswordHelper.Password="{Binding Password,Mode=TwoWay}"></PasswordBox> + <PasswordBox materialDesign:HintAssist.Hint="●●●●●●●●●●●" Width="300" Margin="5 0 0 5" FontSize="{StaticResource FSE_LargerFontSize}" helpers:PasswordHelper.Attach="True" helpers:PasswordHelper.Password="{Binding Password,Mode=TwoWay}"></PasswordBox> </StackPanel> + + <CheckBox ToolTip="Keep trying to reconnect when a connection is lost" Margin="22 0 0 0" VerticalAlignment="Center" IsChecked="{Binding AutoReconnection}">Auto Reconnection</CheckBox> </StackPanel> <StackPanel Margin="20 0 0 0" HorizontalAlignment="Right" VerticalAlignment="Center"> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionWifiViewVM.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionWifiViewVM.cs index 740e08ff0..5af64464c 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionWifiViewVM.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionWifiViewVM.cs @@ -53,6 +53,17 @@ namespace Tango.FSE.UI.Dialogs set { _requireSafetyLevelOperations = value; RaisePropertyChangedAuto(); } } + private bool _autoReconnection; + /// <summary> + /// Gets or sets a value indicating whether keep trying to reconnect. + /// </summary> + public bool AutoReconnection + { + get { return _autoReconnection; } + set { _autoReconnection = value; RaisePropertyChangedAuto(); } + } + + private ExternalBridgeTcpClient _machine; /// <summary> /// Gets or sets the selected machine. @@ -97,6 +108,7 @@ namespace Tango.FSE.UI.Dialogs Password = EncryptionHelper.Decrypt(connectionSettings.Password); SelectedIntent = connectionSettings.Intent; RequireSafetyLevelOperations = connectionSettings.RequireSafetyLevelOperations; + AutoReconnection = connectionSettings.AutoReconnection; RememberMachinePassword = true; } } @@ -123,6 +135,7 @@ namespace Tango.FSE.UI.Dialogs connectionSettings.Password = EncryptionHelper.Encrypt(Password); connectionSettings.Intent = SelectedIntent; connectionSettings.RequireSafetyLevelOperations = RequireSafetyLevelOperations; + connectionSettings.AutoReconnection = AutoReconnection; } else { diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/RemoteJobUpload/DefaultRemoteJobUploadProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/RemoteJobUpload/DefaultRemoteJobUploadProvider.cs index 535e5edca..bc2c6e84f 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/RemoteJobUpload/DefaultRemoteJobUploadProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/RemoteJobUpload/DefaultRemoteJobUploadProvider.cs @@ -40,7 +40,7 @@ namespace Tango.FSE.UI.RemoteJobUpload { Type = jobType, Name = Path.GetFileNameWithoutExtension(filePath) - }); + }, new TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(30) }); var handler = await FileSystemProvider.Upload(filePath, uploadResponse.TargetFilePath, true); @@ -54,7 +54,7 @@ namespace Tango.FSE.UI.RemoteJobUpload var completedResponse = await MachineProvider.MachineOperator.SendGenericRequest<RemoteJobUploadCompletedRequest, RemoteJobUploadCompletedResponse>(new RemoteJobUploadCompletedRequest() { ID = uploadResponse.ID - }, new TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(20) }); + }, new TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(30) }); if (completedResponse.Error.IsNotNullOrEmpty()) { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> + <!--<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />--> </requestedPrivileges> </security> </trustInfo> diff --git a/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs b/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs index 1e13cda6d..5f2996014 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs @@ -905,16 +905,16 @@ namespace Tango.BL.Entities if (tables.Count > 0) { - return tables.Max(x => x.MaxInkUptake); + return tables.Max(x => x.MaxInkUptake) + 1; } else { - return MAX_INK_UPTAKE; + return MAX_INK_UPTAKE + 1; } } catch { - return MAX_INK_UPTAKE; + return MAX_INK_UPTAKE + 1; } } |
