?? global.bas
字號(hào):
Attribute VB_Name = "Global"
'test descrption:
'Computer : Pentium II 266Hz
'Input Source : function generator
'this program can run PCI-1760 safely under 500Hz DI input in Windows NT
'but due to OS windows 95, this program only can run PCi-1760 safely under
'200 Hz DI input
'So if you want more high speed performance please use VC++ language to write
'you project or run this program under Windows NT OS
'Note:
'1.project property in compile item you must select compile to native code
'2.If you use VB We do not support Counter Overflow function and counter match only
'support to 32767
'
' Windows (Constant, Data structure, API) declaration
Public Const SYNCHRONIZE = &H100000
Public Const EVENT_ALL_ACCESS = &H1F0003
Public Const INFINITE = &HFFFFFFFF
Public Const WAIT_OBJECT_0 = &H0
Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Boolean
End Type
Declare Function OpenEvent Lib "kernel32" Alias "OpenEventA" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, lpName As Byte) As Long
Declare Function ResetEvent Lib "kernel32" (ByVal hHandle As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Declare Function CreateThread Lib "kernel32" (ByVal EventHandlingThread As Long, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal vbNullString As Long, EventThreadId As Long) As Long
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'Global bEventThreadRunning As Boolean
'Global bEventThreadTerminate As Boolean
'Global EventType As Integer
'Global ptCheckEvent As PT_CheckEvent
Sub EventHandlingThread()
Dim EventType As Integer
Dim ReturnValue As Integer
Dim ptCheckEvent As PT_CheckEvent
Dim ptFDITransfer As PT_FDITransfer
ptCheckEvent.EventType = DRV_GetAddress(EventType)
ptCheckEvent.Milliseconds = 1000
While bEventThreadRunning = True
bEventThreadTerminate = False
ErrorNum = DRV_CheckEvent(frmMain.DeviceHandle, ptCheckEvent)
If frmMain.CheckError(ErrorNum) <> 0 Then
ErrorNum = DRV_DeviceClose(frmMain.DeviceHandle)
Exit Sub
End If
' Check event
Select Case EventType
Case ADS_EVT_PATTERNMATCH ' Pattern Match Event
With frmMain
ptFDITransfer.EventType = ADS_EVT_PATTERNMATCH
ptFDITransfer.RetData = DRV_GetAddress(ReturnValue)
ErrorNum = DRV_FDITransfer(.DeviceHandle, ptFDITransfer)
If .CheckError(ErrorNum) Then
ErrorNum = DRV_DeviceClose(.DeviceHandle)
Exit Sub
End If
.PatternEventCount = .PatternEventCount + 1
.labPatternMatchCount.Caption = Str(.PatternEventCount)
End With
Case ADS_EVT_COUNTERMATCH
With frmMain
ptFDITransfer.EventType = ADS_EVT_COUNTERMATCH
ptFDITransfer.RetData = DRV_GetAddress(ReturnValue)
ErrorNum = DRV_FDITransfer(.DeviceHandle, ptFDITransfer)
If .CheckError(ErrorNum) Then
ErrorNum = DRV_DeviceClose(.DeviceHandle)
Exit Sub
End If
.CountMatchEventCount = .CountMatchEventCount + 1
.labMatchChannel.Caption = Str(ReturnValue)
.labMatchCount.Caption = Str(.CountMatchEventCount)
End With
Case ADS_EVT_COUNTEROVERFLOW
With frmMain
ptFDITransfer.EventType = ADS_EVT_COUNTEROVERFLOW
ptFDITransfer.RetData = DRV_GetAddress(ReturnValue)
ErrorNum = DRV_FDITransfer(.DeviceHandle, ptFDITransfer)
If .CheckError(ErrorNum) Then
ErrorNum = DRV_DeviceClose(.DeviceHandle)
Exit Sub
End If
.CountOverflowEventCount = .CountOverflowEventCount + 1
.labOverflowChannel.Caption = Str(ReturnValue)
.labOverflowCount.Caption = Str(.CountOverflowEventCount)
End With
Case ADS_EVT_STATUSCHANGE
With frmMain
ptFDITransfer.EventType = ADS_EVT_STATUSCHANGE
ptFDITransfer.RetData = DRV_GetAddress(ReturnValue)
ErrorNum = DRV_FDITransfer(.DeviceHandle, ptFDITransfer)
If .CheckError(ErrorNum) Then
ErrorNum = DRV_DeviceClose(.DeviceHandle)
Exit Sub
End If
If (ReturnValue And &HFF) Then
.FallingEventCount = .FallingEventCount + 1
.labStatus.Caption = "Falling"
.labChannelNo.Caption = Str(ReturnValue And &HFF)
.labStatusCount.Caption = Str(.FallingEventCount)
ElseIf (ReturnValue And &HFF00) Then
.RisingEventCount = .RisingEventCount + 1
.labStatus.Caption = "Rising"
'.labChannelNo.Caption = Str((ReturnValue And &HFF00) / &H100)
'.labStatusCount.Caption = Str(.RisingEventCount)
.labChannelNo.Caption = (ReturnValue And &HFF00) / &H100
.labStatusCount.Caption = .RisingEventCount
End If
End With
End Select
bEventThreadTerminate = True
Wend
End Sub
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -