public override void Handle(MDB_BOARD board) { Debug.WriteLine("Init Handle"); /* if (board.NucleoPort != null) * board.CloseSerialPort(); */ GoToNextState(board, true); }
public override void Handle(MDB_BOARD board) { Thread.Sleep(1000); board.UpdateMessage = "Error detected during testing"; Thread.Sleep(1000); Debug.WriteLine("ERROR"); if (board.NucleoPort.IsOpen) { board.CloseSerialPort(); } board.State = new SQL_Update(); }
public override void Handle(MDB_BOARD board) { board.UpdateMessage = "Saving into database"; if (board.NucleoPort != null) { board.CloseSerialPort(); } Debug.WriteLine("Update DB"); board.InsertTestResult(); GoToNextState(board, true); }
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) { 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); } } else { GoToNextState(board, false); Debug.WriteLine("Leds Fail"); } }
public override void GoToNextState(MDB_BOARD board, bool state) { state_number = 3; board.test_result[state_number] = state ? 1 : 0; board.UpdateList(state_number, state); if (state) { board.UpdateMessage = "RS232 Test Passed"; board.State = new DeviceCurrent(); } else { board.BoardErrorDescription = "RS232 Test Failed"; board.UpdateMessage = "RS232 Test Failed"; board.State = new ErrorState(); } }
public override void GoToNextState(MDB_BOARD board, bool state) { state_number = 0; //board.LastTestNumber = state_number; //board.UpdateMessageResult = state ? "Board Initialized" : "Failed to Initialize board"; //board.LastTestResult = state; state_number = 0; if (state) { board.State = new Led_State(); } else { board.State = new ErrorState(); } }
public override void GoToNextState(MDB_BOARD board, bool state) { state_number = 1; board.UpdateList(0, state); board.UpdateList(state_number, state); board.test_result[0] = state ? 1 : 0; board.test_result[state_number] = state ? 1 : 0; if (state) { board.UpdateMessage = "Leds Test Passed"; board.State = new RelayState(); } else { board.BoardErrorDescription = "Leds Test Failed"; board.UpdateMessage = "Leds Test Failed"; board.State = new ErrorState(); } }
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("RS232 State " + board.RS232Port); 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"); return; }
public override void GoToNextState(MDB_BOARD board, bool state) { state_number = 4; board.test_result[state_number] = state ? 1 : 0; board.UpdateList(state_number, state); if (board.MDB_MOD) { board.test_result[5] = state ? 1 : 0; board.BoardTestStatus = state ? 1 : 0; board.State = new SQL_Update(); } else if (state) { board.UpdateMessage = "Device Current: " + device_current + "mA"; board.State = new Led_State(); } else { board.BoardErrorDescription = "Failed to Read Device Current"; board.UpdateMessage = "Failed to Read Device Current"; board.State = new ErrorState(); } }
public override void Handle(MDB_BOARD board) { Debug.WriteLine("Finish Handle"); //context.State = new RelayState(); }
public abstract void GoToNextState(MDB_BOARD board, bool state);
public abstract void Handle(MDB_BOARD board);
private void Start_test_button_Click(object sender, RoutedEventArgs e) { if (!CheckIfFormComplete()) { MessageBox.Show("Please select all itens correctly", "Wrong Fields", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); SetStartButtonState(true); return; } MDB_Board = new MDB_BOARD(new Init_State()) { BoardOperator = operator_txtbox.Text, BoardWorkstation = combo_workStation.Text, SerialNumber = GetSerialNumber(), BoardErrorDescription = "No Errors" }; MDB_Board.ConnectToMysql(server, database, uid, password); //Check for a Valid DB Connection - Error Exit Program if (!UpdateDBConnectionBox()) { MessageBox.Show("Error Connecting to Database", "Check Database configuration", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); SetStartButtonState(true); return; } //Check for a valid Serial Number or a Repeated One - Error Exit Program if (String.IsNullOrEmpty(MDB_Board.SerialNumber) || MDB_Board.CheckRepeatedTest()) { MessageBox.Show("Error In Serial Number", "Repeated Serial Number", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); SetStartButtonState(true); return; } //So far so good... ResetProgressBar(); //Assign Serial Communication Ports MDB_Board.RS232Port = SerialCom.SelectedItem.ToString(); MDB_Board.NucleoSerialCommunication(CurrentPort.SelectedItem.ToString()); //Validate Serial Ports - Error Exit Program if (!MDB_Board.CorrectPortConfig()) { MDB_Board.CloseSerialPort(); MessageBox.Show("Wrong Port Selection", "Wrong Fields", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); SetStartButtonState(true); return; } //Set Correct Power Supply MDB_Board.SetMDBSupply(); //Everything is Ok //Start Testing with scripts in a Thread try { MDB_Board.InitializeList(); test_list.ItemsSource = MDB_Board.list_itens; UpdateTextEvolution(Environment.NewLine + "---------------------------"); StartTimer(); Thread Test_Thread = new Thread(() => MDB_Board.StartTesting()); Test_Thread.Start(); } catch { SetStartButtonState(true); MessageBox.Show("Can't communicate with board" + Environment.NewLine + "Please check cable connection", "No communication with board", MessageBoxButton.OK, MessageBoxImage.Error); timer.Stop(); } }
public override void GoToNextState(MDB_BOARD board, bool state) { throw new NotImplementedException(); }
public override void Handle(MDB_BOARD board) { Debug.WriteLine("Relay Handle"); 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) { Debug.WriteLine("ops"); } Debug.WriteLine(item.ToString()); } //Debug.WriteLine(listStrLineElements); GoToNextState(board, true); } else { Debug.WriteLine("RELAY FAIL"); GoToNextState(board, false); } }
public override void GoToNextState(MDB_BOARD board, bool state) { board.State = new FinishState(); }