void SaveDataToDatabase() { try { string batchName = null; foreach (int Socket in LifetimeTest.TestResults.Keys) { string CurrentSerialNumber = listLifetimeInfo1.GetSerialNumber(Socket); Dispatcher.BeginInvoke(new Action(delegate() { batchName = textBatchName.Text; })); if (numericTestHour.pinValue() == 0) { //this causing prob int BaselineID = GCIDB.GetMostRecentLifetimeTestID_BaseLine(LoadedPartID, CurrentSerialNumber, batchName); // Look at this later //if (BaselineID != 0) //{ // if (MessageBox.Show("Baseline data already exists for:\nPart: " + SelectedPartName + "\nSerial Number: " + CurrentSerialNumber + "\n\nDo you want to change the baseline data to these measurements?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.Yes) // { // continue; // } // else // return; //} } int LifetimeTestID = GCIDB.GetNextLifetimeTestID(); String Batch = null; Dispatcher.BeginInvoke(new Action(delegate() { Batch = textBatchName.Text; })); DateTime Time = DateTime.Now; int Hour = (int)numericTestHour.pinValue(); double Temperature = (double)numericTemperature.pinValue(); foreach (int TestedDUTPin in LifetimeTest.TestResults[Socket].Keys) { double AverageVoltage = LifetimeTest.TestResults[Socket][TestedDUTPin].GetVoltageAverage(); double StdDev = LifetimeTest.TestResults[Socket][TestedDUTPin].GetStandardDeviation(); for (int j = 0; j < LifetimeTest.TestResults[Socket][TestedDUTPin].VoltageReadings.Count; j++) { Console.WriteLine(j - 1); double MeasuredVoltage = LifetimeTest.TestResults[Socket][TestedDUTPin].VoltageReadings[j]; GCIDB.AddLifetimeTestData(LifetimeTestID, CurrentSerialNumber, Batch, LoadedPartID, Hour, LoadedLifetimeLimitID, Temperature, TestedDUTPin, j, MeasuredVoltage, AverageVoltage, StdDev, Time); } } } } catch (Exception ex) { MessageBox.Show("SaveDataToDatabase(): " + ex.ToString()); } }
void CompareToLimits() { try { //if (this.InvokeRequired == true) //if(this.BeginInvokeRequired == true) { //{ // this.Invoke(new MethodInvoker(delegate // { Dispatcher.BeginInvoke(new Action(delegate() { TreeViewItem nodeRoot = new TreeViewItem(); nodeRoot.Header = SelectedPartName + " - " + textBatchName.Text; treeReport.Items.Add(nodeRoot); TreeViewItem nodeLifeTimeLimitRoot = new TreeViewItem(); nodeLifeTimeLimitRoot.Header = "Lifetime limits for this part"; //nodeLifeTimeLimitRoot.Expand(); TreeViewItem nodeLifeTimeLowerLimit = new TreeViewItem(); nodeLifeTimeLowerLimit.Header = "Lower lifetime range limit [mV]: " + LifetimePartLimits.LowerRange.ToString(); TreeViewItem nodeLifeTimeUpperLimit = new TreeViewItem(); nodeLifeTimeUpperLimit.Header = "Upper lifetime range limit [mV]: " + LifetimePartLimits.UpperRange.ToString(); nodeLifeTimeLimitRoot.Items.Add(nodeLifeTimeLowerLimit); nodeLifeTimeLimitRoot.Items.Add(nodeLifeTimeUpperLimit); nodeRoot.Items.Add(nodeLifeTimeLimitRoot); foreach (int Socket in LifetimeTest.TestResults.Keys) { string CurrentSerialNumber = listLifetimeInfo1.GetSerialNumber(Socket); TreeViewItem ItemserialNumber = new TreeViewItem(); ItemserialNumber.Header = listLifetimeInfo1.CurrentLifetimeInfo[Socket].SocketName + " -- " + CurrentSerialNumber; //nodeRoot.Expand(); nodeRoot.Items.Add(ItemserialNumber); int BaselineID = GCIDB.GetMostRecentLifetimeTestID_BaseLine(LoadedPartID, CurrentSerialNumber, textBatchName.Text.Trim()); if (BaselineID == 0) { return; } Dictionary <int, Double> BaselineData = GCIDB.GetLifetimeBaselineData(BaselineID); foreach (int TestedDUTPin in LifetimeTest.TestResults[Socket].Keys) { double AverageVoltage = LifetimeTest.TestResults[Socket][TestedDUTPin].GetVoltageAverage(); double StdDev = LifetimeTest.TestResults[Socket][TestedDUTPin].GetStandardDeviation(); bool PinResult = false; double UpperCompareValue = BaselineData[TestedDUTPin] + (LifetimePartLimits.UpperRange / 1000.0); double LowerCompareValue = BaselineData[TestedDUTPin] + (LifetimePartLimits.LowerRange / 1000.0); if (AverageVoltage < LowerCompareValue || AverageVoltage > UpperCompareValue) { PinResult = false; listLifetimeInfo1.SetResult(Socket, false); //AddLog("Socket " + Socket + " DUT Pin [" + TestedDUTPin + "] Average Voltage: " + AverageVoltage + " FAILED"); } else { PinResult = true; // AddLog("Socket " + Socket + " DUT Pin [" + TestedDUTPin + "] Average Voltage: " + AverageVoltage + " PASSED"); } string strPin = string.Empty; TreeViewItem nodePin; if (PinResult == true) { nodePin = new TreeViewItem(); nodePin.Header = "DUT Pin " + TestedDUTPin.ToString() + " (Passed)"; nodePin.Background = Brushes.Green; } else { nodePin = new TreeViewItem(); nodePin.Header = "DUT Pin " + TestedDUTPin.ToString() + " (Failed)"; nodePin.Background = Brushes.Red; } TreeViewItem nodeBaselineVoltage = new TreeViewItem(); nodeBaselineVoltage.Header = "Baseline (T0) Average Voltage = " + BaselineData[TestedDUTPin].ToString(); TreeViewItem nodeMeasuredVoltage = new TreeViewItem(); nodeMeasuredVoltage.Header = "T" + numericTestHour.pinValue().ToString() + " Average Voltage = " + AverageVoltage.ToString(); TreeViewItem ItemstdDevVoltage = new TreeViewItem(); ItemstdDevVoltage.Header = "T" + numericTestHour.pinValue().ToString() + " Std Dev Voltage = " + StdDev.ToString(); TreeViewItem nodeIndividualMeasurements = new TreeViewItem(); nodeIndividualMeasurements.Header = "Individual Measurements (" + LifetimeTest.TestResults[Socket][TestedDUTPin].VoltageReadings.Count.ToString() + " values)"; //foreach (double Value in LifetimeTest.TestResults[Socket][TestedDUTPin].VoltageReadings) //{ for (int i = 0; i < LifetimeTest.TestResults[Socket][TestedDUTPin].VoltageReadings.Count; i++) { nodeIndividualMeasurements.Items.Add("#" + (i + 1).ToString() + " = " + LifetimeTest.TestResults[Socket][TestedDUTPin].VoltageReadings[i].ToString()); } ItemserialNumber.Items.Add(nodePin); // nodePin.Expand(); nodePin.Items.Add(nodeBaselineVoltage); nodePin.Items.Add(nodeMeasuredVoltage); nodePin.Items.Add(ItemstdDevVoltage); nodePin.Items.Add(nodeIndividualMeasurements); //nodePin.Expand(); } // ItemserialNumber.Expand(); } })); //} } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }