Ejemplo n.º 1
0
        private async Task <bool> LoadBoardRegistersSettings(int maxRetries)
        {
            //await EmptyReadBufferAsync();

            int retries = 0;

            while (retries < maxRetries)
            {
                try
                {
                    if (GetBoardRegistersString(out var registersString))
                    {
                        BoardSettings.LoadFromRegistersString(registersString);
                        return(true);
                    }
                    retries++;
                    await Task.Delay(1000);

                    Log?.Invoke(this, new LogEventArgs(this, "LoadBoardRegistersSettings", "Failed to get registers settings.", LogLevel.WARN));
                }
                catch (Exception e)
                {
                    Log?.Invoke(this, new LogEventArgs(this, "LoadBoardRegistersSettings", e, LogLevel.WARN));
                    retries++;
                    await Task.Delay(1000);
                }
            }

            Log?.Invoke(this, new LogEventArgs(this, "LoadBoardRegistersSettings", "Failed to get settings", LogLevel.ERROR));
            return(false);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Load the board configuration string into the settings object
 /// </summary>
 private void LoadBoardSettings(string configString)
 {
     try
     {
         BoardSettings = new CytonBoardsImplementation();
         BoardSettings.LoadFromRegistersString(configString);
     }
     catch (Exception)
     {
         BoardSettings = null;
     }
 }