⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmtest.frm

📁 Test program for Hitachi Finger Vein
💻 FRM
📖 第 1 页 / 共 3 页
字号:
                                    strPattern = ""
                                    
                                    For i = 0 To (400 - 1)
                                        strPattern = strPattern & Right$("00" & Hex(byteTemplate(i)), 2)
                                    Next
                                    
                                    Set myDB = New ADODB.Connection
                                    Set myRS = New ADODB.Recordset
                                    
                                    'myDB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Project\Finger Vein\VB\Test\Test.mdb;Persist Security Info=FalseProvider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Project\Finger Vein\VB\Test\Test.mdb;Persist Security Info=False"
                                    myDB.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Project\Finger Vein\VB\Test\Test.mdb;Persist Security Info=False"
                                    myRS.Open "SELECT * FROM FVTest WHERE ID='" & txtUserID.Text & "'", myDB, adOpenDynamic, adLockPessimistic
                                    myRS.Requery
                                    
                                    If myRS.EOF Then
                                        myRS.AddNew
                                        myRS("ID") = txtUserID.Text
                                    End If
                                    
                                    If optFinger(0).Value Then
                                        myRS("F01") = strPattern
                                    ElseIf optFinger(1).Value Then
                                        myRS("F02") = strPattern
                                    Else
                                        myRS("F03") = strPattern
                                    End If
                                    
                                    myRS.Update
                                    
                                    myRS.Close
                                    myDB.Close
                                    
                                    Set myRS = Nothing
                                    Set myDB = Nothing
                                    
                                    Call Add2List("Enrollment is success ...")
                                'Else
                                '    Call Add2List("Error during saving data ... enrollment is aborted !")
                                'End If
                            'Else
                            '    Call Add2List("Error during saving data ... enrollment is aborted !")
                            'End If
                        Else
                            Call Add2List("Template already exist ... enrollment is aborted !")
                        End If
                    Else
                        Call Add2List("Can not get the optimum template !!!")
                    End If
                Else
                    Call Add2List("Error during select optimum template !!!")
                End If
            End If
            
            'Turn ON LED
            nRet = UBR_LEDOnOff(comONLINE, tmrTimeOut, False)
            
        End If
        
        Call cmdEraseTemplateRAM_Click
    End If
    
    Me.MousePointer = 0
End Sub

Private Function SimilarityCheck(ByRef byteTemplate() As Byte) As Boolean
    Dim bCont As Boolean
    Dim bRet As Boolean
    Dim iRet As Long
    
    bRet = False
    
    bRet = UBR_SimilarityCheckStart(comONLINE, tmrTimeOut, byteTemplate)
    If bRet Then
        bCont = True
        
        While bCont
            iRet = UBR_SimilarityCheckResult(comONLINE, tmrTimeOut)
            Select Case Chr$(iRet)
                Case "0"
                    'Still executing the request ....
                    'Keep do looping
                    
                Case "1"
                    'There is no similar template in FV RAM
                    bRet = False
                    bCont = False
                    
                Case "9"
                    'There is no template in FV RAM (RAM is empty)
                    bRet = False
                    bCont = False
                    
                Case "A"
                    'Have a similar template
                    bRet = True
                    bCont = False
                    
                Case Else
                    '"9" = Abnormal sequence
                    '"B" = Abnormality occurred
                    '"F" = Abnormal closed
                    Debug.Print "ErrCode : " & Chr$(iRet)
                    Call Add2List("ErrCode : " & Chr$(iRet))
                    bCont = False
            End Select
        Wend
    End If
    
    SimilarityCheck = bRet
End Function

Private Sub cmdEraseSetExternalTemplate_Click()
    Dim nRet As Boolean
    
    Me.MousePointer = 11
    
    If comONLINE.PortOpen Then
        nRet = UBR_Erase_SetExternalTemplate(comONLINE, tmrTimeOut)
        Call Add2List("Erase Set External Template " & IIf(nRet, "is success ...", "is failed !!!"))
    End If
    
    Me.MousePointer = 0
End Sub

Private Sub cmdEraseTemplateRAM_Click()
    Dim nRet As Boolean
    
    Me.MousePointer = 11
    
    If comONLINE.PortOpen Then
        nRet = UBR_EraseTemplateSDRAM(comONLINE, tmrTimeOut)
        Call Add2List("Erase internal template (SDRAM) " & IIf(nRet, "is success ...", "is failed !!!"))
    End If
    
    Me.MousePointer = 0
End Sub

Private Sub cmdEraseTemplateROM_Click()
    Dim nRet As Boolean
    
    Me.MousePointer = 11
    
    If comONLINE.PortOpen Then
        'OnDebugMode = True
        nRet = UBR_EraseTemplateFlashROM(comONLINE, tmrTimeOut)
        Call Add2List("Erase internal template (Flash ROM) " & IIf(nRet, "is success ...", "is failed !!!"))
        'OnDebugMode = False
    End If
    
    Me.MousePointer = 0
End Sub

'Private Function Save2RAM(ByRef byteTemplate() As Byte) As Boolean
'
'End Function

Private Sub cmdInit_Click()
    Dim nRet As Boolean
    Dim nIndex As Integer
    
    Me.MousePointer = 11
    
    If comONLINE.PortOpen Then
        If cmdInit.Caption = "Create Session" Then
            nIndex = 0
            nRet = UBR_CreateSession(comONLINE, tmrTimeOut)
            If nRet Then
                cmdInit.Caption = "Close Session"
            End If
        Else
            nIndex = 1
            nRet = UBR_CloseSession(comONLINE, tmrTimeOut)
            If nRet Then
                cmdInit.Caption = "Create Session"
            End If
        End If
        
        Call Add2List(IIf(nIndex = 0, "Create Session", "Close Session") & " " & IIf(nRet, "is success ...", "is failed !!!"))
        
        'If nIndex = 0 And nRet Then
        '    nRet = UBR_LoadInternalTemplate(comONLINE, tmrTimeOut)
        '    Call Add2List(IIf(nRet, "Load Internal Template is success ...", "Failure during load internal template !!!"))
        'End If
    End If
    
    Me.MousePointer = 0
End Sub

Private Sub cmdLED_Click()
    Dim nRet As Boolean
    Dim nIndex As Integer
    
    Me.MousePointer = 11
    
    If comONLINE.PortOpen Then
        If cmdLED.Caption = "Turn On LED" Then
            nIndex = 0
            nRet = UBR_LEDOnOff(comONLINE, tmrTimeOut, False)
            If nRet Then
                cmdLED.Caption = "Turn Off LED"
            End If
        Else
            nIndex = 1
            nRet = UBR_LEDOnOff(comONLINE, tmrTimeOut, True)
            If nRet Then
                cmdLED.Caption = "Turn On LED"
            End If
        End If
        
        Call Add2List(IIf(nIndex = 0, "Turn-ON LED", "Turn-OFF LED") & " " & IIf(nRet, "is success ...", "is failed !!!"))
    End If
    
    Me.MousePointer = 0
End Sub

Private Sub cmdLoadInternalTemplate_Click()
    Dim bRet As Boolean
    
    Me.MousePointer = 11
    
    If comONLINE.PortOpen Then
        bRet = UBR_LoadInternalTemplate(comONLINE, tmrTimeOut)
        Call Add2List("Loading internal template is " & IIf(bRet, "success ...", "failure !!!"))
    End If
    
    Me.MousePointer = 0
End Sub

Private Sub cmdReset_Click()
    Dim nRet As Boolean
    
    Me.MousePointer = 11
    
    If comONLINE.PortOpen Then
        nRet = UBR_ResetDevice(comONLINE, tmrTimeOut)
        Call Add2List("Reset Device " & IIf(nRet, "is success ...", "is failed !!!"))
    End If
    
    Me.MousePointer = 0
End Sub

Private Sub cmdSetExternal2RAM_Click()
    Dim nRet As Boolean
    Dim iRet As Integer
    Dim i As Integer
    Dim j As Integer
    Dim k As Integer
    Dim nIndex As Integer
    Dim strUserID As String
    Dim strPattern1 As String
    Dim strPattern2 As String
    Dim strPattern3 As String
    Dim byteTemplate(0 To 400) As Byte
    Dim myDB As ADODB.Connection
    Dim myRS As ADODB.Recordset
    
    Me.MousePointer = 11
    
    If comONLINE.PortOpen Then
        Set myDB = New ADODB.Connection
        Set myRS = New ADODB.Recordset
        
        'myDB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Project\Finger Vein\VB\Test\Test.mdb;Persist Security Info=FalseProvider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Project\Finger Vein\VB\Test\Test.mdb;Persist Security Info=False"
        myDB.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Project\Finger Vein\VB\Test\Test.mdb;Persist Security Info=False"
        myRS.Open "SELECT * FROM FVTest WHERE ID='" & txtUserID.Text & "'", myDB, adOpenDynamic, adLockPessimistic
        myRS.Requery
        
        nRet = False
        
        If myRS.EOF Then
            MsgBox "User ID not found !!!", vbCritical + vbOKOnly
        Else
            If Not IsNull(myRS("F01")) Then
                strPattern1 = myRS("F01")
            Else
                strPattern1 = String$(800, "0")
            End If
            
            If Not IsNull(myRS("F02")) Then
                strPattern2 = myRS("F02")
            Else
                strPattern2 = String$(800, "0")
            End If
            
            If Not IsNull(myRS("F03")) Then
                strPattern3 = myRS("F03")
            Else
                strPattern3 = String$(800, "0")
            End If
                        
            nRet = True
        End If
        
        myRS.Close
        myDB.Close
        
        Set myRS = Nothing
        Set myDB = Nothing
        
        If nRet Then
            'Erase internal template
            Call cmdEraseTemplateRAM_Click
            For k = 1 To 3
                If k = 1 Then
                    If strPattern1 <> String(800, "0") Then
                        j = 0
                    Else
                        j = 1
                    End If
                End If
                
                If k = 2 Then
                    If strPattern2 <> String(800, "0") Then
                        j = 0
                    Else
                        j = 1
                    End If
                End If
                
                If k = 3 Then
                    If strPattern3 <> String(800, "0") Then
                        j = 0
                    Else
                        j = 1
                    End If
                End If
                
                If j = 0 Then
                    j = 0
                    For i = 1 To 800 Step 2
                        If k = 1 Then
                            byteTemplate(j) = "&H" & Mid$(strPattern1, i, 2)
                        ElseIf k = 2 Then
                            byteTemplate(j) = "&H" & Mid$(strPattern2, i, 2)
                        Else
                            byteTemplate(j) = "&H" & Mid$(strPattern3, i, 2)
                        End If
                        j = j + 1
                    Next
                    
                    strUserID = Left$(Trim$(txtUserID.Text) & String$(16, " "), 16)
'                    'iRet = UBR_Save2RAMStart(comONLINE, tmrTimeOut, strUserID, byteTemplate)
'                    If iRet = &H31 Then
'                        'iRet = UBR_Save2RAMResult(comONLINE, tmrTimeOut)
'                        'If iRet = &H31 Then
'                            Call Add2List("Download External Template #" & k & "is success ...")
                            iRet = UBR_Download_SetExternalTemplate(comONLINE, tmrTimeOut, (k - 1), byteTemplate)
                            If iRet = &H31 Then
                                Call Add2List("Download External Template #" & k & "is success ...")
                            Else
                                Call Add2List("Download External Template #" & k & "is failed !!!")
                            End If
'                        Else
'                            Call Add2List("Download External Template #" & k & "is success ...")
'                        'End If
'                    End If
                        
                End If
            Next
        End If
    End If
    
    Me.MousePointer = 0
End Sub

Private Sub Form_Activate()
    Me.MousePointer = 0
    OnDebugMode = False
    IsProcessFinished = False
    IsProcessIdle = True
End Sub

Private Sub Form_Load()
    Dim i As Integer
    
    cmboPORT.Clear
    
    For i = 1 To 8
        cmboPORT.AddItem "COM" & i
    Next
    
    cmboPORT.ListIndex = 0
    
    Call CenterMe(Me)
End Sub

Private Sub tmrTimeOut_Timer()
    IsTimeOut = True
    tmrTimeOut = False
End Sub

Private Sub txtUserID_Change()
    If txtUserID <> "" Then
        cmdEnroll.Enabled = True
        cmdSetExternal2RAM.Enabled = True
        cmdEraseSetExternalTemplate.Enabled = True
        cmdAuthentication1ToN_External.Enabled = True
    Else
        cmdEnroll.Enabled = False
        cmdSetExternal2RAM.Enabled = False
        cmdEraseSetExternalTemplate.Enabled = False
        cmdAuthentication1ToN_External.Enabled = False
    End If
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -