diff --git a/ProductFunctionTester/Main_Form.vb b/ProductFunctionTester/Main_Form.vb index 433525c..ac2418d 100644 --- a/ProductFunctionTester/Main_Form.vb +++ b/ProductFunctionTester/Main_Form.vb @@ -2605,14 +2605,82 @@ SettingFail: End Function + 'Private Sub Jig_End() + ' If EndTest() Then + ' txbWindow.AppendText("JIG Serial Test End : FAIL" & vbCrLf) + ' Exit Sub + ' End If + ' txbWindow.AppendText("JIG Serial Test End : Success" & vbCrLf) + 'End Sub + Private Sub Jig_End() - If EndTest() Then - txbWindow.AppendText("JIG Serial Test End : FAIL" & vbCrLf) - Exit Sub - End If - txbWindow.AppendText("JIG Serial Test End : Success" & vbCrLf) + For retryCount As Integer = 0 To 2 + txbWindow.AppendText($"JIG 종료 시도 {retryCount + 1}/3" & vbCrLf) + + If EndTest() Then + txbWindow.AppendText($"JIG Serial Test End : FAIL (시도 {retryCount + 1})" & vbCrLf) + + If retryCount < 2 Then + Threading.Thread.Sleep(1000) + + If JigSerial IsNot Nothing AndAlso JigSerial.IsOpen Then + JigSerial.DiscardInBuffer() + JigSerial.DiscardOutBuffer() + Threading.Thread.Sleep(200) + End If + Continue For + Else + txbWindow.AppendText("JIG 정상 종료 실패 - 강제 종료 실행" & vbCrLf) + ForceJigShutdown() + Exit Sub + End If + Else + txbWindow.AppendText("JIG Serial Test End : Success" & vbCrLf) + Exit For + End If + Next End Sub + Private Sub ForceJigShutdown() + Try + txbWindow.AppendText("강제 JIG 종료 시작" & vbCrLf) + + If JigSerial IsNot Nothing AndAlso JigSerial.IsOpen Then + Dim shutdownCommands() As String = {"[endmft]"} + + For Each cmd In shutdownCommands + Try + SendData(cmd) + Threading.Thread.Sleep(500) + txbWindow.AppendText($"강제 종료 명령 전송: {cmd}" & vbCrLf) + Catch + + End Try + Next + + Try + Dim portName As String = JigSerial.PortName + Dim baudRate As Integer = JigSerial.BaudRate + + JigSerial.Close() + Threading.Thread.Sleep(1000) + + JigSerial.PortName = portName + JigSerial.BaudRate = baudRate + JigSerial.Open() + + txbWindow.AppendText("시리얼 포트 재연결 완료" & vbCrLf) + Catch serialEx As Exception + txbWindow.AppendText($"시리얼 포트 재연결 실패: {serialEx.Message}" & vbCrLf) + End Try + End If + + Catch ex As Exception + txbWindow.AppendText($"강제 종료 중 오류: {ex.Message}" & vbCrLf) + End Try + End Sub + + Public Function EPTestRun() As Boolean Dim ForCnt As Int16 = 0 Try @@ -4488,12 +4556,32 @@ ErrorEnd: End Function + Private Sub InitializeDeviceState() + Try + txbWindow.AppendText("기기 상태 초기화 시작..." & vbCrLf) + + Try + TestMode_On(0) ' MFT 모드를 0으로 초기화 + Threading.Thread.Sleep(300) + Catch + + End Try + + txbWindow.AppendText("기기 상태 초기화 완료" & vbCrLf) + + Catch ex As Exception + txbWindow.AppendText("기기 초기화 중 오류 (무시하고 계속): " & ex.Message & vbCrLf) + End Try + End Sub + Private Sub rfFunction() Try StartTime = MeasureTimeAll(MeasStart) TestData.Test_Serial = txbBarcode.Text + InitializeDeviceState() + If StartSwitch = True Then If JigSerial.IsOpen = True Then @@ -4625,6 +4713,19 @@ ProcessEnd: Jig_End() NormalEnd: myscope.IO.Clear() + 'txbWindow.AppendText("[" & MeasureTimeAll(MeasEnd) & "ms] Test Play" & vbCrLf) + + Try + If TestError = False Then + Jig_End() ' 지그 전원 차단 + TestMode_On(0) ' MFT 모드 초기화 + txbWindow.AppendText("비정상 종료로 인한 전원 차단" & vbCrLf) + End If + Catch normalEx As Exception + txbWindow.AppendText("정상 종료 처리 중 오류: " & normalEx.Message & vbCrLf) + End Try + + 'myscope.IO.Clear() txbWindow.AppendText("[" & MeasureTimeAll(MeasEnd) & "ms] Test Play" & vbCrLf) End Sub @@ -5260,6 +5361,29 @@ ProcessEnd: txbOkCount.Text = Val(txbOkCount.Text) + 1 End Sub + 'Private Sub RFReCount() + ' If dupDATA = 0 Then + ' txbDayCount.Text = Val(txbDayCount.Text) + 1 + ' If processNum = TestStepList.RF_NewSuc Or processNum = TestStepList.Rf_ReSuc Then + ' txbOkCount.Text = Val(txbOkCount.Text) + 1 + ' Else + ' txbNgCount.Text = Val(txbNgCount.Text) + 1 + ' End If + ' Else + ' If TDDataSet(TD_Data.TestStep) = TestStepList.Rf_NewFail Or TDDataSet(TD_Data.TestStep) = TestStepList.RF_ReFail Then + ' If processNum = TestStepList.HF_NewSuc Or processNum = TestStepList.HF_ReSuc Then + ' txbOkCount.Text = Val(txbOkCount.Text) + 1 + ' txbNgCount.Text = Val(txbNgCount.Text) - 1 + ' End If + ' Else + ' If processNum = TestStepList.HF_NEWFail Or processNum = TestStepList.HF_ReFail Then + ' txbOkCount.Text = Val(txbOkCount.Text) - 1 + ' txbNgCount.Text = Val(txbNgCount.Text) + 1 + ' End If + ' End If + ' End If + 'End Sub + Private Sub RFReCount() If dupDATA = 0 Then txbDayCount.Text = Val(txbDayCount.Text) + 1 @@ -5269,20 +5393,38 @@ ProcessEnd: txbNgCount.Text = Val(txbNgCount.Text) + 1 End If Else - If TDDataSet(TD_Data.TestStep) = TestStepList.Rf_NewFail Or TDDataSet(TD_Data.TestStep) = TestStepList.RF_ReFail Then - If processNum = TestStepList.HF_NewSuc Or processNum = TestStepList.HF_ReSuc Then - txbOkCount.Text = Val(txbOkCount.Text) + 1 - txbNgCount.Text = Val(txbNgCount.Text) - 1 + ' formType에 따라 다른 로직 적용 + If formType = formTypeList.altoPD Then + ' Alto PD의 경우 Alto 관련 TestStep 사용 + If TDDataSet(TD_Data.TestStep) = TestStepList.Rf_NewFail Or TDDataSet(TD_Data.TestStep) = TestStepList.RF_ReFail Then + If processNum = TestStepList.HF_NewSuc Or processNum = TestStepList.HF_ReSuc Then + txbOkCount.Text = Val(txbOkCount.Text) + 1 + txbNgCount.Text = Val(txbNgCount.Text) - 1 + End If + Else + If processNum = TestStepList.HF_NEWFail Or processNum = TestStepList.HF_ReFail Then + txbOkCount.Text = Val(txbOkCount.Text) - 1 + txbNgCount.Text = Val(txbNgCount.Text) + 1 + End If End If Else - If processNum = TestStepList.HF_NEWFail Or processNum = TestStepList.HF_ReFail Then - txbOkCount.Text = Val(txbOkCount.Text) - 1 - txbNgCount.Text = Val(txbNgCount.Text) + 1 + ' 일반 RF의 경우 RF 관련 TestStep 사용 + If TDDataSet(TD_Data.TestStep) = TestStepList.Rf_NewFail Or TDDataSet(TD_Data.TestStep) = TestStepList.RF_ReFail Then + If processNum = TestStepList.RF_NewSuc Or processNum = TestStepList.Rf_ReSuc Then + txbOkCount.Text = Val(txbOkCount.Text) + 1 + txbNgCount.Text = Val(txbNgCount.Text) - 1 + End If + Else + If processNum = TestStepList.Rf_NewFail Or processNum = TestStepList.RF_ReFail Then + txbOkCount.Text = Val(txbOkCount.Text) - 1 + txbNgCount.Text = Val(txbNgCount.Text) + 1 + End If End If End If End If End Sub + Private Function CountUpdate() As Boolean If rdbAltoPD.Checked = True Then DBCmd = "UPDATE " & pd1CntTableNow & " SET PD1_AltoCnt = '" & txbDayCount.Text & "', PD1_AltoOkCnt = '" & txbOkCount.Text & "', PD1_AltoNgCnt = '" & txbNgCount.Text & "' WHERE PD1_Date = '" & NowDate & "'"