private async Task ManterConexaoAsync() { while (true) { try { if (NobreakInterface.SerialPort?.IsOpen == true) { await Task.Delay(GET_DATA_FREQUENCY); continue; } var(port, count) = NobreakInterface.Connect(TentativaDeConexao); TentativaDeConexao = count + 1; Write($"Tentando contato com a {port}"); await Task.Delay(TimeSpan.FromSeconds(10)); if (Package != null) { break; } } catch (Exception ex) { Write(ex.Message); TentativaDeConexao++; } await Task.Delay(GET_DATA_FREQUENCY); } }
public Configs(NobreakInterface nobreakInterface, MainWindow mainWindow) { InitializeComponent(); NobreakInterface = nobreakInterface; MainWindow = mainWindow; AtualizarTela(); }
private void BtnParaTesteDebaterias_Click(object sender, RoutedEventArgs e) { NobreakInterface.SetTestOff(); if (MainWindow.Package?.Status != null) { MainWindow.Package.Status.TesteAtivo = false; } AtualizarTela(); }
private void BtnBeepOnOf_Click(object sender, RoutedEventArgs e) { NobreakInterface.SetBeepOnOf(); if (MainWindow.Package?.Status != null) { MainWindow.Package.Status.BeepLigado = !MainWindow.Package.Status.BeepLigado; } AtualizarTela(); }
public MainWindow() { InitializeComponent(); var screenWidth = SystemParameters.PrimaryScreenWidth; var screenHeight = SystemParameters.PrimaryScreenHeight; MainWindow1.Left = screenWidth - MainWindow1.Width - 700; MainWindow1.Top = screenHeight - MainWindow1.Height - (screenHeight > screenWidth ? 82 : 40); //MainWindow1.Top = screenHeight - MainWindow1.Height - (screenHeight > screenWidth ? 82 : 48); NobreakInterface = new NobreakInterface(Callback); Connect(); }
private async Task GetStatus() { await Task.Run(async() => { while (true) { try { NobreakInterface.GetStatus(); await Task.Delay(GET_DATA_FREQUENCY); } catch (Exception ex) { Write(ex.Message); break; } } }); }