diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-10-08 05:07:41 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-10-08 05:07:41 +0300 |
| commit | 810bbfab7a812a0d9f0e46ff60d45280594a6716 (patch) | |
| tree | 70b2f60a34fe93a43961c0eec960c31c79536b54 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI | |
| parent | 4748b626794f346d6c7989413fe76d609966cdf9 (diff) | |
| download | Tango-810bbfab7a812a0d9f0e46ff60d45280594a6716.tar.gz Tango-810bbfab7a812a0d9f0e46ff60d45280594a6716.zip | |
Implemented auto reconnection for USB on MS.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI')
3 files changed, 55 insertions, 36 deletions
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 56f2a2bc0..feed9e193 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -132,8 +132,6 @@ namespace Tango.MachineStudio.UI.StudioApplication { if (e == Transport.TransportComponentState.Disconnected || e == Transport.TransportComponentState.Failed) { - bool reconnect = ConnectedMachine is IExternalBridgeSecureClient; - ConnectedMachine = null; if (e == Transport.TransportComponentState.Failed) @@ -147,7 +145,7 @@ namespace Tango.MachineStudio.UI.StudioApplication ConnectionLostViewVM vm = new ConnectionLostViewVM() { Exception = failed_reason, - AutoReconnect = reconnect, + AutoReconnect = true, }; InvokeUI(() => diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index 78125cd8c..3783b54f8 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -434,6 +434,10 @@ <Project>{63561e19-ff5a-414b-a5ef-e30711543e1d}</Project> <Name>Tango.Emulations</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.Git\Tango.Git.csproj"> + <Project>{99081c0e-065c-4d68-bf60-f82330cca02d}</Project> + <Name>Tango.Git</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.Integration\Tango.Integration.csproj"> <Project>{4206ac58-3b57-4699-8835-90bf6db01a61}</Project> <Name>Tango.Integration</Name> @@ -676,7 +680,7 @@ if $(ConfigurationName) == Release RD /S /Q "$(TargetDir)Roslyn\"</PostBuildEven </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_UseGlobalSettings="False" BuildVersion_DetectChanges="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.DeltaBaseYearDayOfYear" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_BuildVersioningStyle="None.None.Increment.DeltaBaseYearDayOfYear" BuildVersion_UpdateFileVersion="True" BuildVersion_DetectChanges="True" BuildVersion_UseGlobalSettings="False" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index 6ddfee545..4f8c8a9b1 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -58,8 +58,9 @@ namespace Tango.MachineStudio.UI.ViewModels private IEventLogger _eventLogger; private MachineStudioSettings _settings; private MachineStudioWebClient _machineStudioWebClient; - private IExternalBridgeSecureClient _reconnectionMachine; + private IExternalBridgeClient _reconnectionMachine; private MachineLoginViewVM _reconnectionMachineConfig; + private bool _lastUploadHardwareConfigLocal; /// <summary> /// Gets or sets the current loaded module. @@ -350,9 +351,16 @@ namespace Tango.MachineStudio.UI.ViewModels ApplicationManager.ReconnectionRequired += ApplicationManager_ReconnectionRequired; } - private void ApplicationManager_ReconnectionRequired(object sender, EventArgs e) + private async void ApplicationManager_ReconnectionRequired(object sender, EventArgs e) { - ConnectToMachineSecure(_reconnectionMachine, _reconnectionMachineConfig); + if (_reconnectionMachine is IExternalBridgeSecureClient client) + { + ConnectToMachineSecure(client, _reconnectionMachineConfig); + } + else + { + await ConnectToMachineLocal(_reconnectionMachine, _reconnectionMachine.Machine, _lastUploadHardwareConfigLocal); + } } private void MachineEventsStateProvider_EventsResolved(object sender, IEnumerable<MachinesEvent> e) @@ -486,41 +494,15 @@ namespace Tango.MachineStudio.UI.ViewModels { if (vm.SelectedMachine != null) { - using (NotificationProvider.PushTaskItem("Connecting to " + x.SelectedMachine.ToString() + "...")) - { - try - { - await x.SelectedMachine.Connect(); - x.SelectedMachine.SerialNumber = vm.SelectedMachine.SerialNumber; - ApplicationManager.SetConnectedMachine(x.SelectedMachine); - - PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine }); - _settings.LastVirtualMachineSerialNumber = vm.SelectedMachine.SerialNumber; - _settings.Save(); - - if (x.UploadHardwareConfiguration) - { - UploadHardwareConfiguration(false); - } - } - catch (Exception ex) - { - LogManager.Log(ex); - - _notificationProvider.ShowError("Could not connect to the selected machine." + Environment.NewLine + ex.Message); - - } - - InvalidateRelayCommands(); - } + await ConnectToMachineLocal(x.SelectedMachine, vm.SelectedMachine, x.UploadHardwareConfiguration); } }); } - InvalidateRelayCommands(); + base.InvalidateRelayCommands(); } - InvalidateRelayCommands(); + base.InvalidateRelayCommands(); }); } else @@ -585,6 +567,41 @@ namespace Tango.MachineStudio.UI.ViewModels InvalidateRelayCommands(); } + private async Task ConnectToMachineLocal(IExternalBridgeClient client, Machine machine, bool uploadHardwareConfig) + { + using (NotificationProvider.PushTaskItem("Connecting to " + client.ToString() + "...")) + { + try + { + _reconnectionMachine = client; + + await client.Connect(); + client.SerialNumber = machine.SerialNumber; + ApplicationManager.SetConnectedMachine(client); + + PostMessage(new MachineConnectionChangedMessage() { Machine = client }); + _settings.LastVirtualMachineSerialNumber = machine.SerialNumber; + _settings.Save(); + + _lastUploadHardwareConfigLocal = uploadHardwareConfig; + + if (uploadHardwareConfig) + { + UploadHardwareConfiguration(false); + } + } + catch (Exception ex) + { + LogManager.Log(ex); + + _notificationProvider.ShowError("Could not connect to the selected machine." + Environment.NewLine + ex.Message); + + } + + InvalidateRelayCommands(); + } + } + private async void ConnectToMachineSecure(IExternalBridgeSecureClient machine, MachineLoginViewVM config) { using (NotificationProvider.PushTaskItem("Connecting to machine " + machine.ToString() + "...")) |
