From 4490b0a76d4188cb285d62b106e208803ceaa133 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 13 Aug 2018 14:22:32 +0300 Subject: PPC.Common Logs and comments! --- .../MachineSetup/MachineSetupManager.cs | 89 +++++++++++++++++++--- 1 file changed, 78 insertions(+), 11 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index 01f828c3f..14cdeb3f2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -21,14 +21,33 @@ using Tango.Transport.Web; namespace Tango.PPC.Common.MachineSetup { + /// + /// Represents the PPC machine setup manager. + /// + /// + /// public class MachineSetupManager : ExtendedObject, IMachineSetupManager { - private IPPCApplicationManager _applicationManager; + #region Events + /// + /// Occurs when there is a text log message available. + /// public event EventHandler ProgressLog; + + /// + /// Occurs when the has changed. + /// public event EventHandler ProgressStep; + #endregion + + #region Properties + private MachineSetupSteps _currentStep; + /// + /// Gets the current setup step. + /// public MachineSetupSteps CurrentStep { get { return _currentStep; } @@ -39,11 +58,15 @@ namespace Tango.PPC.Common.MachineSetup _currentStep = value; RaisePropertyChangedAuto(); ProgressStep?.Invoke(this, _currentStep); + LogManager.Log("Machine Setup Manager Step: " + value.ToString()); } } } private double _downloadProgress; + /// + /// Gets the downloading packages step progress. + /// public double DownloadingPackagesProgress { get { return _downloadProgress; } @@ -51,27 +74,39 @@ namespace Tango.PPC.Common.MachineSetup } private String _updatingPackagesStatus; + /// + /// Gets the downloading packages step status. + /// public String DownloadingPackagesStatus { get { return _updatingPackagesStatus; } set { _updatingPackagesStatus = value; RaisePropertyChangedAuto(); } } - public MachineSetupManager(IPPCApplicationManager applicationManager) - { - _applicationManager = applicationManager; - } + #endregion + + #region Public Methods + /// + /// Performs a machine setup using the specified serial number and machine service address. + /// + /// The serial number. + /// The machine service address. + /// public Task Setup(string serialNumber, string machineServiceAddress) { return Task.Factory.StartNew(() => { + LogManager.Log($"Starting machine setup for serial number {serialNumber}..."); + //Connect to machine service and get matching packages for this machine. CurrentStep = MachineSetupSteps.DownloadingPackage; DownloadingPackagesProgress = 0; DownloadingPackagesStatus = "Connecting to machine service..."; + LogManager.Log($"Connecting to machine service on {machineServiceAddress}..."); + MachineSetupRequest request = new MachineSetupRequest(); request.SerialNumber = serialNumber; @@ -82,15 +117,23 @@ namespace Tango.PPC.Common.MachineSetup setup_response = http.Post(machineServiceAddress + "/api/Synchronization/MachineSetup", request).Result; } + LogManager.Log($"Machine setup response received: {Environment.NewLine}{setup_response.ToJsonString()}"); + //Create temporary folders for packages. var _newPackageTempFolder = TemporaryManager.CreateFolder(); _newPackageTempFolder.Persist = true; + LogManager.Log($"Temporary package folder created: {_newPackageTempFolder}."); + //Download software package. var tempFile = TemporaryManager.CreateFile(".zip"); + LogManager.Log($"Temporary package zip file created: {tempFile}."); + DownloadingPackagesStatus = "Downloading software package..."; + LogManager.Log("Downloading software package..."); + int fileSize = 0; DownloadingPackagesProgress = 0; @@ -98,23 +141,24 @@ namespace Tango.PPC.Common.MachineSetup { InvokeUINow(() => { - Thread.Sleep(10); + Thread.Sleep(10); //TODO: this is necessary only for visibility... DownloadingPackagesProgress = ((double)current / (double)fileSize) * 100d; }); })) { using (FtpClient ftp = new FtpClient(setup_response.FtpAddress, setup_response.FtpUserName, setup_response.FtpPassword)) { - LogManager.Log("Connecting to FTP site: " + setup_response.FtpAddress); + LogManager.Log("FTP: Connecting to site: " + setup_response.FtpAddress); ftp.ConnectAsync().Wait(); - LogManager.Log("Retrieving download size..."); + LogManager.Log("FTP: Retrieving download size..."); fileSize = (int)ftp.GetFileSize(setup_response.FtpFilePath); - LogManager.Log("Download size: " + fileSize + " bytes."); - LogManager.Log("Starting download..."); + LogManager.Log("FTP: Download size: " + fileSize + " bytes."); + LogManager.Log("FTP: Starting download..."); ftp.DownloadAsync(fs, setup_response.FtpFilePath).Wait(); } } + LogManager.Log("Extracting downloaded zip file..."); //Extract software package. ZipFile.ExtractToDirectory(tempFile, _newPackageTempFolder); @@ -126,17 +170,25 @@ namespace Tango.PPC.Common.MachineSetup String localAddress = SettingsManager.Default.GetOrCreate().DataBaseSource; String remote_address = setup_response.DbAddress; + LogManager.Log($"Synchronizing database '{remote_address}\\{db_name}' => '{localAddress}\\{db_name}'..."); + + LogManager.Log("Initializing database manager..."); DbManager db = DbManager.FromAddressAndName(localAddress, db_name); + LogManager.Log("Checking Tango database exists on the local machine..."); if (!db.Exists(db_name)) { throw new InvalidProgramException("Database tango does not exists."); } + LogManager.Log("Clearing database..."); db.ClearDb(); + LogManager.Log("Disposing database manager."); db.Dispose(); + LogManager.Log($"Initializing {nameof(ExaminerSequenceConfigurationRunner)}..."); + ExaminerSequenceConfigurationRunner runner = new ExaminerSequenceConfigurationRunner( Path.Combine(_newPackageTempFolder, "Synchronization Scripts", "config.xml"), Path.Combine(_newPackageTempFolder, "Synchronization Scripts"), @@ -157,11 +209,14 @@ namespace Tango.PPC.Common.MachineSetup runner.Log += (x, msg) => { + LogManager.Log(msg); ProgressLog.Invoke(this, msg); }; runner.ScriptExecuting += (x, item) => { + LogManager.Log($"Executing script {item.ToString()}..."); + if (item.Type == ExaminerSequenceItemType.Data && item.RequiresSerialNumber) { CurrentStep = MachineSetupSteps.SynchronizingMachineConfiguration; @@ -172,7 +227,17 @@ namespace Tango.PPC.Common.MachineSetup } }; - runner.Run().Wait(); + LogManager.Log("Starting synchronization process..."); + + try + { + runner.Run().Wait(); + LogManager.Log("Synchronization completed successfully!"); + } + catch (Exception ex) + { + throw LogManager.Log(ex, "Setup manager error while trying to synchronize database."); + } return new MachineSetupResult() { @@ -180,5 +245,7 @@ namespace Tango.PPC.Common.MachineSetup }; }); } + + #endregion } } -- cgit v1.3.1 From 9c2939ac72bdb7501ce19236c60ab5f584247fb4 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 14 Aug 2018 10:54:24 +0300 Subject: Improved logging library threading model. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 15400960 -> 15400960 bytes .../MachineSetup/MachineSetupManager.cs | 6 ++ .../Visual_Studio/Tango.Logging/ConsoleLogger.cs | 26 ++++++--- .../Tango.Logging/ConsoleWindow.xaml.cs | 7 ++- Software/Visual_Studio/Tango.Logging/FileLogger.cs | 5 -- .../Tango.Logging/GlobalExceptionTrapper.cs | 3 +- Software/Visual_Studio/Tango.Logging/ILogger.cs | 5 -- Software/Visual_Studio/Tango.Logging/LogManager.cs | 65 ++++++--------------- .../Tango.Logging/SimpleStringLogger.cs | 1 - .../Visual_Studio/Tango.Logging/VSOutputLogger.cs | 6 -- 11 files changed, 51 insertions(+), 73 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 97c8b24cd..6bb94b6ce 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 7beb87baf..e16bf57a7 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index 14cdeb3f2..f40725a35 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -12,6 +12,7 @@ using System.Threading; using System.Threading.Tasks; using Tango.Core; using Tango.Core.DB; +using Tango.Core.Helpers; using Tango.Core.IO; using Tango.PMR.Synchronization; using Tango.PPC.Common.Application; @@ -163,6 +164,11 @@ namespace Tango.PPC.Common.MachineSetup ZipFile.ExtractToDirectory(tempFile, _newPackageTempFolder); + LogManager.Log("Copying latest updater utility to application path..."); + //Copy new updater utility to app path. + File.Copy(Path.Combine(_newPackageTempFolder, "Tango.PPC.Updater.exe"), Path.Combine(PathHelper.GetStartupPath(), "Tango.PPC.Updater.exe")); + + //Synchronize database CurrentStep = MachineSetupSteps.SynchronizingSchema; diff --git a/Software/Visual_Studio/Tango.Logging/ConsoleLogger.cs b/Software/Visual_Studio/Tango.Logging/ConsoleLogger.cs index d073f81ed..37d3f4304 100644 --- a/Software/Visual_Studio/Tango.Logging/ConsoleLogger.cs +++ b/Software/Visual_Studio/Tango.Logging/ConsoleLogger.cs @@ -22,11 +22,6 @@ namespace Tango.Logging /// public bool Enabled { get; set; } - /// - /// Gets or sets a value indicating whether this will be notified about logs without waiting for the logs queue. - /// - public bool Immediate { get; set; } - /// /// Initializes a new instance of the class. /// @@ -34,7 +29,6 @@ namespace Tango.Logging { _consoleTitle = consoleTitle; Enabled = true; - Immediate = true; } /// @@ -45,7 +39,25 @@ namespace Tango.Logging { EnsureConsoleOpen(() => { - console.SetColor(ConsoleColor.White); + switch (output.Category) + { + case LogCategory.Info: + console.SetColor(ConsoleColor.White); + break; + case LogCategory.Warning: + console.SetColor(ConsoleColor.Yellow); + break; + case LogCategory.Error: + console.SetColor(ConsoleColor.Red); + break; + case LogCategory.Critical: + console.SetColor(ConsoleColor.DarkRed); + break; + case LogCategory.Debug: + console.SetColor(ConsoleColor.Gray); + break; + } + console.WriteLine(output.ToString()); }); } diff --git a/Software/Visual_Studio/Tango.Logging/ConsoleWindow.xaml.cs b/Software/Visual_Studio/Tango.Logging/ConsoleWindow.xaml.cs index e95284cf8..04e5ab2fa 100644 --- a/Software/Visual_Studio/Tango.Logging/ConsoleWindow.xaml.cs +++ b/Software/Visual_Studio/Tango.Logging/ConsoleWindow.xaml.cs @@ -24,6 +24,7 @@ namespace Tango.Logging { private bool _closing; private SolidColorBrush _currentBrush; + private ConsoleColor _current_color; /// /// Initializes a new instance of the class. @@ -75,7 +76,11 @@ namespace Tango.Logging /// The color. public void SetColor(ConsoleColor color) { - InvokeUI(() => _currentBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(color.ToString()))); + if (_current_color != color) + { + _current_color = color; + InvokeUI(() => _currentBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(color.ToString()))); + } } private void AppendLog(String log) diff --git a/Software/Visual_Studio/Tango.Logging/FileLogger.cs b/Software/Visual_Studio/Tango.Logging/FileLogger.cs index 547db406e..121ef5374 100644 --- a/Software/Visual_Studio/Tango.Logging/FileLogger.cs +++ b/Software/Visual_Studio/Tango.Logging/FileLogger.cs @@ -110,11 +110,6 @@ namespace Tango.Logging } } - /// - /// Gets or sets a value indicating whether this will be notified about logs without waiting for the logs queue. - /// - public bool Immediate { get; set; } - /// /// Creates the name of the log file. /// diff --git a/Software/Visual_Studio/Tango.Logging/GlobalExceptionTrapper.cs b/Software/Visual_Studio/Tango.Logging/GlobalExceptionTrapper.cs index b0bc3ed76..3ceb78b17 100644 --- a/Software/Visual_Studio/Tango.Logging/GlobalExceptionTrapper.cs +++ b/Software/Visual_Studio/Tango.Logging/GlobalExceptionTrapper.cs @@ -87,9 +87,9 @@ namespace Tango.Logging } _lastGlobalExceptionTime = DateTime.Now; - LogManager.Default.OverrideQueue = true; LogManager.Default.Log("Application Crashed", LogCategory.Critical); LogManager.Default.Log(exception, LogCategory.Critical); + LogManager.Default.Flush(); ApplicationCrashedEventArgs e = new ApplicationCrashedEventArgs(exception); @@ -100,7 +100,6 @@ namespace Tango.Logging LogManager.Default.Log("Trying application recovery. Ignoring exception..."); } - LogManager.Default.OverrideQueue = false; return e.TryRecover; } } diff --git a/Software/Visual_Studio/Tango.Logging/ILogger.cs b/Software/Visual_Studio/Tango.Logging/ILogger.cs index de3c3584b..25eff0969 100644 --- a/Software/Visual_Studio/Tango.Logging/ILogger.cs +++ b/Software/Visual_Studio/Tango.Logging/ILogger.cs @@ -21,10 +21,5 @@ namespace Tango.Logging /// Gets or sets a value indicating whether this is enabled. /// bool Enabled { get; set; } - - /// - /// Gets or sets a value indicating whether this will be notified about logs without waiting for the logs queue. - /// - bool Immediate { get; set; } } } diff --git a/Software/Visual_Studio/Tango.Logging/LogManager.cs b/Software/Visual_Studio/Tango.Logging/LogManager.cs index 7d339d6b6..91f6423d0 100644 --- a/Software/Visual_Studio/Tango.Logging/LogManager.cs +++ b/Software/Visual_Studio/Tango.Logging/LogManager.cs @@ -22,6 +22,7 @@ namespace Tango.Logging private ConcurrentQueue _logs; private Thread _loggingThread; private bool _isStarted; + private AutoResetEvent _semaphore; /// /// Occurs when a new log as been received. @@ -53,17 +54,12 @@ namespace Tango.Logging } } - - /// - /// Gets or sets a value indicating whether to propagate logs instantly (Warning - not thread safe). - /// - public bool OverrideQueue { get; set; } - /// /// Initializes the class. /// public LogManager() { + _semaphore = new AutoResetEvent(false); _loggers = new List(); _logs = new ConcurrentQueue(); Categories = new List(); @@ -131,14 +127,7 @@ namespace Tango.Logging log.Category = category; log.Description = description != null ? description : e.ToString(); - if (!OverrideQueue) - { - AppendLog(log); - } - else - { - AppendLogInstantly(log); - } + AppendLog(log); return e; } @@ -197,14 +186,7 @@ namespace Tango.Logging log.Message = message; log.LogObject = logObject; - if (!OverrideQueue) - { - AppendLog(log); - } - else - { - AppendLogInstantly(log); - } + AppendLog(log); return message; } @@ -221,7 +203,7 @@ namespace Tango.Logging string path = Uri.UnescapeDataString(uri.Path); String folder = Path.GetDirectoryName(path); - foreach (var file in Directory.GetFiles(folder,"*.dll")) + foreach (var file in Directory.GetFiles(folder, "*.dll")) { FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(file); string version = fvi.ProductVersion; @@ -249,13 +231,9 @@ namespace Tango.Logging /// The log. private void AppendLog(LogItemBase log) { - if (log != null) - { - _loggers.Where(x => x.Enabled && x.Immediate).ToList().ForEach(x => x.OnLog(log)); - } - _logs.Enqueue(log); StartLoggingThread(); + _semaphore.Set(); } /// @@ -281,7 +259,7 @@ namespace Tango.Logging { while (_isStarted) { - while (_logs.Count > 0) + if (_logs.Count > 0) { LogItemBase log; @@ -289,37 +267,32 @@ namespace Tango.Logging { if (log != null) { - _loggers.Where(x => x.Enabled && !x.Immediate).ToList().ForEach(x => x.OnLog(log)); + _loggers.Where(x => x.Enabled).ToList().ForEach(x => x.OnLog(log)); NewLog?.Invoke(this, log); } } } - Thread.Sleep(10); + _semaphore.WaitOne(); } } /// - /// Appends the log instantly. + /// Ensures all registered loggers be notified about current logs in queue immediately. /// - /// The log. - [DebuggerStepThrough] - [DebuggerHidden] - private void AppendLogInstantly(LogItemBase log) + public void Flush() { - bool wroteLog = false; - - while (!wroteLog) + while (_logs.Count > 0) { - try - { - _loggers.Where(x => x.Enabled).ToList().ForEach(x => x.OnLog(log)); + LogItemBase log; - wroteLog = true; - } - catch + if (_logs.TryDequeue(out log)) { - Thread.Sleep(5); + if (log != null) + { + _loggers.Where(x => x.Enabled).ToList().ForEach(x => x.OnLog(log)); + NewLog?.Invoke(this, log); + } } } } diff --git a/Software/Visual_Studio/Tango.Logging/SimpleStringLogger.cs b/Software/Visual_Studio/Tango.Logging/SimpleStringLogger.cs index f25050dca..1b0780e58 100644 --- a/Software/Visual_Studio/Tango.Logging/SimpleStringLogger.cs +++ b/Software/Visual_Studio/Tango.Logging/SimpleStringLogger.cs @@ -12,7 +12,6 @@ namespace Tango.Logging private bool _immidiate; public bool Enabled { get => _enabled; set => _enabled = value; } - public bool Immediate { get => _immidiate; set => _immidiate = value; } public List Categories { get; set; } diff --git a/Software/Visual_Studio/Tango.Logging/VSOutputLogger.cs b/Software/Visual_Studio/Tango.Logging/VSOutputLogger.cs index 970cc6c83..66a11c7df 100644 --- a/Software/Visual_Studio/Tango.Logging/VSOutputLogger.cs +++ b/Software/Visual_Studio/Tango.Logging/VSOutputLogger.cs @@ -20,7 +20,6 @@ namespace Tango.Logging /// public VSOutputLogger() { - Immediate = true; Enabled = true; _assembly_name = Assembly.GetEntryAssembly().GetName().Name + ": "; @@ -50,10 +49,5 @@ namespace Tango.Logging _isEnabled = value; } } - - /// - /// Gets or sets a value indicating whether this will be notified about logs without waiting for the logs queue. - /// - public bool Immediate { get; set; } } } -- cgit v1.3.1 From a282f06d5060617af3ba3b4c4ea6b9f03372df3d Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 14 Aug 2018 15:31:28 +0300 Subject: Fixed some issues with Machine Setup. --- .../MachineSetup/MachineSetupManager.cs | 2 +- .../PPC/Tango.PPC.UI/Views/MachineSetupView.xaml | 2 +- .../PPC/Tango.PPC.Updater/MainWindow.xaml | 4 ++-- .../PPC/Tango.PPC.Updater/MainWindow.xaml.cs | 18 +++++++++++------- 4 files changed, 15 insertions(+), 11 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index f40725a35..281c68a77 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -166,7 +166,7 @@ namespace Tango.PPC.Common.MachineSetup LogManager.Log("Copying latest updater utility to application path..."); //Copy new updater utility to app path. - File.Copy(Path.Combine(_newPackageTempFolder, "Tango.PPC.Updater.exe"), Path.Combine(PathHelper.GetStartupPath(), "Tango.PPC.Updater.exe")); + File.Copy(Path.Combine(_newPackageTempFolder, "Tango.PPC.Updater.exe"), Path.Combine(PathHelper.GetStartupPath(), "Tango.PPC.Updater.exe"), true); //Synchronize database diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml index 9ff98ce52..e67905eba 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml @@ -76,7 +76,7 @@ Setup completed successfully. Machine is ready! - START + RESTART diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Updater/MainWindow.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Updater/MainWindow.xaml index 77a87d224..a5e63477f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Updater/MainWindow.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Updater/MainWindow.xaml @@ -10,8 +10,8 @@ - - + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Updater/MainWindow.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Updater/MainWindow.xaml.cs index 34e32a306..394d3292f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Updater/MainWindow.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Updater/MainWindow.xaml.cs @@ -30,12 +30,12 @@ namespace Tango.PPC.Updater public MainWindow() { //Launch debugger.. -#if DEBUG - if (!Debugger.IsAttached) - { - Debugger.Launch(); - } -#endif +//#if DEBUG +// if (!Debugger.IsAttached) +// { +// Debugger.Launch(); +// } +//#endif if (!Directory.Exists(_sourceFolder)) { @@ -76,7 +76,11 @@ namespace Tango.PPC.Updater { Debug.WriteLine(ex.ToString()); ShowError(ex.Message); - StartTango(); + Process p = new Process(); + p.StartInfo.FileName = _appPath + "\\" + _msProcessName + ".exe"; + p.StartInfo.LoadUserProfile = true; + p.StartInfo.UseShellExecute = true; + p.Start(); Environment.Exit(0); } } -- cgit v1.3.1 From 04fd2234090e23ff2e648d997a1cc753c9354941 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 16 Aug 2018 15:59:12 +0300 Subject: Implemented full machine setup with connectivity and communication testing! Fixed an issue with auto reset event on transport and logging :/ --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 15400960 -> 15400960 bytes .../MachineSetup/MachineSetupManager.cs | 2 +- .../Connectivity/DefaultConnectivityProvider.cs | 1 - .../Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs | 231 ++++++++++++++++++--- .../PPC/Tango.PPC.UI/Views/MachineSetupView.xaml | 163 +++++++++++---- .../Tango.PPC.UI/Views/MachineSetupView.xaml.cs | 13 ++ .../ViewsContracts/IMachineSetupView.cs | 7 + .../Visual_Studio/Tango.BL/Entities/Machine.cs | 22 -- .../Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs | 1 - .../Tango.DAL.Remote/DB/RemoteADO.edmx | 3 - .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 130 ++++++------ Software/Visual_Studio/Tango.Logging/LogManager.cs | 2 +- .../Tango.Logging/SimpleStringLogger.cs | 3 +- .../Tango.SharedUI/Controls/NavigationControl.cs | 27 +++ .../Discovery/UsbCommunicationScanner.cs | 4 + .../Tango.Transport/TransporterBase.cs | 4 +- 17 files changed, 446 insertions(+), 167 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 4e4ae505a..d9efa6228 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index de69c2ab7..9c5c485ea 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index 281c68a77..5ecd170af 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -216,7 +216,7 @@ namespace Tango.PPC.Common.MachineSetup runner.Log += (x, msg) => { LogManager.Log(msg); - ProgressLog.Invoke(this, msg); + ProgressLog?.Invoke(this, msg); }; runner.ScriptExecuting += (x, item) => diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs index ec51b9a98..d338b3ff1 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs @@ -219,7 +219,6 @@ namespace Tango.PPC.UI.Connectivity { result = await network.Connect(auth); await RefreshAvailableWiFiNetworks(); - return result; } if (result) 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 a81db331c..57c2200c6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs @@ -8,6 +8,9 @@ using System.Threading.Tasks; using Tango.Core; using Tango.Core.Commands; using Tango.Core.Helpers; +using Tango.Integration.Operation; +using Tango.Logging; +using Tango.PMR.Connection; using Tango.PPC.Common; using Tango.PPC.Common.Application; using Tango.PPC.Common.MachineSetup; @@ -16,6 +19,7 @@ using Tango.PPC.UI.ViewsContracts; using Tango.Settings; using Tango.SharedUI.Helpers; using Tango.SQLExaminer; +using Tango.Transport.Adapters; namespace Tango.PPC.UI.ViewModels { @@ -36,6 +40,19 @@ namespace Tango.PPC.UI.ViewModels Failed, } + public enum MachineSetupView + { + WelcomeView, + WiFiSelectionView, + WiFiTestView, + EmbeddedWelcomeView, + EmbeddedTestView, + SetupWelcomeView, + SetupProgressView, + SetupCompletedView, + SetupFailedView, + } + private MachineSetupResult _setup_result; #region Properties @@ -85,19 +102,46 @@ 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 /// - /// Gets or sets the start command. + /// Gets or sets the complete command. + /// + public RelayCommand CompleteCommand { get; set; } + + /// + /// Gets or sets the navigate to WiFi command. /// - public RelayCommand StartCommand { get; set; } + public RelayCommand NavigateToWiFiCommand { get; set; } /// - /// Gets or sets the complete command. + /// Gets or sets the skip embedded test command. /// - public RelayCommand CompleteCommand { get; set; } + public RelayCommand SkipEmbeddedTestCommand { get; set; } + + /// + /// Gets or sets the perform embedded test command. + /// + public RelayCommand PerformEmbeddedTestCommand { get; set; } + + /// + /// Gets or sets the install command. + /// + public RelayCommand InstallCommand { get; set; } + + /// + /// Gets or sets the restart command. + /// + public RelayCommand RestartCommand { get; set; } #endregion @@ -111,16 +155,31 @@ namespace Tango.PPC.UI.ViewModels public MachineSetupViewVM(IPPCApplicationManager applicationManager, IMachineSetupManager machineSetupManager) { MachineSetupManager = machineSetupManager; - MachineSetupManager.ProgressLog += (x, msg) => AppendLog(msg); + //MachineSetupManager.ProgressLog += (x, msg) => AppendLog(msg); MachineSetupManager.ProgressStep += (x, step) => AppendLog(Environment.NewLine + "-----------" + step.ToDescription().ToUpper() + "-----------" + Environment.NewLine); HostAddress = "localhost\\SQLEXPRESS"; SerialNumber = "1111"; - StartCommand = new RelayCommand(StartSetup, () => !String.IsNullOrWhiteSpace(HostAddress) && !String.IsNullOrWhiteSpace(SerialNumber) && State == MachineSetupStates.None); CompleteCommand = new RelayCommand(CompleteSetup, () => State == MachineSetupStates.Completed); applicationManager.SetupRequired += ApplicationManager_SetupRequired; + + NavigateToWiFiCommand = new RelayCommand(EnsureWiFi); + + PerformEmbeddedTestCommand = new RelayCommand(PerformEmbeddedTest); + SkipEmbeddedTestCommand = new RelayCommand(SkipEmbeddedTest); + InstallCommand = new RelayCommand(Install); + RestartCommand = new RelayCommand(() => { NavigateTo(MachineSetupView.WelcomeView); }); + + if (!LogManager.Categories.Contains(LogCategory.Debug)) + { + LogManager.Categories.Add(LogCategory.Debug); + } + + var logger = new SimpleStringLogger(); + LogManager.RegisterLogger(logger); + logger.LogReceived += Logger_LogReceived; } #endregion @@ -138,6 +197,12 @@ namespace Tango.PPC.UI.ViewModels NavigationManager.NavigateTo(NavigationView.MachineSetupView); } + + private void Logger_LogReceived(object sender, LogItemBase e) + { + AppendLog(e.Message); + } + #endregion #region Private Methods @@ -158,10 +223,142 @@ namespace Tango.PPC.UI.ViewModels } /// - /// Starts the setup. + /// Completes the setup. + /// + private void CompleteSetup() + { + String updater_exe = AssemblyHelper.GetCurrentAssemblyFolder() + "\\Tango.PPC.Updater.exe"; + + LogManager.Log("Completing machine setup..."); + LogManager.Log($"Executing '{updater_exe}' with arguments '{_setup_result.UpdatePackagePath}'..."); + Process.Start(updater_exe, _setup_result.UpdatePackagePath); + LogManager.Log("Terminating application process!"); + Environment.Exit(0); + } + + /// + /// Navigates to the specified view. /// - private async void StartSetup() + /// The view. + private Task NavigateTo(MachineSetupView view) { + return View.NavigateTo(view); + } + + #endregion + + #region WiFi + + private async void EnsureWiFi() + { + await NavigateTo(MachineSetupView.WiFiTestView); + + await Task.Delay(2000); + + bool connected = await ConnectivityProvider.CheckInternetConnection(); + + if (connected) + { + await NavigateTo(MachineSetupView.EmbeddedWelcomeView); + } + else + { + await NavigateTo(MachineSetupView.WiFiSelectionView); + await ConnectivityProvider.RefreshAvailableWiFiNetworks(); + + ConnectivityProvider.ConnectionStateChanged += ConnectivityProvider_ConnectionStateChanged; + } + } + + private void ConnectivityProvider_ConnectionStateChanged(object sender, Common.Connectivity.ConnectionStateEventArgs e) + { + if (e.IsConnected) + { + ConnectivityProvider.ConnectionStateChanged -= ConnectivityProvider_ConnectionStateChanged; + EnsureWiFi(); + } + } + + #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?")) + { + + } + } + + #endregion + + #region Setup + + private async void Install() + { + await NavigateTo(MachineSetupView.SetupProgressView); + LogManager.Log("Starting machine setup..."); State = MachineSetupStates.Working; @@ -172,31 +369,17 @@ namespace Tango.PPC.UI.ViewModels Settings.ApplicationState = ApplicationStates.SemiSetup; Settings.Save(); State = MachineSetupStates.Completed; - LogManager.Log("Machine setup completed."); + await NavigateTo(MachineSetupView.SetupCompletedView); } catch (Exception ex) { LogManager.Log(ex, "Machine setup failed."); State = MachineSetupStates.Failed; - await NotificationProvider.ShowInfo(ex.Message); + await NavigateTo(MachineSetupView.SetupFailedView); } } - /// - /// Completes the setup. - /// - private void CompleteSetup() - { - String updater_exe = AssemblyHelper.GetCurrentAssemblyFolder() + "\\Tango.PPC.Updater.exe"; - - LogManager.Log("Completing machine setup..."); - LogManager.Log($"Executing '{updater_exe}' with arguments '{_setup_result.UpdatePackagePath}'..."); - Process.Start(updater_exe, _setup_result.UpdatePackagePath); - LogManager.Log("Terminating application process!"); - Environment.Exit(0); - } - #endregion } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml index e67905eba..a097eeb45 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml @@ -4,17 +4,24 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:vm="clr-namespace:Tango.PPC.UI.ViewModels" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:global="clr-namespace:Tango.PPC.UI" xmlns:setup="clr-namespace:Tango.PPC.Common.MachineSetup;assembly=Tango.PPC.Common" + xmlns:connectivity="clr-namespace:Tango.PPC.Common.Connectivity;assembly=Tango.PPC.Common" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:local="clr-namespace:Tango.PPC.UI.Views" mc:Ignorable="d" - d:DesignHeight="2000" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MachineSetupViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MachineSetupViewVM}"> + d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MachineSetupViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MachineSetupViewVM}"> - + - + + + MACHINE SETUP WIZARD + + + @@ -22,63 +29,129 @@ - - - MACHINE SETUP + + + + + + Welcome to the machine setup wizard! + In the next steps the software will gather required information, perform tests and apply an initial configuration to this machine. + + + Press 'START' to initiate the setup process. + + + START + + + + + + + We need an active internet connection in order to fetch the latest software package and machine configuration. + + + Please connect to one of the available WiFi networks. + + + + + + + + + + Checking internet connection, please wait... + + + + + + + + + It is recommended to perform a quick communication test with the machine before proceeding. Please turn on and connect the machine, then tap 'PERFORM TEST'. + - - - This machine has not been configured yet and require several steps in order to be ready. - - Enter this machine serial number, synchronization server address and tap 'INSTALL'. - + + SKIP + PERFORM TEST + + + + + + + + + + - - SERIAL NUMBER - + + + + The next step is to download the latest software package and synchronize the machine data. Enter the machine serial number, service address and press 'INSTALL'. + - MACHINE SERVICE ADDRESS - + + SERIAL NUMBER + - INSTALL + MACHINE SERVICE ADDRESS + + + INSTALL + - + - - + + + Please wait while we setting up this machine. Do not turn off this PC. - - - - - - - - - - - - + + + + + + + + + + + + + - + - + Setup completed successfully. Machine is ready! + + RESTART + - RESTART - - + + + + Setup failed, tap 'RESTART' to restart the process. + + RESTART + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml.cs index a2c20ecc2..aee809e9c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml.cs @@ -12,6 +12,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.PPC.UI.ViewModels; using Tango.PPC.UI.ViewsContracts; namespace Tango.PPC.UI.Views @@ -35,5 +36,17 @@ namespace Tango.PPC.UI.Views txtLog.SelectionStart = txtLog.Text.Length; txtLog.ScrollToEnd(); } + + public Task NavigateTo(MachineSetupViewVM.MachineSetupView view) + { + TaskCompletionSource source = new TaskCompletionSource(); + + navigationControl.NavigateTo(view.ToString(),() => + { + source.SetResult(new object()); + }); + + return source.Task; + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewsContracts/IMachineSetupView.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewsContracts/IMachineSetupView.cs index c9ff93280..65b194f7b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewsContracts/IMachineSetupView.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewsContracts/IMachineSetupView.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.PPC.Common; +using static Tango.PPC.UI.ViewModels.MachineSetupViewVM; namespace Tango.PPC.UI.ViewsContracts { @@ -18,5 +19,11 @@ namespace Tango.PPC.UI.ViewsContracts /// /// The log. void AppendLog(String log); + + /// + /// Navigates to the specified machine setup view. + /// + /// The view. + Task NavigateTo(MachineSetupView view); } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/Machine.cs b/Software/Visual_Studio/Tango.BL/Entities/Machine.cs index c5d033dc4..3c9271fff 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Machine.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Machine.cs @@ -159,28 +159,6 @@ namespace Tango.BL.Entities } - protected Boolean _enablewifi; - - /// - /// Gets or sets the machine enable wifi. - /// - - [Column("ENABLE_WIFI")] - - public Boolean EnableWifi - { - get - { - return _enablewifi; - } - - set - { - _enablewifi = value; RaisePropertyChanged(nameof(EnableWifi)); - } - - } - protected Boolean _enableexternalbridge; /// diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs index d1917e428..615012c19 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs @@ -32,7 +32,6 @@ namespace Tango.DAL.Remote.DB public string ORGANIZATION_GUID { get; set; } public string MACHINE_VERSION_GUID { get; set; } public string CONFIGURATION_GUID { get; set; } - public bool ENABLE_WIFI { get; set; } public bool ENABLE_EXTERNAL_BRIDGE { get; set; } public string EXTERNAL_BRIDGE_PASSWORD { get; set; } public string DEFAULT_RML_GUID { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index ea08f9446..8809518b5 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -684,7 +684,6 @@ - @@ -3736,7 +3735,6 @@ - @@ -5970,7 +5968,6 @@ - diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index 406d3e7fb..cc0d83531 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,80 +5,80 @@ - - - - - + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - + + - - - - - - - - - - - + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.Logging/LogManager.cs b/Software/Visual_Studio/Tango.Logging/LogManager.cs index 91f6423d0..2d99c4fac 100644 --- a/Software/Visual_Studio/Tango.Logging/LogManager.cs +++ b/Software/Visual_Studio/Tango.Logging/LogManager.cs @@ -259,7 +259,7 @@ namespace Tango.Logging { while (_isStarted) { - if (_logs.Count > 0) + while (_logs.Count > 0) { LogItemBase log; diff --git a/Software/Visual_Studio/Tango.Logging/SimpleStringLogger.cs b/Software/Visual_Studio/Tango.Logging/SimpleStringLogger.cs index 1b0780e58..4f22dcf6c 100644 --- a/Software/Visual_Studio/Tango.Logging/SimpleStringLogger.cs +++ b/Software/Visual_Studio/Tango.Logging/SimpleStringLogger.cs @@ -28,10 +28,9 @@ namespace Tango.Logging Enabled = true; } - public SimpleStringLogger(params LogCategory[] categories) + public SimpleStringLogger(params LogCategory[] categories) : this() { Categories = categories.ToList(); - Enabled = true; } public void OnLog(LogItemBase log) diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs index 2b59bb663..c8b6d3afb 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs @@ -17,6 +17,8 @@ namespace Tango.SharedUI.Controls [ContentProperty(nameof(Elements))] public class NavigationControl : UserControl { + private Action _onCompleted; + #region Transition Types public enum TransitionTypes @@ -218,6 +220,22 @@ namespace Tango.SharedUI.Controls DependencyProperty.Register("KeepElementsAttached", typeof(bool), typeof(NavigationControl), new PropertyMetadata(false)); + + public int SelectedIndex + { + get { return (int)GetValue(SelectedIndexProperty); } + set { SetValue(SelectedIndexProperty, value); } + } + + // Using a DependencyProperty as the backing store for SelectedIndex. This enables animation, styling, binding, etc... + public static readonly DependencyProperty SelectedIndexProperty = + DependencyProperty.Register("SelectedIndex", typeof(int), typeof(NavigationControl), new PropertyMetadata(0, (d, e) => (d as NavigationControl).OnSelectedIndexChanged())); + + private void OnSelectedIndexChanged() + { + SelectedElement = Elements[SelectedIndex > Elements.Count - 1 ? 0 : SelectedIndex]; + } + #endregion #region Attached Properties @@ -373,6 +391,8 @@ namespace Tango.SharedUI.Controls if (fromVM != null && fromVM != toVM) fromVM.OnNavigatedFrom(); if (toVM != null) toVM.OnNavigatedTo(); + + _onCompleted?.Invoke(); }; switch (TransitionType) @@ -478,6 +498,13 @@ namespace Tango.SharedUI.Controls public FrameworkElement NavigateTo(String navigationName) { + return NavigateTo(navigationName, null); + } + + public FrameworkElement NavigateTo(String navigationName, Action onCompleted = null) + { + _onCompleted = onCompleted; + var element = Elements.SingleOrDefault(x => GetNavigationName(x) == navigationName || x.GetType().Name == navigationName); if (element != null) diff --git a/Software/Visual_Studio/Tango.Transport/Discovery/UsbCommunicationScanner.cs b/Software/Visual_Studio/Tango.Transport/Discovery/UsbCommunicationScanner.cs index 1284490da..aec553191 100644 --- a/Software/Visual_Studio/Tango.Transport/Discovery/UsbCommunicationScanner.cs +++ b/Software/Visual_Studio/Tango.Transport/Discovery/UsbCommunicationScanner.cs @@ -31,6 +31,8 @@ namespace Tango.Transport.Discovery /// public class UsbCommunicationScanner : ICommunicationScanner where TRequest : IMessage where TResponse : IMessage { + public event Action ScanningPort; + /// /// Gets the baud rate. /// @@ -80,6 +82,8 @@ namespace Tango.Transport.Discovery logManager.Log("Scanning " + port.ToString() + "..."); + ScanningPort?.Invoke(port.Port); + SafeFileHandle hFile = UsbComPortWin32.CreateFile(@"\\.\" + port.Port, -1073741824, 0, IntPtr.Zero, 3, UsbComPortWin32.dwFlagsAndAttributes, IntPtr.Zero); if (hFile.IsInvalid) { diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs index c67489007..6376a43ce 100644 --- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs @@ -822,7 +822,7 @@ namespace Tango.Transport { while (State == TransportComponentState.Connected) { - if (Adapter != null && _sendingQueue.Count > 0) + while (Adapter != null && _sendingQueue.Count > 0) { TransportMessageBase message; if (_sendingQueue.TryDequeue(out message)) @@ -901,7 +901,7 @@ namespace Tango.Transport { byte[] data; - if (Adapter != null && _arrivedResponses.Count > 0) + while (Adapter != null && _arrivedResponses.Count > 0) { if (_arrivedResponses.TryDequeue(out data)) { -- cgit v1.3.1 From a054c6d8866efbc4fe42621b0fa6a4fb4d5532e4 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 16 Aug 2018 16:16:31 +0300 Subject: Redundant. --- .../PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs | 2 +- Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index 5ecd170af..8d1c0e147 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -142,7 +142,7 @@ namespace Tango.PPC.Common.MachineSetup { InvokeUINow(() => { - Thread.Sleep(10); //TODO: this is necessary only for visibility... + Thread.Sleep(2); //TODO: this is necessary only for visibility... DownloadingPackagesProgress = ((double)current / (double)fileSize) * 100d; }); })) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml index a097eeb45..6e91da3f8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml @@ -23,7 +23,7 @@ - + -- cgit v1.3.1