Exemple #1
0
        private void RunButton_Click(object sender, EventArgs e)
        {
            // Disables buttons on the main form
            this.EnableButtons(false);

            // Check if we should use the camrea or database
            if (this.UseCameraCheckbox.Checked)
            {
                TrueTest.OperatingMode = TrueTest.OperatingModeEnum.UseCamera;
            }
            else
            {
                TrueTest.OperatingMode = TrueTest.OperatingModeEnum.UseDatabaseAuto;
            }

            // Clear and reset the bitmap control
            RiBitmapCtl1.ROIArray = null;
            RiBitmapCtl1.ClearDefects();
            RiBitmapCtl1.Measurement = null;
            RiBitmapCtl1.SetBackColor(Color.Black);

            // Ask for the serial number.  If the user quits or cancels, exit without starting the sequence
            string serialnumber = string.Empty;

            if (TrueTest.ShowSerialNumberDialog(ref serialnumber) != System.Windows.Forms.DialogResult.OK)
            {
                EnableButtons(true);
                return;
            }

            TrueTest.SequenceRunAll();
        }
Exemple #2
0
        /// <summary>
        /// Listens for commands from serial port and calls functions depending upon command received.
        /// </summary>
        private void SerialPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            try
            {
                // 20ms Sleep introduced in order to allow the buffer to completely fill.
                System.Threading.Thread.Sleep(20);

                string       RecievedString = SerialPort.ReadLine();
                PacketSerial ReceivedPacket = new PacketSerial(RecievedString);

                switch (ReceivedPacket.Request())
                {
                case SerialCommand.SerialNumber:
                {
                    string SerialNumber = ReceivedPacket.Data[0];
                    WriteToLog("Received: SN," + SerialNumber);
                    TrueTest.set_SerialNumber(0, SerialNumber);
                    SerialPort.WriteLine("SA," + SerialNumber);
                    return;
                }

                case SerialCommand.DeviceReady:
                {
                    WriteToLog("Received: RD");

                    // Run the sequence
                    TrueTest.SequenceRunAll();

                    return;
                }

                case SerialCommand.PatternAcknowledge:
                {
                    WriteToLog("Received: PA," + ReceivedPacket.Data[0]);
                    AckRecieved = true;
                    break;
                }

                case SerialCommand.UnloadAcknowledge:
                {
                    WriteToLog("Received: UA");
                    break;
                }

                case SerialCommand.ResultAcknowledge:
                {
                    WriteToLog("Received: RA," + ReceivedPacket.Data[0]);
                    break;
                }

                default:
                {
                    WriteToLog("Unrecognized command: " + RecievedString);
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "SerialPort Error");
                WriteToLog("Receive Error: " + ex.Message);
            }
        }