public override void Handle(MDB_BOARD board) { //throw new NotImplementedException(); if (board.NucleoPort == null) { GoToNextState(board, false); } else { board.NucleoMessage = ""; Thread.Sleep(1500); board.SendToNucleo("1"); Thread.Sleep(1500); if (board.NucleoMessage != null) { device_current = board.NucleoMessage; board.BoardCurrent = Regex.Match(board.NucleoMessage, @"\d+").Value; Debug.WriteLine(board.BoardCurrent + "mA"); board.SetMDBSupply(); } board.NucleoMessage = ""; Thread.Sleep(1500); board.SendToNucleo("5"); Thread.Sleep(1500); if (board.NucleoMessage != null) { usb_volt = board.NucleoMessage; board.BoardCurrent = Regex.Match(board.NucleoMessage, @"\d+").Value; Debug.WriteLine(usb_volt + "mV"); } if (board.BoardCurrent != null) { GoToNextState(board, true); } } }
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); } }