public TOSADevice GetTOSADevice(int id) { if (!File.Exists(DbFile)) { return(null); } using (var conn = SimpleDbConnection()) { conn.Open(); TOSADevice device = conn.Query <TOSADevice>( @"SELECT Id, Part_Number, I_Align, P_Min_TO, P_Min_FC, V_Max, POPCT_Min, P_FC_Shift_Max FROM TOSADevice where Id = @id", new { id }).FirstOrDefault(); return(device); } }
public TOSADevice GetTOSADevice(int id) { if (!File.Exists(DbFile)) { return(null); } using (var cnn = DataFileConnection()) { cnn.Open(); TOSADevice result = cnn.Query <TOSADevice>( @"select * from TOSADevice where id = @id", new { id }).FirstOrDefault(); return(result); } }
public void SaveTOSADevice(TOSADevice device) { using (var conn = SimpleDbConnection()) { conn.Open(); conn.Execute( @"INSERT INTO TOSADevice ( Part_Number, I_Align, I_Align_Tol, P_Min_TO, P_Min_FC, V_Max, POPCT_Min, P_FC_Shift_Max ) values ( @part_number, @i_align, @i_align_tol, @p_min_to, @p_min_fc, @v_max, @popct_min, @p_fc_shift_max )", new { part_number = device.Part_Number, i_align = device.I_Align, i_align_tol = device.I_Align_Tol, p_min_to = device.P_Min_TO, p_min_fc = device.P_Min_FC, v_max = device.V_Max, popct_min = device.POPCT_Min, p_fc_shift_max = device.P_FC_Shift_Max }); } }
private async void Sweep() { TOSADevice device = d as TOSADevice; TOSAOutput output = o as TOSAOutput; bool sweepResult = true; SweepData sweepData = await TestCalculations.SweepTest(device.I_Start, device.I_Stop, device.I_Step, sweepProgress); sd = sweepData; double r = TestCalculations.FindSlope(sweepData.currents, sweepData.voltages, device.I_OP_Min, device.I_OP_Max) * 1000; resistance.Text = r.ToString("F") + " Ω"; bool R_Pass = (r >= device.RS_Min && r <= device.RS_Max); output.RS = r; output.RS_Pass = R_Pass; if (!R_Pass) { resistance.Foreground = Brushes.OrangeRed; sweepResult = false; } double se = TestCalculations.FindSlope(sweepData.currents, sweepData.powers, device.I_OP_Min, device.I_OP_Max); slopeEfficiency.Text = se.ToString("F"); bool SE_Pass = (se >= device.SE_Min && se <= device.SE_Max); output.SE = se; output.SE_Pass = SE_Pass; if (!SE_Pass) { slopeEfficiency.Foreground = Brushes.OrangeRed; sweepResult = false; } double ith = TestCalculations.ThresholdCurrent(sweepData, device.I_OP_Min, device.I_OP_Max); thresholdCurrent.Text = ith.ToString("F") + " mA"; bool ITH_Pass = (ith >= device.Ith_Min && ith <= device.Ith_Max); output.Ith = ith; output.Ith_Pass = ITH_Pass; measurementPanel.Visibility = Visibility.Visible; if (!ITH_Pass) { thresholdCurrent.Foreground = Brushes.OrangeRed; sweepResult = false; } double p_test = sweepData.powers.ElementAt(sweepData.setcurrents.IndexOf(device.I_Test)); testPower.Text = p_test.ToString("F") + " mW"; bool P_Test_Pass = (p_test >= device.P_Test_FC_Min && p_test <= device.P_Test_FC_Max); output.P_Test_FC = p_test; output.P_Test_FC_Pass = P_Test_Pass; if (!P_Test_Pass) { testPower.Foreground = Brushes.OrangeRed; sweepResult = false; } double popct = p_test / output.P_Test_OB; POPCT.Text = (100 * popct).ToString("F") + " %"; bool POPCT_Pass = (popct >= device.POPCT_Min); output.POPCT = popct; output.POPCT_Pass = POPCT_Pass; if (!POPCT_Pass) { testPower.Foreground = Brushes.OrangeRed; sweepResult = false; } double ibm = TestCalculations.IBM_PBM(sweepData, device.P_BM_Test); monitorCurrent.Text = ibm.ToString("F") + " mA"; bool IBM_Pass = (ibm >= device.IBM_Min && ibm <= device.IBM_Max); output.I_BM_P_BM_Test = ibm; output.I_BM_P_BM_Test_Pass = IBM_Pass; if (!IBM_Pass) { monitorCurrent.Foreground = Brushes.OrangeRed; sweepResult = false; } double pmin = sweepData.powers.ElementAt(sweepData.setcurrents.IndexOf(device.I_OP_Min)); double pmax = sweepData.powers.ElementAt(sweepData.setcurrents.IndexOf(device.I_OP_Max)); double ibmslope = TestCalculations.FindSlope(sweepData.powers, sweepData.ibms, pmin, pmax); ibmSlope.Text = ibmslope.ToString("F") + " A/W"; output.I_BM_Slope = ibmslope; double ibmtrack = TestCalculations.IBM_Track(sweepData, device.I_OP_Min, device.I_OP_Max); ibmTrack.Text = ibmtrack.ToString("F"); bool IBM_Track_Pass = (ibmtrack >= device.IBM_Tracking_Min && ibmtrack <= device.IBM_Tracking_Max); output.IBM_Track = ibmtrack; output.I_BM_Track_Pass = IBM_Track_Pass; if (!IBM_Track_Pass) { ibmTrack.Foreground = Brushes.OrangeRed; sweepResult = false; } measurementPanel.Visibility = Visibility.Visible; var w = Window.GetWindow(this) as MainWindow; if (sweepResult) { passed = true; testMessage.Text = "Test Passed"; testMessage.Foreground = Brushes.ForestGreen; StartTestButton.Content = "Next step"; d = device; o = output; w.device = d; w.output = o; } else { testMessage.Text = "Test Failed"; testMessage.Foreground = Brushes.OrangeRed; if (numTries >= 3) { StartTestButton.Content = "Go home"; output.Result = false; MainWindow.Conn.SaveTOSAOutput(output); } else { StartTestButton.Content = "Retry test"; } } SaveLIButton.Visibility = Visibility.Visible; }
private void OpenBoreTest() { TOSADevice device = d as TOSADevice; TOSAOutput output = o as TOSAOutput; bool openBoreResult = true; OBData ob = TestCalculations.OpenBoreTest(device.I_Test, device.VBR_Test); foreach (TextBlock tb in Utils.FindVisualChildren <TextBlock>(measurementPanel)) { tb.Foreground = Brushes.White; } testCurrent.Text = ob.i_test.ToString("F") + " mA"; output.I_Test = ob.i_test; bool I_Test_Pass = (Math.Abs(device.I_Test - ob.i_test) / device.I_Test <= device.I_Test_Tol); if (!I_Test_Pass) { testCurrent.Foreground = Brushes.OrangeRed; openBoreResult = false; } testPower.Text = ob.p_test.ToString("F") + " mW"; bool P_Test_OB_Pass = (ob.p_test >= device.P_Test_OB_Min && ob.p_test <= device.P_Test_OB_Max); output.P_Test_OB = ob.p_test; output.P_OB_Pass = P_Test_OB_Pass; if (!P_Test_OB_Pass) { testPower.Foreground = Brushes.OrangeRed; openBoreResult = false; } testVoltage.Text = ob.v_test.ToString("F") + " V"; bool V_Test_OB_Pass = (ob.v_test >= device.V_Test_Min && ob.v_test <= device.V_Test_Max); output.V_Test = ob.v_test; output.V_Test_Pass = V_Test_OB_Pass; if (!V_Test_OB_Pass) { testVoltage.Foreground = Brushes.OrangeRed; openBoreResult = false; } monitorCurrent.Text = ob.ibm_test.ToString("F") + " mA"; bool IBM_Test_Pass = (ob.ibm_test >= device.IBM_Min && ob.ibm_test <= device.IBM_Max); if (!IBM_Test_Pass) { monitorCurrent.Foreground = Brushes.OrangeRed; openBoreResult = false; } output.IBM_Test_OB = ob.ibm_test; output.IBM_Pass = IBM_Test_Pass; reverseBreakdownCurrent.Text = ob.ibr.ToString("F") + " µA"; reverseBreakdownVoltage.Text = device.VBR_Test.ToString("F") + " V"; bool IBR_Pass = (Math.Abs(ob.ibr) <= device.IBR_Max); if (!IBR_Pass) { reverseBreakdownCurrent.Foreground = Brushes.OrangeRed; openBoreResult = false; } output.IBR = ob.ibr; output.IBR_Pass = IBR_Pass; measurementPanel.Visibility = Visibility.Visible; var w = Window.GetWindow(this) as MainWindow; if (openBoreResult) { passed = true; testMessage.Text = "Test Passed"; testMessage.Foreground = Brushes.ForestGreen; StartTestButton.Content = "Next step"; d = device; o = output; w.device = d; w.output = o; } else { testMessage.Text = "Test Failed"; testMessage.Foreground = Brushes.OrangeRed; if (numTries >= 3) { StartTestButton.Content = "Go home"; output.Result = false; MainWindow.Conn.SaveTOSAOutput(output); } else { StartTestButton.Content = "Retry test"; } } }
private async void Wiggle() { TOSADevice device = d as TOSADevice; TOSAOutput output = o as TOSAOutput; bool wiggleTestResult = true; WiggleData wiggleData = await TestCalculations.TOSAWiggleTest((int)device.Wiggle_Time, wiggleProgress); wiggleMin.Text = wiggleData.min.ToString("F") + " mW"; wiggleMax.Text = wiggleData.max.ToString("F") + " mW"; wiggleAvg.Text = wiggleData.avg.ToString("F") + " mW"; double popct_wiggle = wiggleData.min / output.P_Test_OB; popctWiggle.Text = (100 * popct_wiggle).ToString("F") + " %"; bool POPCT_Wiggle_Pass = (popct_wiggle >= device.POPCT_Wiggle_Min); output.POPCT_Wiggle_Min = popct_wiggle; output.POPCT_Wiggle_Min_Pass = POPCT_Wiggle_Pass; if (!POPCT_Wiggle_Pass) { popctWiggle.Foreground = Brushes.OrangeRed; wiggleTestResult = false; } double pwiggle = 10 * Math.Log10(wiggleData.max / wiggleData.min); wiggleDb.Text = pwiggle.ToString("F") + " dB"; bool Pwiggle_Pass = (pwiggle <= device.Pwiggle_Max); output.Wiggle_dB = pwiggle; output.Wiggle_dB_Pass = Pwiggle_Pass; if (!Pwiggle_Pass) { wiggleDb.Foreground = Brushes.OrangeRed; wiggleTestResult = false; } measurementPanel.Visibility = Visibility.Visible; var w = Window.GetWindow(this) as MainWindow; if (wiggleTestResult) { passed = true; testMessage.Text = "Test Passed"; testMessage.Foreground = Brushes.ForestGreen; StartTestButton.Content = "End job"; output.Result = true; MainWindow.Conn.SaveTOSAOutput(output); d = device; o = output; w.device = d; w.output = o; } else { testMessage.Text = "Test Failed"; testMessage.Foreground = Brushes.OrangeRed; if (numTries >= 3) { StartTestButton.Content = "Go home"; output.Result = false; MainWindow.Conn.SaveTOSAOutput(output); } else { StartTestButton.Content = "Retry test"; } } NextDeviceButton.Visibility = Visibility.Visible; }
public void SaveTOSADevice(TOSADevice tosa) { if (!File.Exists(DbFile)) { return; } using (var cnn = DataFileConnection()) { cnn.Open(); cnn.Execute( @"insert into TOSADevice ( Part_Number, I_Start, I_Step, I_Stop, I_Test, P_Test_OB_Min, P_Test_OB_Max, V_Test_Min, V_Test_Max, VBR_Test, IBM_Min, IBM_Max, P_Test_FC_Min, P_Test_FC_Max, I_OP_Min, I_OP_Max, P_BM_Test, POPCT_Min, IBM_Tracking_Min, IBM_Tracking_Max, RS_Min, RS_Max, SE_Min, SE_Max, Ith_Min, Ith_Max, Wiggle_Time, Pwiggle_Max, IBR_Max, POPCT_Wiggle_Min, ) values ( @Part_Number, @I_Start, @I_Step, @I_Stop, @I_Test, @P_Test_OB_Min, @P_Test_OB_Max, @V_Test_Min, @V_Test_Max, @VBR_Test, @IBM_Min, @IBM_Max, @P_Test_FC_Min, @P_Test_FC_Max, @I_OP_Min, @I_OP_Max, @P_BM_Test, @POPCT_Min, @IBM_Tracking_Min, @IBM_Tracking_Max, @RS_Min, @RS_Max, @SE_Min, @SE_Max, @Ith_Min, @Ith_Max, @Wiggle_Time, @Pwiggle_Max, @IBR_Max, @POPCT_Wiggle_Min ) ", new { Part_Number = tosa.Part_Number, I_Start = tosa.I_Start, I_Step = tosa.I_Step, I_Stop = tosa.I_Stop, I_Test = tosa.I_Test, P_Test_OB_Min = tosa.P_Test_OB_Min, P_Test_OB_Max = tosa.P_Test_OB_Max, V_Test_Min = tosa.V_Test_Min, V_Test_Max = tosa.V_Test_Max, VBR_Test = tosa.VBR_Test, IBM_Min = tosa.IBM_Min, IBM_Max = tosa.IBM_Max, P_Test_FC_Min = tosa.P_Test_FC_Min, P_Test_FC_Max = tosa.P_Test_FC_Max, I_OP_Min = tosa.I_OP_Min, I_OP_Max = tosa.I_OP_Max, P_BM_Test = tosa.P_BM_Test, POPCT_Min = tosa.POPCT_Min, IBM_Tracking_Min = tosa.IBM_Tracking_Min, IBM_Tracking_Max = tosa.IBM_Tracking_Max, RS_Min = tosa.RS_Min, RS_Max = tosa.RS_Max, SE_Min = tosa.SE_Min, SE_Max = tosa.SE_Max, Ith_Min = tosa.Ith_Min, Ith_Max = tosa.Ith_Max, Wiggle_Time = tosa.Wiggle_Time, Pwiggle_Max = tosa.Pwiggle_Max, IBR_Max = tosa.IBR_Max, POPCT_Wiggle_Min = tosa.POPCT_Wiggle_Min } ); } }