public override void Handle(MDB_BOARD board) { try { string[] lines = board.Start_script("--com " + board.RS232Port); for (int i = 0; i < lines.Length; i++) { if (lines[i].Contains("FAILED")) { if (lines[i - 1].Contains("SERIAL") || lines[i - 1].Contains("[M <]checking MDB S -> M") || (lines[i - 1].Contains("[M <]checking MDB S -> M"))) { Debug.WriteLine("Serial failed"); GoToNextState(board, false); return; } } } Thread.Sleep(100); GoToNextState(board, true); //Debug.WriteLine("RS232 Sucess"); } catch (Exception e) { GoToNextState(board, false); Debug.WriteLine("RS232 Fail - Exception: " + e.Message); } }
public override void Handle(MDB_BOARD board) { Debug.WriteLine("Leds Handle"); MessageBoxResult response = MessageBoxResult.No; response = MessageBox.Show("Starting Leds Test\n Are you ready?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question); if (response == MessageBoxResult.Yes) { try { string[] lines = board.Start_script("--leds"); if (lines.Length >= 10 && lines[0].Contains("[M >]M,TEST_LED") && lines[1].Contains("[M <]m,ACK") && lines[2].Contains("[M <]checking LEDs...") && lines[3].Contains("[M <]1") && lines[4].Contains("[M <]2") && lines[5].Contains("[M <]3") && lines[6].Contains("[M <]4") && lines[7].Contains("[M <]all") && lines[8].Contains("[M <]-------------------------") && lines[9].Contains("- closing mdb connection")) { response = MessageBox.Show("Leds ok?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question); if (response == MessageBoxResult.Yes) { //Debug.WriteLine("Nice"); GoToNextState(board, true); } else { //Debug.WriteLine("Fail"); GoToNextState(board, false); } } else { Debug.WriteLine("Leds Fail"); GoToNextState(board, false); } } catch (Exception e) { GoToNextState(board, false); Debug.WriteLine("Leds Fail - Exception: " + e.Message); } } else { GoToNextState(board, false); Debug.WriteLine("Leds Fail"); } }
public override void Handle(MDB_BOARD board) { //Debug.WriteLine("Relay Handle"); try { board.NucleoMessage = ""; board.SendToNucleo("3"); Thread.Sleep(1000); if (board.NucleoMessage == null) { Debug.WriteLine("No Reset ACK... Failed State"); GoToNextState(board, false); return; } if (!board.NucleoMessage.Contains("Reset")) { Debug.WriteLine("No Reset ACK... Failed State"); GoToNextState(board, false); return; } string[] lines = board.Start_script("--relay"); if (lines.Length >= 9 && lines[0].Contains("[M >]M,TEST_REL") && lines[1].Contains("[M <]m,ACK") && lines[2].Contains("[M <]checking RELAY...") && lines[3].Contains("[M <]ON") && lines[4].Contains("[M <]OFF") && lines[5].Contains("[M <]ON") && lines[6].Contains("[M <]OFF") && lines[7].Contains("[M <]-------------------------") && lines[8].Contains("- closing mdb connection")) { board.NucleoMessage = ""; Thread.Sleep(1000); board.SendToNucleo("4"); Thread.Sleep(1000); List <String> listStrLineElements = board.NucleoMessage.Split(';').ToList(); Debug.WriteLine("RELAY PASSED"); foreach (var item in listStrLineElements) { var number = int.Parse(Regex.Match(item, "\\d+").Value); if (number > 2 || number <= 0) { Debug.WriteLine("ops"); } Debug.WriteLine(item.ToString()); } //Debug.WriteLine(listStrLineElements); GoToNextState(board, true); } else { Debug.WriteLine("RELAY FAIL"); GoToNextState(board, false); } } catch (Exception e) { Debug.WriteLine("RELAY FAIL - Exception: " + e.Message); GoToNextState(board, false); } }