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

📄 frmmain.frm

📁 瑞立德门禁控制器VB源程 4门网络控制器 产品级源程
💻 FRM
📖 第 1 页 / 共 5 页
字号:
Private Sub cmdCloseDoor_Click()
    
    Dim intret As Integer
    Dim nDoorAddr As Byte
    
    nDoorAddr = CInt(Me.cmbDoorAddr3.Text)
    
    intret = M8_CloseDoor(nIP, nDoorAddr)
    
    If intret = -1 Then
        MsgBox "成功关闭"
    Else
        MsgBox "失败" & CStr(intret), vbCritical
    End If
  
End Sub

Private Sub cmdConnectServer_Click()
    
    Dim intret As Integer
    
    nIP = StrIPToIntIP(Me.txtCtrlIP.Text)
    
    intret = M8_ConnectToEventServer(nIP, nCommPwd)
    
    If intret = -1 Then
        MsgBox "连接成功"
        Me.Label2.Caption = "已连接"
    Else
        MsgBox "连接失败,返回值:" & CStr(intret), vbCritical, "Error!"
    End If
    
End Sub

Private Sub cmdDelAccessLevel_Click()
    
    Dim intret As Integer
    Dim nDoorAddr As Integer
    Dim intLevelID As Integer
    
    nDoorAddr = CInt(Me.cmbDoorAddr.Text)
    intLevelID = CInt(Me.txtLevelID.Text)
    
    intret = M8_DeletePurview(nIP, nDoorAddr, intLevelID)
    
    If intret <> -1 Then
        MsgBox "Fail, Return Code:" & CStr(intret), vbCritical, "Error!"
    Else
        MsgBox "成功"
    End If
    
End Sub

Private Sub cmdDelCard_Click()
    
    Dim intret As Integer
    
    intret = M8_DeleteCard(nIP, CLng(Me.txtCardNumber.Text))
    
    If intret <> -1 Then
        MsgBox "Fail, Return Code:" & CStr(intret), vbCritical, "Error!"
    Else
        MsgBox "成功"
    End If
    
End Sub

Private Sub cmdDeleteTimezone_Click()
    
    Dim intret As Integer
    
    intret = M8_DeleteTimePeriod(nIP, CInt(Me.txtTimezoneID.Text))
    
    If intret <> -1 Then
        MsgBox "Fail, Return Code:" & CStr(intret), vbCritical, "Error!"
    Else
        MsgBox "成功"
    End If

End Sub

Private Sub cmdGetAccessLevel_Click()
    
    Dim intret As Integer
    Dim pAccessLevel As TYPEACCESSLEVEL
    Dim nDoorAddr As Integer
    
    nDoorAddr = CInt(Me.cmbDoorAddr.Text)
    
    pAccessLevel.nLevelID = CInt(Me.txtLevelID.Text)
    
    intret = M8_GetPurview(nIP, nDoorAddr, pAccessLevel)
    
    If intret = -1 Then
        MsgBox "成功:" & pAccessLevel.nOperation
    Else
        MsgBox "失败" & CStr(intret)
    End If
    
End Sub

Private Sub cmdGetCard_Click()
    
    Dim intret As Integer
    Dim pCard As TYPECARD
    
    pCard.nNumber = CLng(Me.txtCardNumber.Text)
    intret = M8_GetCard(nIP, pCard)
    
    If intret <> -1 Then
        MsgBox "Fail: Return Code:" & CStr(intret), vbCritical, "Error!"
    Else
        Me.txtCardLevelID.Text = CStr(pCard.nAccessLevelID)
        Me.DTPicker1.Value = "20" & Format(pCard.nExpireYear, "00") & "-" & Format(pCard.nExpireMonth, "00") & "-" & Format(pCard.nExpireDay, "00")
        MsgBox "成功!"
    End If
    
End Sub

Private Sub cmdGetDoorCtrl_Click()
    Dim pDoorCtrl As TYPEDC
    Dim intret As Integer
    
    pDoorCtrl.nAddr = CInt(Me.cmbDoorAddr5.Text)
    intret = M8_GetDoorCtrl(nIP, pDoorCtrl)
    
    If intret = -1 Then
        MsgBox "成功获取" & CStr(pDoorCtrl.nAddr) & "号读卡器接口"
    Else
        MsgBox "获取读卡器接口失败,返回码:" & CStr(intret), vbCritical, "Error!"
    End If
    
End Sub

Private Sub cmdGetEvent_Click()
    
    Dim intret As Integer
    Dim tEvent(500) As CARDEVENT
    Dim intRealCount As Long
    
    intret = M8_GetEvents(nIP, tEvent(0), 500, intRealCount, GE_ALL)
    MsgBox intret & " RealCount:" & CStr(intRealCount)
    
    
End Sub

Private Sub cmdGetDoorStatus_Click()
    
    Dim intret As Integer
    Dim nDoorAddr As Byte
    Dim nDoorStatus As Long
    
    nDoorAddr = CInt(Me.cmbDoorAddr3.Text)
    
    intret = M8_IsOpen(nIP, nDoorAddr, nDoorStatus)
    
    If intret = -1 Then
        If nDoorStatus = 0 Then
            MsgBox "门现在的状态为关闭"
        Else
            MsgBox "门现在的状态为打开"
        End If
    Else
        MsgBox "失败" & CStr(intret), vbCritical
    End If
  
End Sub

Private Sub cmdGetEvents_Click()
    
    Dim i As Integer
    Dim intret As Integer
    Dim pEvents() As CARDEVENT
    
    Dim intCount As Long
    Dim intRealCount As Long
    
    intCount = CInt(Me.txtEventCount.Text)
    
    ReDim pEvents(CInt(Me.txtEventCount.Text))
    
    'If Label2.Caption <> "已连接" Then Exit Sub
    
    intret = M8_GetEventsFromBuf(nIP, pEvents(0), intCount, intRealCount)
    If intret <> -1 Then
        MsgBox "Fail to get events, code:" & CStr(intret), vbCritical, "Error!"
    Else
        Me.lbReceivedEvent.Caption = "收到" & CStr(intRealCount) & "条读卡记录"
    End If
    
    If intRealCount > 0 Then
        For i = 1 To intRealCount
            With Me.vsGrid
                .Rows = .Rows + 1
                .TextMatrix(.Rows - 1, 0) = CStr(i)
                .TextMatrix(.Rows - 1, 1) = cHexToDec(pEvents(i - 1).nCardNumber(3), pEvents(i - 1).nCardNumber(2), pEvents(i - 1).nCardNumber(1), pEvents(i - 1).nCardNumber(0))
                .TextMatrix(.Rows - 1, 2) = "20" & Format(CStr(pEvents(i - 1).nYear), "00") & "-" & Format(CStr(pEvents(i - 1).nMonth), "00") & "-" & Format(CStr(pEvents(i - 1).nDay), "00")
                .TextMatrix(.Rows - 1, 3) = Format(CStr(pEvents(i - 1).nHour), "00") & ":" & Format(CStr(pEvents(i - 1).nMinute), "00") & ":" & Format(CStr(pEvents(i - 1).nSec), "00")
                .TextMatrix(.Rows - 1, 4) = CStr(pEvents(i - 1).nDoorAddr)
                Select Case pEvents(i - 1).nEventType
                        Case ET_CARD
                        .TextMatrix(.Rows - 1, 5) = "刷卡,但没有开门"
                        Case ET_CARD_OPEN
                        .TextMatrix(.Rows - 1, 5) = "刷卡开门(门被用户推开)"
                        Case ET_INNER_OPEN
                        .TextMatrix(.Rows - 1, 5) = "内部(按钮)开门"
                        Case ET_ILLEGAL_OPEN
                        .TextMatrix(.Rows - 1, 5) = " 非法开门"
                        Case ET_INVALID_CARD
                        .TextMatrix(.Rows - 1, 5) = " 无效卡刷卡"
                        Case ET_DOOR_OPENED_TIMEOUT
                        .TextMatrix(.Rows - 1, 5) = " 门开超时报警"
                        Case ET_EVENT_SERVER_DISMANTLE
                        .TextMatrix(.Rows - 1, 5) = " 事件服务器被拆除"
                        Case ET_EVENT_SERVER_REVERT
                        .TextMatrix(.Rows - 1, 5) = " 事件服务器被还原"
                        Case ET_SENSOR1_ON
                        .TextMatrix(.Rows - 1, 5) = " 门1门磁打开"
                        Case ET_BUTTON1_ON
                        .TextMatrix(.Rows - 1, 5) = " 门1按钮打开"
                        Case ET_INPUT1_ON
                        .TextMatrix(.Rows - 1, 5) = " 辅助输入1打开"
                        Case ET_INPUT2_ON
                        .TextMatrix(.Rows - 1, 5) = " 辅助输入2打开"
                        Case ET_LOCK1_ON
                        .TextMatrix(.Rows - 1, 5) = " 门1电锁打开"
                        Case ET_LOCK1_ASSIST_ON
                        .TextMatrix(.Rows - 1, 5) = " 门1电锁辅助输出打开"
                        Case ET_TTL1_ON
                        .TextMatrix(.Rows - 1, 5) = " TTL辅助输出1打开"
                        Case ET_TTL2_ON
                        .TextMatrix(.Rows - 1, 5) = " TTL辅助输出2打开"
                        Case ET_TTL3_ON
                        .TextMatrix(.Rows - 1, 5) = " TTL辅助输出3打开"
                        Case ET_TTL4_ON
                        .TextMatrix(.Rows - 1, 5) = " TTL辅助输出4打开"
                        Case ET_DOOR_CTRL_FAIL
                        .TextMatrix(.Rows - 1, 5) = " 门控制器失效"
                        Case ET_DOOR_CTRL_DISMANTLE
                        .TextMatrix(.Rows - 1, 5) = " 门控制器被拆除"
                        Case ET_READER_DISMANTLE
                        .TextMatrix(.Rows - 1, 5) = " 读卡器被拆除"
                        Case ET_SUPER_PWD_OPEN
                        .TextMatrix(.Rows - 1, 5) = "超级密码开门"
                        Case ET_ENTER_CARD
                        .TextMatrix(.Rows - 1, 5) = " 门控制器进入安全(卡开门)状态"
                        Case ET_ENTER_DORMANCY
                        .TextMatrix(.Rows - 1, 5) = " 门控制器进入休眠状态"
                        Case ET_ENTER_CONST_OPEN
                        .TextMatrix(.Rows - 1, 5) = " 门控制器进入常开状态"
                        Case ET_ENTER_CARDnPWD
                        .TextMatrix(.Rows - 1, 5) = " 门控制器进入卡 + 密码状态"
                        Case ET_ENTER_CARD_APB
                        .TextMatrix(.Rows - 1, 5) = " 门控制器进入卡APB状态"
                        Case ET_ENTER_CARDnPWD_APB
                        .TextMatrix(.Rows - 1, 5) = " 门控制器进入卡 + 密码APB状态"
                        Case ET_SENSOR1_OFF
                        .TextMatrix(.Rows - 1, 5) = " 门1门磁关闭"
                        Case ET_BUTTON1_OFF
                        .TextMatrix(.Rows - 1, 5) = " 门1按钮关闭"
                        Case ET_INPUT1_OFF
                        .TextMatrix(.Rows - 1, 5) = " 辅助输入1关闭"
                        Case ET_INPUT2_OFF
                        .TextMatrix(.Rows - 1, 5) = " 辅助输入2关闭"
                        Case ET_LOCK1_OFF
                        .TextMatrix(.Rows - 1, 5) = " 门1电锁关闭"
                        Case ET_LOCK1_ASSIST_OFF
                        .TextMatrix(.Rows - 1, 5) = " 门1电锁辅助输出关闭"
                        Case ET_TTL1_OFF
                        .TextMatrix(.Rows - 1, 5) = " TTL辅助输出1关闭"
                        Case ET_TTL2_OFF
                        .TextMatrix(.Rows - 1, 5) = " TTL辅助输出2关闭"
                        Case ET_TTL3_OFF
                        .TextMatrix(.Rows - 1, 5) = " TTL辅助输出3关闭"
                        Case ET_TTL4_OFF
                        .TextMatrix(.Rows - 1, 5) = " TTL辅助输出4关闭"
                        Case Else
                        .TextMatrix(.Rows - 1, 5) = CStr(pEvents(i - 1).nEventType)
                End Select
            End With
        Next
    End If
    
    vsGrid.ShowCell vsGrid.Rows - 1, 0
    
    If Me.chkMovePointer.Value = 1 Then
        intret = M8_IncreaseEventCount(nIP, intRealCount)
        If intret <> -1 Then
            MsgBox "移动指针时错误", vbCritical, "Error!"
        End If
    End If
    
End Sub

Private Sub cmdGetEventServer_Click()
    Dim pEventServer As TYPECTRL
    
    pEventServer.nIP = nIP
    If M8_GetEventServer(pEventServer) = -1 Then
        MsgBox CStr(pEventServer.nCommPwd)
    End If
End Sub

Private Sub cmdGetTimezone_Click()
    
    Dim intret As Integer
    
    Dim pTimezone As TYPETIMEZONE
    Dim i As Integer
    
    pTimezone.nTZID = CInt(Me.txtTimezoneID.Text)
    
    intret = M8_GetTimePeriod(nIP, pTimezone)
    
    If intret <> -1 Then
        MsgBox "Fail, Return Code:" & CStr(intret), vbCritical, "Error!"
    Else
        Me.dtpStartTime.Value = ConvertTimeStr(pTimezone.StartTime)
        Me.dtpEndTime.Value = ConvertTimeStr(pTimezone.EndTime)
        
        For i = 0 To 6
            Me.chkWeekDay(i).Value = IIf((pTimezone.StartTime.nWeek And (2 ^ i)) >= 1, 1, 0)
        Next
        
        If (pTimezone.nTimeMask And 104) = 104 Then
            Me.chkCheckDay.Value = 1
        Else
            Me.chkCheckDay.Value = 0
        End If
        
        If (pTimezone.nTimeMask And 16) = 16 Then
            Me.chkCheckWeek.Value = 1
        Else
            Me.chkCheckWeek.Value = 0
        End If
        
        If (pTimezone.nTimeMask And 7) = 7 Then
            Me.chkCheckTime.Value = 1
        Else
            Me.chkCheckTime.Value = 0
        End If
        
        MsgBox "成功,TimezoneID:" & CStr(pTimezone.nTZID) & " Week:" & CStr(pTimezone.StartTime.nWeek) & " Timemask:" & CStr(pTimezone.nTimeMask)
    End If
    
End Sub

Private Sub cmdLockAssist_Click(Index As Integer)
    
    Dim intret As Integer
    Dim nDoorAddr As Byte
    Dim pIOAttr As TYPEIOATT
    
    nDoorAddr = CInt(Me.cmbDoorAddr3.Text)
    
    If Index = 0 Then
        ' 设置输出时间
        pIOAttr.nIONumber = 130
        pIOAttr.nNormal = 0
        ' 设置为0时为手动停止
        pIOAttr.nOutTime = CInt(Me.txtLATime.Text)
        
        intret = M8_SetIoAttribute(nIP, nDoorAddr, pIOAttr)
        
        If intret = -1 Then
            ' 输出辅助电锁输出,Output代码为2
            intret = M8_SetOutput(nIP, nDoorAddr, 2, 2)

⌨️ 快捷键说明

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