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

📄 frmtest.frm

📁 Test program for Hitachi Finger Vein
💻 FRM
📖 第 1 页 / 共 3 页
字号:
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   6900
      TabIndex        =   2
      Top             =   60
      Width           =   1335
   End
End
Attribute VB_Name = "frmTest1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Add2List(ByVal strStr As String)
    'On Error Resume Next
    lstLog.AddItem strStr
    If lstLog.ListCount > 1 Then
        lstLog.ListIndex = lstLog.ListCount - 1
    Else
        lstLog.ListIndex = 0
    End If
    'On Error GoTo 0
End Sub

Private Sub cmdAuthentication1ToN_External_Click()
    Dim iRet As Long
    Dim bRet As Boolean
    Dim bCont As Boolean
    Dim bFlag2 As Boolean
    Dim bFlag3 As Boolean
    Dim IsEmptyRAM As Boolean
    Dim strUserID As String
    Dim i As Integer
    
    If comONLINE.PortOpen Then
        Me.MousePointer = 11
        
        Call UBR_FinishProcess(comONLINE, tmrTimeOut)
        Call cmdSetExternal2RAM_Click
        
        IsProcessFinished = False
        IsProcessIdle = False
        IsEmptyRAM = False
        
        While Not IsProcessFinished
            'DoEvents
            bRet = UBR_Authentication_1ToN_External_Start(comONLINE, tmrTimeOut)
            If bRet Then
                bFlag2 = True: bFlag3 = True: bCont = True
                While (Not IsProcessFinished And bCont)
                    DoEvents
                    iRet = UBR_Authentication_1ToN_External_Result(comONLINE, tmrTimeOut)
                    Select Case Chr$(iRet)
                        Case "1"
'                            strUserID = ""
'                            For i = 0 To (16 - 1)
'                                If Reply(50 + i) >= 48 And Reply(50 + i) <= 57 Then
'                                    strUserID = strUserID & Chr$(Reply(50 + i))
'                                End If
'                            Next

                            'MsgBox "Reply(11)=" & Chr(Reply(11)) & " / " & Reply(16)
                            i = Reply(16)
                            
                            Call UBR_LEDOnOff(comONLINE, tmrTimeOut, True)
                            Call UBR_LEDOnOff(comONLINE, tmrTimeOut, False)
                            Call Add2List("User Identified ....")
                            Call Add2List("Finger #" & (i + 1) & " is detected")
                            'Call Add2List("User ID = " & strUserID)
                            Call cmdEraseSetExternalTemplate_Click
                            bCont = False
                            Call DelayMSec(2000)
                            IsProcessFinished = True
                            IsEmptyRAM = True
                            
                        Case "2"
                            If bFlag2 Then
                                Call Add2List("Place your finger ....")
                            End If
                            bFlag2 = False
                            
                        Case "3"
                            If bFlag3 Then
                                Call Add2List("Capturing your finger ....")
                            End If
                            bFlag3 = False
                            
                        Case "A"
                            Call Add2List("Un-Known user ....")
                            bCont = False
                            Call cmdEraseSetExternalTemplate_Click
                            Call DelayMSec(2000)
                            IsProcessFinished = True
                            IsEmptyRAM = True
                        
                        Case "9"
                            Call cmdEraseSetExternalTemplate_Click
                            Call Add2List("No data at RAM")
                            IsProcessFinished = True
                            IsEmptyRAM = True
                            bCont = False
                            
                        Case Else
                            IsProcessFinished = True
                            IsEmptyRAM = True
                            Call cmdEraseSetExternalTemplate_Click
                            Call Add2List("ErrCode : " & Chr$(iRet))
                            bCont = False
                    End Select
                Wend
            Else
                Call Add2List("Can not start authentication process !!!")
                IsProcessFinished = True
            End If
        Wend
        
        IsProcessIdle = True
        If IsProcessFinished And Not IsEmptyRAM Then
            Call cmdEndProcess_Click
        End If
        
        Me.MousePointer = 0
    End If
End Sub

Private Sub cmdAuthentication1ToN_Internal_Click()
    Dim iRet As Long
    Dim bRet As Boolean
    Dim bCont As Boolean
    Dim bFlag2 As Boolean
    Dim bFlag3 As Boolean
    Dim IsEmptyRAM As Boolean
    Dim strUserID As String
    Dim i As Integer
    
    If comONLINE.PortOpen Then
        Me.MousePointer = 11
        
        Call UBR_FinishProcess(comONLINE, tmrTimeOut)
            
        IsProcessFinished = False
        IsProcessIdle = False
        IsEmptyRAM = False
        While Not IsProcessFinished
            'DoEvents
            bRet = UBR_Authentication_1ToN_Internal_Start(comONLINE, tmrTimeOut)
            If bRet Then
                bFlag2 = True: bFlag3 = True: bCont = True
                While (Not IsProcessFinished And bCont)
                    DoEvents
                    iRet = UBR_Authentication_1ToN_Internal_Result(comONLINE, tmrTimeOut)
                    Select Case Chr$(iRet)
                        Case "1"
                            strUserID = ""
                            For i = 0 To (16 - 1)
                                If Reply(50 + i) >= 48 And Reply(50 + i) <= 57 Then
                                    strUserID = strUserID & Chr$(Reply(50 + i))
                                End If
                            Next
                            Call UBR_LEDOnOff(comONLINE, tmrTimeOut, True)
                            Call UBR_LEDOnOff(comONLINE, tmrTimeOut, False)
                            Call Add2List("User Identified ....")
                            Call Add2List("User ID = " & strUserID)
                            bCont = False
                            Call DelayMSec(2000)
                            
                        Case "2"
                            If bFlag2 Then
                                Call Add2List("Place your finger ....")
                            End If
                            bFlag2 = False
                            
                        Case "3"
                            If bFlag3 Then
                                Call Add2List("Capturing your finger ....")
                            End If
                            bFlag3 = False
                            
                        Case "A"
                            Call Add2List("Un-Known user ....")
                            bCont = False
                            Call DelayMSec(2000)
                        
                        Case "9"
                            Call Add2List("No data at RAM")
                            IsProcessFinished = True
                            IsEmptyRAM = True
                            bCont = False
                            
                        Case Else
                            Call Add2List("ErrCode : " & Chr$(iRet))
                            bCont = False
                    End Select
                Wend
            Else
                Call Add2List("Can not start authentication process !!!")
                IsProcessFinished = True
            End If
        Wend
        
        IsProcessIdle = True
        If IsProcessFinished And Not IsEmptyRAM Then
            Call cmdEndProcess_Click
        End If
        
        Me.MousePointer = 0
    End If
End Sub

Private Sub cmdClose_Click()
    Unload Me
End Sub

Private Sub cmdComPort_Click()
    If cmdComPort.Caption = "Open COM" Then
        If comONLINE.PortOpen Then
            comONLINE.PortOpen = False
        End If
        
        comONLINE.CommPort = cmboPORT.ListIndex + 1
        comONLINE.Settings = "57600,E,8,1"
        comONLINE.PortOpen = True
        
        cmdComPort.Caption = "Close COM"
        cmdClose.Enabled = False
        
        lstLog.Clear
        Call Add2List("Com is openned")
    
        'If cmdInit.Caption = "Create Session" Then
        '    Call cmdInit_Click
        'End If
    Else
        'If cmdInit.Caption = "Close Session" Then
        '    Call cmdInit_Click
        'End If
        
        comONLINE.PortOpen = False
        
        cmdComPort.Caption = "Open COM"
        cmdClose.Enabled = True
        
        Call Add2List("Com is closed")
    End If
End Sub

Private Sub cmdEndProcess_Click()
    Dim nRet As Boolean
    
    Me.MousePointer = 11
    
    If comONLINE.PortOpen Then
        If IsProcessIdle Then
            nRet = UBR_FinishProcess(comONLINE, tmrTimeOut)
            Call Add2List("Finished process " & IIf(nRet, "is success ...", "is failed !!!"))
            IsProcessFinished = nRet
        Else
            IsProcessFinished = True
        End If
    End If
    
    Me.MousePointer = 0
End Sub

Private Sub cmdEnroll_Click()
    Dim i As Integer
    Dim nEnrollLoop As Integer
    Dim nRet As Boolean
    Dim iRet As Long
    Dim bContinue As Boolean
    Dim bFlag2 As Boolean
    Dim bFlag3 As Boolean
    Dim byteTemplate(0 To 400) As Byte
    Dim byteStore(0 To 3, 0 To 400) As Byte
    Dim IsEnrollSuccess As Boolean
    Dim nOptimumIndex As Integer
    Dim strUserID As String
    Dim strPattern As String
    Dim myDB As ADODB.Connection
    Dim myRS As ADODB.Recordset
    
    Me.MousePointer = 11
    
    If comONLINE.PortOpen Then
        IsEnrollSuccess = False
        IsProcessFinished = False
        
        nRet = UBR_EraseTemplateObject(comONLINE, tmrTimeOut)
        Call Add2List(IIf(nRet, "Clearing buffer success ...", "Failed to clear buffer !!!"))
        
        Call cmdSetExternal2RAM_Click
        
        If nRet Then
            For nEnrollLoop = 0 To 2
                nRet = UBR_EnrollmentStart(comONLINE, tmrTimeOut)
                
                If Not nRet Then
                    Call Add2List("Failed to start enrollement !!!")
                End If
            
                If nRet And Not IsProcessFinished Then
                    Call Add2List("Enrollment phase " & Format(nEnrollLoop + 1, "00") & " ...")
                    
                    bContinue = True
                    bFlag2 = True
                    bFlag3 = True
                    
                    IsEnrollSuccess = False
                    While bContinue
                        iRet = UBR_EnrollmentGetResult(comONLINE, tmrTimeOut, byteTemplate)
                        
                        Select Case Chr(iRet)
                            Case "1"
                                For i = 0 To (400 - 1)
                                    byteStore(nEnrollLoop, i) = byteTemplate(i)
                                Next
                            
                                'Call Add2List("Enrollment is success ....")
                                
                                IsEnrollSuccess = True
                                bContinue = False
                                
                            Case "2", "3"
                                If Chr(iRet) = "2" Then
                                    If bFlag2 Then
                                        'Debug.Print "sRet=" & iRet & "/" & Chr(iRet)
                                        Call Add2List("Please your finger on the reader ....")
                                    End If
                                    bFlag2 = False
                                Else
                                    If bFlag3 Then
                                        'Debug.Print "sRet=" & iRet & "/" & Chr(iRet)
                                        Call Add2List("Capture finger and create pattern ...")
                                    End If
                                    bFlag3 = False
                                End If
                                
                            Case "9"
                                Call Add2List("Please try again !!!")
                                bContinue = False
                                IsProcessFinished = False
                                
                            Case "A"
                                Call Add2List("Please try again !!!")
                                bContinue = False
                                IsProcessFinished = False
                            
                            Case Else
                                bContinue = False
                                IsProcessFinished = False
                                
                        End Select
                    Wend
                    
                    If IsEnrollSuccess Then
                        nRet = UBR_StoreTemplate2Buffer(comONLINE, tmrTimeOut, nEnrollLoop, byteTemplate)
                        'Call Add2List("Store Template to buffer " & IIf(nRet, "success ...", "failure !!!"))
                        
                        If nRet Then
                            'Turn Green LED ON
                            nRet = UBR_LEDOnOff(comONLINE, tmrTimeOut, True)
                            nRet = UBR_LEDOnOff(comONLINE, tmrTimeOut, False)
                            Call DelayMSec(2500)
                        Else
                            Call Add2List("Error during enrollment and terminated !!!")
                            Exit For
                        End If
                    End If
                End If
                
                If IsProcessFinished Then
                    Exit For
                End If
            Next
            
            If IsEnrollSuccess And Not IsProcessFinished Then
                'OnDebugMode = True
                nRet = UBR_SelectOptimumTemplate(comONLINE, tmrTimeOut)
                ' Call Add2List("Select Optimum Template is " & IIf(nRet, "success ...", "failure !!!"))
                'OnDebugMode = False
                
                If nRet Then
                    nOptimumIndex = Reply(16)
                    If nOptimumIndex >= 0 And nOptimumIndex < 3 Then
                        
                        '--- Store selected optimum object template into byteTemplate
                        For i = 0 To (400 - 1)
                            byteTemplate(i) = byteStore(nOptimumIndex, i)
                        Next
                                                
                        Call Add2List("Template similarity checking ....")
                        
                        'Before saving the selected template,
                        'we have to check for template similarity
                        nRet = SimilarityCheck(byteTemplate)
                        If Not nRet Then
                            '--- Save selected optimum object template into FV internal RAM
                            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

⌨️ 快捷键说明

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