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

📄 form1.frm

📁 M8演示程序
💻 FRM
📖 第 1 页 / 共 5 页
字号:
        Linedata(Linenumber) = TagIDnum(Linenumber) & "=" & FileName(Linenumber)
        
        'then put it into the file *.dem
        Call ReadDemoFile    ' sets the value of demoFile$
        
        demoFile$ = demoFile$ & Linedata(Linenumber)
        Open demoFileName$ For Output As #1
        Print #1, demoFile$
        Close #1
        ' then put it onto the display
        Image1.Picture = LoadPicture(CommonDialog1.FileName)
        
        Exit Sub
        
    End If
    
ErrHandler:
        ' User pressed Cancel button.
    Close #1
    Exit Sub
    
    
End Sub


Private Sub btn_Unlink_Click()
    ' remove from File
    ' remove from RAM
    ' Remove  Graphic
    
    If demoLoadedF = False Then
        result = MsgBox("No Demo Loaded", vbOKOnly, "SkyeWare Message")
        Exit Sub
    End If
    
    If Len(textbox_TagID.Text) < 16 Then
        result = MsgBox("Invalid Tag ID", vbOKOnly, "SkyeWare Message")
    Else
    
        ' check to see if this tag id is already registered:
        While Linenumber < 16
            If TagIDnum(Linenumber) = Mid$(textbox_TagID.Text, 1, 16) Then
                ' remove association here
                ' remove a single line from the file demoFileName$
                Open demoFileName$ For Output As #1
                For X = 1 To Linenumber - 1
                    Print #1, Linedata(X) ' write into file
                Next
                'skip here writing the eliminated line   Linedata(Linenumber)
                For X = Linenumber + 1 To 16
                    If Linedata(X) = "" Then
                        
                        Linedata(X - 1) = "" ' updates last entry of Linedata
                        TagIDnum(X - 1) = ""
                        FileName(X - 1) = ""
                        
                        Exit For
                    End If
                    Print #1, Linedata(X)
                    Linedata(X - 1) = Linedata(X) ' move up all the entries after Linedata(Linenumber) was removed
                    TagIDnum(X - 1) = TagIDnum(X)
                    FileName(X - 1) = FileName(X)
                    
                Next
                Close #1
                
                ' then remove the entry from the array in RAM
                
                
                ' then give message that the picture has been removed
                result = MsgBox("Removed", vbOKOnly, "SkyeWare Message")
                
                ' then remove the picture from the display
                Image1.Picture = LoadPicture
                
                Exit Sub
            End If
            Linenumber = Linenumber + 1
        Wend
        result = MsgBox("Fail", vbOKOnly, "SkyeWare Message")
    End If
End Sub

Private Sub checkbox_anticollision_Click()
    
    If checkbox_anticollision.Value = 1 Then
        frame_anticollision.Visible = True
        'frame_TagData.Visible = False
        textbox_Read.Enabled = False
        textbox_Write.Enabled = False
        btn_Read.Enabled = False
        btn_Write.Enabled = False
        textbox_TagID.Enabled = False
        'checkbox_ReadContinuous.Enabled = False
    Else
        frame_anticollision.Visible = False
        'frame_TagData.Visible = True
        
        If uhfF <> True Then
            textbox_Read.Enabled = True
            textbox_Write.Enabled = True
            btn_Read.Enabled = True
            btn_Write.Enabled = True
        End If
        
        textbox_TagID.Enabled = True
        'checkbox_ReadContinuous.Enabled = True
End If
    
End Sub

Private Sub btn_ClearList_Click()
    textbox_TagIDList.Text = ""
End Sub

Private Sub btn_GetTagID_Click()
    
    Dim Linenumber As Integer
    Dim result$
    
    If uhfF <> True Then
        textbox_Read.Text = ""
    End If
    
    textbox_TagID.Text = ""
    textbox_TagIDList.Text = ""
    
    getTIDFlag = False
    
    If MSComm1.PortOpen = False Then
    ' this code is for demo operation - no reader is connected here
    
        ' every time the user clicks on "Get Tag ID" button then the next tag id in the demo file gets displayed
            
            If checkbox_anticollision.Value = 1 Then
                ' display these tags as samples because no reader is connected here
                textbox_TagIDList.Text = "E0070000016AA145   Tag-It HF-I" & vbCrLf
                textbox_TagIDList.Text = textbox_TagIDList.Text & "60050000034EE859   my-d SRF55V10P" & vbCrLf
                textbox_TagIDList.Text = textbox_TagIDList.Text & "E004010000700322   ICode SLI" & vbCrLf
                textbox_TagIDList.Text = textbox_TagIDList.Text & "E006000000011A4C   STM LRI512" & vbCrLf
            Else
                ' display the next tag id in the demo file list
                Call ReadDemoFile
                ' search through the list of registered tag id numbers and display picture if match
                'display the picture if there is one associated
                
                If tagidIndex = 15 Then
                    'there are maximum 15 pictures allowed in the demo file.
                    ' After picture number 15, go back to the first picture on line 2
                    tagidIndex = 2
                End If
                If TagIDnum(tagidIndex) = "" Then
                    Set Image1.Picture = LoadPicture() ' clear the picture
                    tagidIndex = 2
                End If
                'Image1.AutoSize = True
                Set Image1.Picture = LoadPicture(FileName(tagidIndex))
                textbox_TagID.Text = TagIDnum(tagidIndex)
                tagidIndex = tagidIndex + 1
            End If
            Exit Sub
    End If
    
    
    If uhfF = True Then
        checkbox_anticollision.Enabled = False 'uhf reader doesn't support anticollision mode
    End If
    
    MSComm1.RThreshold = 0  ' disable OnComm
    MSComm1.InBufferCount = 0 ' clear the rx buffer in case a tag id was coming through just as we get here
    
    If checkbox_tagidcontinuous.Enabled = False Then
        ' because this checkbox was disabled, that means we were already in Loop Mode
        
        If MSComm1.PortOpen = True Then
            MSComm1.Output = vbCr   ' send a command (single byte) to end loop mode
        End If
        
        If GetResponse() = True Then
            ' get the "Exit Loop Mode" response "9C"
            If Response$ = vrLf & "9C" & vbCrLf Then
                ' 9C was received as expected.
                Test_Break = 0
            Else
                Test_Break = 0
            End If
        Else
            Test_Break = 0
        End If
        
        If uhfF <> True Then
            checkbox_anticollision.Enabled = True
        End If
        
        checkbox_tagidcontinuous.Enabled = True
        'checkbox_Select.Enabled = True
        
        If uhfF <> True Then
            btn_Read.Enabled = True
            btn_Write.Enabled = True
            textbox_Write.Enabled = True
        End If
        'checkbox_ReadContinuous.Enabled = True

        Call setStatus("Waiting for Command")
        Exit Sub
    End If
    
    If checkbox_anticollision.Value = 1 And checkbox_tagidcontinuous.Value = 1 Then
        flags$ = "0B"
        checkbox_anticollision.Enabled = False
        checkbox_tagidcontinuous.Enabled = False
        'checkbox_Select.Enabled = False
        btn_Read.Enabled = False
        btn_Write.Enabled = False
        textbox_Write.Enabled = False
        'checkbox_ReadContinuous.Enabled = False

        
        If MSComm1.PortOpen = True Then
            MSComm1.Output = vbCr & flags$ & "1400" & vbCr  ' send the AUTO-detect select tag command
        End If


        If GetResponse() = True Then
        ' first we expect the "enter loop mode" response form the reader
            If Response$ = vbLf & "1C" & vbCrLf Then
                ' 1C was received as expected.
                MSComm1.RThreshold = 1  'Now enable OnComm to handle Loop Mode
            Else
                Test_Break = 0
            End If
        Else
            Test_Break = 0
        End If
        
        Call setStatus("Scanning for Multiple Tags/Labels")
        
    ElseIf checkbox_anticollision.Value = 1 And checkbox_tagidcontinuous.Value = 0 Then
        flags$ = "0A"
        ' scan for multiple tag one time
        ' use OnComm
        btn_Read.Enabled = False
        btn_Write.Enabled = False
        textbox_Write.Enabled = False
        'checkbox_ReadContinuous.Enabled = False

        MSComm1.InBufferCount = 0 ' clear the rx buffer
        MSComm1.RThreshold = 1  ' enable OnComm
        If MSComm1.PortOpen = True Then
            MSComm1.Output = vbCr & flags$ & "1400" & vbCr  ' send the AUTO-detect select tag command
        End If
        Call setStatus("Scanning for Multiple Tags/Labels")


    ElseIf checkbox_anticollision.Value = 0 And checkbox_tagidcontinuous.Value = 1 Then
        flags$ = "09"
        checkbox_anticollision.Enabled = False
        checkbox_tagidcontinuous.Enabled = False
        'checkbox_Select.Enabled = False
        btn_Read.Enabled = False
        btn_Write.Enabled = False
        textbox_Write.Enabled = False
        'checkbox_ReadContinuous.Enabled = False

        MSComm1.InBufferCount = 0 ' clear the rx buffer
        MSComm1.RThreshold = 1  ' enable OnComm
        If MSComm1.PortOpen = True Then
            MSComm1.Output = vbCr & flags$ & "1400" & vbCr  ' send the AUTO-detect select tag command
        End If
        
        Call setStatus("Scanning for a Tag/Label")

    Else
        ' in this case the com port can be polled instead of using OnComm
        getTIDFlag = True
        flags$ = "08"
        MSComm1.InBufferCount = 0 ' clear the rx buffer
        MSComm1.RThreshold = 0  ' disable OnComm
        If MSComm1.PortOpen = True Then
            MSComm1.Output = vbCr & flags$ & "1400" & vbCr  ' send the AUTO-detect select tag command
        End If
        
        If GetResponse() = True Then
            ' returns 94 fail, or else a tag id response
            If Response$ = vbLf & "94" & vbCrLf Then
                textbox_TagID.Text = ""
                Set Image1.Picture = LoadPicture
                Call setStatus("No Tag Detected")
                Call setStatus("Waiting for Command")
            Else
                If protocolv2 = True Then
                    TagID$ = Mid$(Response$, 4, 18)
                Else
                    TagID$ = Mid$(Response$, 4, 16)
                End If
                Call DetermineTagType  ' generates proper text string for tagtype$
                textbox_TagID.Text = TagID$ & TagType$
            End If
        Else
            textbox_TagID.Text = ""
            Set Image1.Picture = LoadPicture
            Call setStatus("No Tag Detected")
            Call setStatus("Waiting for Command")
        End If
    
    End If
    
    If checkbox_anticollision.Value = 0 And checkbox_tagidcontinuous.Value = 0 Then
        'display the picture if there is one associated
    
        For Linenumber = 2 To 15
            If Mid$(textbox_TagID.Text, 1, 16) = TagIDnum(Linenumber) Then
                'Image1.AutoSize = True
                Set Image1.Picture = LoadPicture(FileName(Linenumber))
                Exit Sub
            End If
        Next
    
        Set Image1.Picture = LoadPicture
    End If
    
End Sub
Private Sub setStartingBlock()
    
    If Mid$(TagID$, 3, 2) = "04" Then
        ' ICode SLI
        StartingBlock = 0
        TagBlockLength = 4
        MaxBLock = 32
    ElseIf Mid$(TagID$, 3, 2) = "07" Then
        ' Tag-It HF-I
        StartingBlock = 0
        TagBlockLength = 4
        MaxBLock = 64
    ElseIf Mid$(TagID$, 3, 2) = "05" Then
        ' my-d
        StartingBlock = 3
        TagBlockLength = 8
        If Mid$(TagID$, 5, 2) = "40" Then
            ' SRF55V02P
            MaxBLock = 32
        ElseIf Mid$(TagID$, 5, 2) = "00" Then
            ' SRF55V10P
            MaxBLock = 128
        End If
    ElseIf Mid$(TagID$, 3, 2) = "06" Then
        ' LRI512
        StartingBlock = 3
        TagBlockLength = 4
        MaxBLock = 16
    End If
    
End Sub

Private Sub btn_Write_Click()
    Dim bytesWritten As Integer
    Dim numTries As Integer
    
    ' WRITE TAG COMMAND:   <STX><FLAGS><COMMAND><TAG_TYPE><TID><STARTING_BLOCK><NUMBER_OF_BLOCKS><DATA><CRC>
    
    ' select a tag and then check its Tag ID for what kind of Tag Type
    ' use setStartingBlock() to determine how much data the tag will hold
    ' then test to see if the ammount of text in textbox_Write will fit on the tag
    ' then write data from textbox_write one block at a time (4 or 8 bytes per block, depending on the tag type)
    ' stop writing when you encounter the first non-displayable ASCII char (but make sure that the non-displayable
    ' character gets written to the tag so that btn_Read_Click() knows when to stop reading the data.
    
    textbox_TagID.Text = ""
    
    If MSComm1.PortOpen = False Then
        Exit Sub
    End If
    
    flags$ = "08"   ' set the RF_F
    MSComm1.Output = vbCr & flags$ & "1400" & vbCr  ' send the AUTO-DETECT SELECT_TAG command
        
    If GetResponse() = True Then
        
        If Mid(Response$, 2, 2) = "94" Then
            Call setStatus("No Tag Detected")
            Call setStatus("Waiting for Command")
            Exit Sub

⌨️ 快捷键说明

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