private async void buttonArduinoSync_Click(object sender, EventArgs e) { try { // RefreshInfo for all arduinos already added: foreach (var ard in serial.LCAArduinos) { await ard.ReadConfig(); } await serial.ActivateAllArduinos(); // Activates (Ping + ReadConfig) all arduinos that have not been added yet RefreshControlsEnable(); } catch (Exception ex) { Console.WriteLine("In buttonArduinoSync_Click: Exception: {0}", ex.Message); } }
private string UserDefaultLanguage = "en"; // The language the user chose to use as a default (not implemented yet) // The constructor. This sets up most of what this program does. public Main() { AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += new UnhandledExceptionEventHandler(Main_UnhandledException); // Create the SerialInterface object serial = SerialInterface.Create(); // Subscribe to some events: FormClosing += Main_FormClosing; // Might not be needed anymore serial.ArduinoChanged += Serial_ArduinoChanged; serial.ArduinoDataChanged += Serial_ArduinoDataChanged; InitializeComponent(); // Unfocus controls as necessary when the user clicks any of these controls: this.MouseDown += UnfocusControls; tabControl.MouseDown += UnfocusControls; menuStrip1.MouseDown += UnfocusControls; StatusPage.MouseDown += UnfocusControls; ConfigPage.MouseDown += UnfocusControls; SensorsPage.MouseDown += UnfocusControls; DataPage.MouseDown += UnfocusControls; panelStartDelay.MouseDown += UnfocusControls; labelConfigSec2.MouseDown += UnfocusControls; labelConfigSec.MouseDown += UnfocusControls; labelConfigMin.MouseDown += UnfocusControls; labelConfigHr.MouseDown += UnfocusControls; labelPackageName.MouseDown += UnfocusControls; labelSamplePeriod.MouseDown += UnfocusControls; labelTestDuration.MouseDown += UnfocusControls; labelStartDelay.MouseDown += UnfocusControls; // Config Page setup: checkBoxSyncTimeDate.Tag = false; // Unchecked by default textBoxPackageName.TextChanged += TextBoxPackageName_TextChanged; numericUpDownSamplePeriod.ValueChanged += NumericUpDownSampleRate_ValueChanged; numericUpDownTestDurationHours.ValueChanged += NumericUpDownTestDuration_ValueChanged; numericUpDownTestDurationMinutes.ValueChanged += NumericUpDownTestDuration_ValueChanged; numericUpDownTestDurationSeconds.ValueChanged += NumericUpDownTestDuration_ValueChanged; radioButtonStartDelayNone.CheckedChanged += RadioButtonStartDelayOption_CheckedChanged; radioButtonStartDelayOneMin.CheckedChanged += RadioButtonStartDelayOption_CheckedChanged; radioButtonStartDelayThreeMin.CheckedChanged += RadioButtonStartDelayOption_CheckedChanged; // Languages setup: imageComboLanguage.DropDownClosed += imageComboLanguage_DropDownClosed; // To unhighlight the selection imageComboLanguage.KeyDown += imageComboLanguage_KeyDown; imageComboLanguage.SelectedIndexChanged += imageComboLanguage_SelectedIndexChanged; LanguageText = new Dictionary <string, string>(); AvailableLanguages = new SortedSet <string>(); LanguageIcons = new ImageList(); LanguageIcons.ImageSize = new Size(imageComboLanguage.ImageList.ImageSize.Height, imageComboLanguage.ImageList.ImageSize.Height); CurrentLanguage = ""; LoadLanguages(); Console.WriteLine("\n\n\n"); // Arduino List setup: deviceList = new object[] { "<No Device>" }; // This doesn't work! //arduinoList.Items.AddRange(deviceList); arduinoListBinding = new BindingSource(); arduinoListBinding.DataSource = serial.LCAArduinos; arduinoListBinding.ListChanged += Serial_LCAArduinos_Changed; arduinoList.DataSource = arduinoListBinding; arduinoList.DisplayMember = "displayName"; // Start watching for USB PnP (Plug and Play) devices to be added/removed/modified: serial.StartPnPWatcher(); // Find LCA Arduinos (our sensor array Arduinos): serial.ActivateAllArduinos(); RefreshControlsEnable(); }