Ejemplo n.º 1
0
        /// <summary>
        /// This is a blocking call that doesn't finish until the requested pattern is confirmed to be displayed.
        /// </summary>
        /// <param name="p"> The pattern to be displayed and confirmed. </param>
        protected override void ShowPattern(TrueTestPattern p)
        {
            if (p == null)
            {
                return;
            }

            // Check that the pattern is the appropriate type for the DI to send.
            if (!p.Pattern.GetType().Equals(typeof(SimplePattern)))
            {
                return;
            }

            AckRecieved = false;
            SimplePattern pattern        = (SimplePattern)p.Pattern;
            string        PatternNumber  = pattern.ImageNumber.ToString();
            List <string> PacketDataList = new List <string>()
            {
                PatternNumber
            };
            PacketSerial PatternPacket = new PacketSerial(SerialCommand.ShowPattern, PacketDataList);

            PatternPacket.Send(this);

            if (!WaitForAck())
            {
                // Fixture timed out changing the pattern
                WriteToLog("Fixture did not send the Pattern Ready (PR) command after TrueTest requested pattern #" + PatternNumber + ".");
                TrueTest.SequenceStop(); // Cancel sequence
            }
        }
Ejemplo n.º 2
0
 private void ExposureComplete(object sender, ExposureCompleteEventArgs e)
 {
     ExposuresCompleted += 1;
     WriteToLog("Exposure Number " + ExposuresCompleted + " is complete.");
     if (ExposuresCompleted >= NumberOfSequenceExposures)
     {
         // We've taken all of the exposures and we can unload the panel now
         PacketSerial UnloadPacket = new PacketSerial(SerialCommand.Unload);
         UnloadPacket.Send(this);
     }
 }
Ejemplo n.º 3
0
        public void SequenceComplete(object sender, SequenceCompleteEventsArgs e)
        {
            WriteToLog("Sequence Complete...");

            string ResultString = e.PassFail == TrueTest.AnalysisResultEnum.Pass ? "OK" : "NG";

            List <string> DataStringList = new List <string>()
            {
                ResultString
            };

            PacketSerial ResultPacket = new PacketSerial(SerialCommand.Result, DataStringList);

            ResultPacket.Send(this);
        }
Ejemplo n.º 4
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);
            }
        }