From e47f736bca350350a55fa287093dad560da8f678 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 6 Dec 2018 15:48:47 +0200 Subject: Working on PPC firmware upgrade !!! --- .../Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs | 98 +--------------------- 1 file changed, 3 insertions(+), 95 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs index f778ff5a8..02cc4ba33 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs @@ -14,6 +14,7 @@ using Tango.Logging; using Tango.PMR.Connection; using Tango.PPC.Common; using Tango.PPC.Common.Application; +using Tango.PPC.Common.Connection; using Tango.PPC.Common.MachineSetup; using Tango.PPC.Common.Navigation; using Tango.PPC.UI.ViewsContracts; @@ -46,8 +47,6 @@ namespace Tango.PPC.UI.ViewModels WelcomeView, WiFiSelectionView, WiFiTestView, - EmbeddedWelcomeView, - EmbeddedTestView, SetupWelcomeView, SetupProgressView, SetupCompletedView, @@ -103,13 +102,6 @@ namespace Tango.PPC.UI.ViewModels set { _state = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } - private String _machineConnectionStatus; - public String MachineConnectionStatus - { - get { return _machineConnectionStatus; } - set { _machineConnectionStatus = value; RaisePropertyChangedAuto(); } - } - #endregion #region Commands @@ -124,16 +116,6 @@ namespace Tango.PPC.UI.ViewModels /// public RelayCommand NavigateToWiFiCommand { get; set; } - /// - /// Gets or sets the skip embedded test command. - /// - public RelayCommand SkipEmbeddedTestCommand { get; set; } - - /// - /// Gets or sets the perform embedded test command. - /// - public RelayCommand PerformEmbeddedTestCommand { get; set; } - /// /// Gets or sets the install command. /// @@ -168,8 +150,6 @@ namespace Tango.PPC.UI.ViewModels NavigateToWiFiCommand = new RelayCommand(EnsureWiFi); - PerformEmbeddedTestCommand = new RelayCommand(PerformEmbeddedTest); - SkipEmbeddedTestCommand = new RelayCommand(SkipEmbeddedTest); InstallCommand = new RelayCommand(Install); RestartCommand = new RelayCommand(() => { NavigateTo(MachineSetupView.WelcomeView); }); } @@ -260,7 +240,7 @@ namespace Tango.PPC.UI.ViewModels if (connected) { - await NavigateTo(MachineSetupView.EmbeddedWelcomeView); + await NavigateTo(MachineSetupView.SetupWelcomeView); } else { @@ -282,78 +262,6 @@ namespace Tango.PPC.UI.ViewModels #endregion - #region Embedded - - private async void PerformEmbeddedTest() - { - await NavigateTo(MachineSetupView.EmbeddedTestView); - - try - { - MachineConnectionStatus = "Scanning for the machine..."; - - LogManager.Log("Starting machine connection procedure..."); - - TimeSpan timeout = TimeSpan.FromSeconds(SettingsManager.Default.GetOrCreate().MachineScanningTimeoutSeconds); - - LogManager.Log("Scanning for machine on available serial ports..."); - Transport.Discovery.UsbCommunicationScanner scanner = new Transport.Discovery.UsbCommunicationScanner(UsbSerialBaudRates.BR_9600); - - scanner.ScanningPort += (port) => - { - MachineConnectionStatus = $"Scanning for the machine on {port}..."; - }; - - var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, timeout); - - MachineConnectionStatus = "Machine discovered on port: " + response.Adapter.Address + ", trying to connect..."; - - LogManager.Log("Machine discovered on port: " + response.Adapter.Address); - LogManager.Log("Device Information:"); - LogManager.Log(response.Response.DeviceInformation.ToJsonString()); - - LogManager.Log("Disconnecting machine operator..."); - - IMachineOperator op = new MachineOperator(response.Adapter); - - op.EnableDiagnostics = false; - op.EnableEmbeddedDebugging = false; - op.EnableEventsNotification = false; - - LogManager.Log("Connecting machine operator..."); - await op.Connect(); - - MachineConnectionStatus = "Test completed successfully!"; - - await Task.Delay(1000); - - try - { - await op.Disconnect(); - } - catch { } - - await NavigateTo(MachineSetupView.SetupWelcomeView); - } - catch (Exception ex) - { - LogManager.Log(ex, "Error while trying to scan and connect to the machine."); - MachineConnectionStatus = "Test Failed!"; - await Task.Delay(2000); - await NavigateTo(MachineSetupView.EmbeddedWelcomeView); - } - } - - private async void SkipEmbeddedTest() - { - if (await NotificationProvider.ShowQuestion("Are you sure you want to skip the machine communication test?")) - { - await NavigateTo(MachineSetupView.SetupWelcomeView); - } - } - - #endregion - #region Setup private async void Install() @@ -371,7 +279,7 @@ namespace Tango.PPC.UI.ViewModels Settings.Save(); State = MachineSetupStates.Completed; LogManager.Log("Machine setup completed."); - await NavigateTo(MachineSetupView.SetupCompletedView); + CompleteSetup(); } catch (Exception ex) { -- cgit v1.3.1