75 lines
1.8 KiB
VB.net
75 lines
1.8 KiB
VB.net
|
|
Module Module1
|
|
|
|
Dim hDevice As Integer
|
|
Dim hEventInt As Integer
|
|
Dim DeviceID As Int32
|
|
Dim iChannel As Int32
|
|
Dim bDISts(0 To 15) As Byte
|
|
Dim bDOSts(0 To 15) As Byte
|
|
Dim Flag As Int32
|
|
|
|
Dim key As IntPtr
|
|
|
|
|
|
Sub Main()
|
|
|
|
DeviceID = 0
|
|
|
|
hDevice = PCI2312_CreateDevice(DeviceID)
|
|
If (hDevice = INVALID_HANDLE_VALUE) Then
|
|
Console.WriteLine("CreateDevice Error...")
|
|
_getch()
|
|
Return
|
|
End If
|
|
For iChannel = 0 To 15
|
|
If iChannel Mod 2 = 0 Then
|
|
bDOSts(iChannel) = 0 ' 偶数通道赋为低电平"0"
|
|
Else
|
|
bDOSts(iChannel) = 1 '奇数通道赋为高电平"1"
|
|
End If
|
|
Next
|
|
|
|
|
|
Repeat:
|
|
|
|
Console.WriteLine("Press any key to set DO")
|
|
_getch()
|
|
For iChannel = 0 To 15
|
|
Console.WriteLine("bDOSts[{0}] = {1}", iChannel, bDOSts(iChannel))
|
|
|
|
Next
|
|
|
|
If (PCI2312_SetDeviceDO(hDevice, bDOSts) = False) Then ' 开关量输出
|
|
Console.WriteLine("SetDeviceDO Error...")
|
|
_getch()
|
|
GoTo Exit1
|
|
End If
|
|
|
|
Console.WriteLine("")
|
|
Console.WriteLine("Press any key to get DI")
|
|
_getch()
|
|
|
|
If (PCI2312_GetDeviceDI(hDevice, bDISts) = False) Then ' DI Input
|
|
Console.WriteLine("GetDeviceDI Error")
|
|
_getch()
|
|
GoTo Exit1
|
|
End If
|
|
For iChannel = 0 To 15
|
|
Console.Write("bDISts[{0}] = {1}", iChannel, bDISts(iChannel))
|
|
Console.WriteLine("")
|
|
Next
|
|
Console.WriteLine("Press ESC to quit")
|
|
key = _getch()
|
|
If (key <> 27) Then
|
|
GoTo Repeat
|
|
End If
|
|
|
|
|
|
Exit1:
|
|
PCI2312_ReleaseDevice(hDevice)
|
|
Return
|
|
|
|
End Sub
|
|
|
|
End Module |