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(); }
/// <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 } }
void TrueTest__MeasurementComplete(object sender, string e) { if (!TrueTest.AppSettings().DisplayCameraMeasurements) { return; } var mode = ObjectRepository.ReadWriteEnum.ReadOnlyNoWait; var ea = ObjectRepository.GetItem(e, ref mode) as MeasurementCompleteEventArgs; if (ea != null) { UpdateBitmap(ea.Measurement); } }
void TrueTest__DefectListChanged(object sender, string e) { if (!TrueTest.AppSettings().DisplayDefectList) { return; } var mode = ObjectRepository.ReadWriteEnum.ReadOnlyNoWait; var ea = ObjectRepository.GetItem(e, ref mode) as DefectListChangedEventArgs; if (ea != null) { SetDefectList(ea.DefectList); } }
void TrueTest__AnalysisComplete(object sender, string e) { var mode = ObjectRepository.ReadWriteEnum.ReadOnlyNoWait; var ea = ObjectRepository.GetItem(e, ref mode) as AnalysisCompleteEventArgs; if (ea != null) { string s = ea.Results.Count > 0 ? ea.Results[0].Name + "= " + ea.Results[0].Value.ToString() : ""; MessageBox.Show("Analysis Complete: " + ea.AnalysisUserName + Environment.NewLine + s + Environment.NewLine + ea.PassFail.ToString()); if (ea.PassFail == TrueTest.AnalysisResultEnum.Fail) { // cancel the rest of the sequence TrueTest.SequenceStop(); } } }
/// <summary> /// Checks the sequence for each unique measurement as analyses may reuse measurements already taken for others. /// </summary> public void PrepareForSequenceRunAll(object sender, EventArgs e) { // Calculate how many exposures are going to be required to run the sequence List <PatternSetup> PatternList = new List <PatternSetup>(); NumberOfSequenceExposures = 0; var sequence = TrueTest.get_Sequence(0); foreach (TrueTestEngine.SequenceItem SeqStep in sequence.Items) { if (!SeqStep.Selected) { continue; } PatternSetup ps = sequence.GetPatternSetupByName(SeqStep.PatternSetupName); if (ps == null) { continue; } // Check to see if we already counted this pattern's exposures bool RepeatPattern = false; foreach (PatternSetup P in PatternList) { if (P == ps) { RepeatPattern = true; break; } } if (!RepeatPattern) { PatternList.Add(ps); NumberOfSequenceExposures += 1; } } WriteToLog("This sequence will require " + NumberOfSequenceExposures + " camera exposures."); // Reset the number of exposures completed ExposuresCompleted = 0; }
private void Form1_Load(object sender, EventArgs e) { var calibrationDBResult = TrueTest.APIResultEnum.Success; var sequenceDBResult = TrueTest.APIResultEnum.Success; var measurementDBResult = TrueTest.APIResultEnum.Success; string calibrationDatabase = Properties.Settings.Default.CalibrationDatabase; string sequenceFileName = Properties.Settings.Default.SequenceXMLPathFileName; string measurementFileName = Properties.Settings.Default.MeasurementDatabasePathFileName; // Initialize TrueTest TrueTest.Initialize(ref calibrationDatabase, ref sequenceFileName, ref measurementFileName, this, //Give TrueTest a reference to the main application form (this) ref calibrationDBResult, ref sequenceDBResult, ref measurementDBResult); // The strings are passed in by reference, so if the user browses to select a new file during initialization, the values will be automatically updated // Therefore we still need to save My.Settings. Properties.Settings.Default.CalibrationDatabase = calibrationDatabase; Properties.Settings.Default.SequenceXMLPathFileName = sequenceFileName; Properties.Settings.Default.MeasurementDatabasePathFileName = measurementFileName; Properties.Settings.Default.Save(); // Add some event handlers to handle events coming from TrueTest AddTrueTestEventHandlers(); // Tells TrueTest to take measurements with the camera rather than retrieving measurements from the database TrueTest.OperatingMode = TrueTest.OperatingModeEnum.UseCamera; // Makes sure to save all results into the measurement database TrueTest.AppSettings().SaveAnalysisResultsToDatabase = true; // If the user wants to make a camera measurement, make sure it gets saved to the database TrueTest.SaveMeasurementsToDatabase = true; this.Text = TrueTest.get_Sequence().Name; }
private void Form1_FormClosing(object sender, EventArgs e) { TrueTest.Shutdown(); }
private void EditButton_Click(object sender, EventArgs e) { TrueTest.ShowEditSequenceDialog(); }
/// <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); } }