public override bool Run() { string rs = WriteCommand($"echo {BUZZER_HZ} > {BUZZER_PATH}/period"); rs = WriteCommand($"echo {BUZZER_HZ/2} > {BUZZER_PATH}/duty_cycle"); rs = WriteCommand($"echo 1 > {BUZZER_PATH}/enable"); //var dialogResult = MessageBox.Show("Is Buzzer Active?", "Buzzer?", MessageBoxButtons.YesNo); TestStatusQuestion = new ShowQuestionDlg("Is Buzzer Active?", "Buzzer?", MessageBoxButtons.YesNo); var dialogResult = TestStatus.ShowQuestionDlg.DialogResult; while (TestStatus.ShowQuestionDlg.DialogResult == DialogResult.None) { ; } // Turn it off rs = WriteCommand($"echo 0 > {BUZZER_PATH}/enable"); if (dialogResult == DialogResult.No || dialogResult == DialogResult.Cancel) { TestErrorTxt = "Buzzer was not active"; return(false); } return(true); }
public override bool Run() { TestStatusTxt = "Testing LEDs"; string line = WriteCommand(""); WriteCommand(""); WriteCommand("echo none > " + string.Format(LED_TRIGGER_PATH, "red")); WriteCommand("echo none > " + string.Format(LED_TRIGGER_PATH, "yellow")); WriteCommand("echo none > " + string.Format(LED_TRIGGER_PATH, "green")); DialogResult dialogResult = DialogResult.None; CancellationTokenSource cts = new CancellationTokenSource(); var task = Task.Factory.StartNew(() => { while (dialogResult == DialogResult.None) { if (cts.Token.IsCancellationRequested) { break; } try { WriteCommand("echo 0 > " + string.Format(LED_BRIGHTNESS_PATH, "red"), cmd_delay_ms: 100); WriteCommand("echo 0 > " + string.Format(LED_BRIGHTNESS_PATH, "yellow"), cmd_delay_ms: 100); WriteCommand("echo 0 > " + string.Format(LED_BRIGHTNESS_PATH, "green"), cmd_delay_ms: 100); Thread.Sleep(250); WriteCommand("echo 1 > " + string.Format(LED_BRIGHTNESS_PATH, "red"), cmd_delay_ms: 100); WriteCommand("echo 1 > " + string.Format(LED_BRIGHTNESS_PATH, "yellow"), cmd_delay_ms: 100); WriteCommand("echo 1 > " + string.Format(LED_BRIGHTNESS_PATH, "green"), cmd_delay_ms: 100); Thread.Sleep(250); } catch { break; } } }, cts.Token); //dialogResult = MessageBox.Show("Are LEDs flashing?", "LEDs?", MessageBoxButtons.YesNo); TestStatusQuestion = new ShowQuestionDlg("Are LEDs flashing?", "LEDs?", MessageBoxButtons.YesNo); while (TestStatus.ShowQuestionDlg.DialogResult == DialogResult.None) { ; } dialogResult = TestStatus.ShowQuestionDlg.DialogResult; cts.Cancel(); task.Wait(); // Leave leds on WriteCommand("echo 1 > " + string.Format(LED_BRIGHTNESS_PATH, "red"), timeout_sec: 2); WriteCommand("echo 1 > " + string.Format(LED_BRIGHTNESS_PATH, "yellow"), timeout_sec: 2); WriteCommand("echo 1 > " + string.Format(LED_BRIGHTNESS_PATH, "green"), timeout_sec: 2); if (dialogResult == DialogResult.Yes) { return(true); } else { TestErrorTxt = "LEDs were not all flashing"; return(false); } }