Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        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();
            }
        }