📄 frmaitester.frm
字号:
VERSION 5.00
Object = "{624EC978-8E3A-11D2-A9C9-002018650913}#1.1#0"; "Adain.ocx"
Begin VB.Form frmAITester
Caption = "ActiveDAQ AI Control Tester"
ClientHeight = 3240
ClientLeft = 3390
ClientTop = 1725
ClientWidth = 6645
LinkTopic = "Form1"
ScaleHeight = 3240
ScaleWidth = 6645
StartUpPosition = 2 'CenterScreen
Begin DAQAILib.DAQAI DAQAI1
Height = 495
Left = 5640
TabIndex = 22
Top = 240
Width = 495
_Version = 65537
_ExtentX = 864
_ExtentY = 864
_StockProps = 0
End
Begin VB.Frame Frame3
Caption = "Single Read"
Height = 1685
Left = 2880
TabIndex = 12
Top = 1395
Width = 3615
Begin VB.CommandButton cmdStop
Caption = "St&op"
Enabled = 0 'False
Height = 375
Left = 1560
TabIndex = 19
ToolTipText = "Stop Auto Scan"
Top = 1200
Width = 1095
End
Begin VB.CommandButton cmdStart
Caption = "St&art"
Height = 375
Left = 240
TabIndex = 18
ToolTipText = "Star Auto Scan"
Top = 1200
Width = 1095
End
Begin VB.TextBox txtScanTime
Alignment = 1 'Right Justify
Height = 285
Left = 1200
TabIndex = 16
Text = "1000"
ToolTipText = "Auto Scan time interval"
Top = 840
Width = 1095
End
Begin VB.Timer ScanTimer
Enabled = 0 'False
Interval = 1000
Left = 2880
Top = 960
End
Begin VB.CommandButton cmdRead
Caption = "&Read"
Height = 375
Left = 2520
TabIndex = 15
ToolTipText = "Single Read action"
Top = 315
Width = 855
End
Begin VB.TextBox txtReturnData
Alignment = 1 'Right Justify
Height = 285
Left = 1200
TabIndex = 13
Text = "xxxxxxxx"
ToolTipText = "Data Reading"
Top = 320
Width = 1095
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "Scan Time : mS"
Height = 195
Left = 240
TabIndex = 17
Top = 885
Width = 2385
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "Return Data :"
Height = 195
Left = 120
TabIndex = 14
Top = 375
Width = 1080
End
End
Begin VB.Frame Frame2
Caption = "Property Settings:"
Height = 1680
Left = 120
TabIndex = 7
Top = 1395
Width = 2635
Begin VB.ComboBox cmbChannel
Height = 315
ItemData = "frmAITester.frx":0000
Left = 1200
List = "frmAITester.frx":0034
TabIndex = 20
ToolTipText = "Device Data ype"
Top = 1215
Width = 1215
End
Begin VB.ComboBox cmbDataType
Height = 315
ItemData = "frmAITester.frx":006E
Left = 1200
List = "frmAITester.frx":0078
TabIndex = 10
ToolTipText = "Device Data ype"
Top = 795
Width = 1215
End
Begin VB.ComboBox cmbInputRange
Height = 315
Left = 1200
TabIndex = 8
ToolTipText = "Input voltage range"
Top = 360
Width = 1215
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "Channel :"
Height = 195
Left = 405
TabIndex = 21
Top = 1245
Width = 675
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "Data Type :"
Height = 195
Left = 240
TabIndex = 11
Top = 840
Width = 840
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "Input Range :"
Height = 195
Left = 120
TabIndex = 9
Top = 420
Width = 975
End
End
Begin VB.CommandButton cmdExit
Caption = "&Close"
Height = 375
Left = 5280
TabIndex = 6
ToolTipText = "Close application"
Top = 840
Width = 1215
End
Begin VB.Frame Frame1
Caption = "Select Device :"
Height = 1215
Left = 120
TabIndex = 0
Top = 120
Width = 4935
Begin VB.CommandButton cmdSelectDevice
Caption = "&Select Device"
Default = -1 'True
Height = 375
Left = 3240
TabIndex = 5
ToolTipText = "Selecting device to operation"
Top = 240
Width = 1455
End
Begin VB.TextBox txtDeviceName
Enabled = 0 'False
Height = 315
Left = 1320
TabIndex = 4
Text = "AdvanTech"
ToolTipText = "Device Name"
Top = 720
Width = 3345
End
Begin VB.TextBox txtDeviceNum
Height = 300
Left = 1320
TabIndex = 1
Text = "-100"
ToolTipText = "Device Number"
Top = 315
Width = 855
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "Device Name :"
Height = 195
Left = 120
TabIndex = 3
Top = 780
Width = 1185
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Device No. :"
Height = 195
Left = 120
TabIndex = 2
Top = 330
Width = 1140
End
End
End
Attribute VB_Name = "frmAITester"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim gInputRangeList(12) As String
Private Sub cmbDataType_Click()
DAQAI1.DataType = cmbDataType.ListIndex
End Sub
Private Sub cmbInputRange_Click()
gGainCode = cmbInputRange.ListIndex
DAQAI1.OverallInputRange = gGainCode
End Sub
Private Sub cmdExit_Click()
Unload Me
End
End Sub
Private Sub cmdRead_Click()
Dim bReading As Integer
Dim vReading As Single
Dim uChannel As Integer
If DAQAI1.OpenDevice Then
MsgBox DAQAI1.ErrorMessage, vbOKOnly
Exit Sub
End If
uChannel = cmbChannel.ListIndex
DAQAI1.OverallInputRange = cmbInputRange.ListIndex
Select Case (cmbDataType.ListIndex)
Case 0
bReading = DAQAI1.RawInput(uChannel)
txtReturnData.Text = Hex(bReading)
Case 1
vReading = DAQAI1.RealInput(uChannel)
txtReturnData.Text = vReading
End Select
DAQAI1.CloseDevice
End Sub
Private Sub cmdSelectDevice_Click()
Dim i As Integer
Dim j As Integer
Dim bRet As Boolean
DAQAI1.SelectDevice
txtDeviceNum.Text = DAQAI1.DeviceNumber
txtDeviceName.Text = DAQAI1.DeviceName
DAQAI1.DeviceNumber = DAQAI1.DeviceNumber
DAQAI1.DeviceName = DAQAI1.DeviceName
cmbInputRange.Clear
' Open Device
If DAQAI1.OpenDevice Then
MsgBox DAQAI1.ErrorMessage, vbOKOnly
Exit Sub
End If
' Get input range list
bRet = DAQAI1.GetInputRange(i, gInputRangeList)
For j = 0 To i - 1
cmbInputRange.AddItem gInputRangeList(j)
Next j
If i <> 0 Then
cmbInputRange.ListIndex = 0
End If
' Get Max. channel number
If DAQAI1.MaxDifferentialChannel > DAQAI1.MaxSingleEndedChannel Then
i = DAQAI1.MaxDifferentialChannel
Else
i = DAQAI1.MaxSingleEndedChannel
End If
If i = 0 Then
MsgBox "Function Not Supported", vbOKOnly
Unload Me
End
End If
cmbChannel.Clear
For j = 0 To i - 1
cmbChannel.AddItem (Str(j))
Next j
If i <> 0 Then
cmbChannel.ListIndex = 0
End If
DAQAI1.CloseDevice
End Sub
Private Sub cmdStart_Click()
If DAQAI1.OpenDevice Then
MsgBox DAQAI1.ErrorMessage, vbOKOnly
Exit Sub
End If
UIControl (False)
cmdSelectDevice.Enabled = False
DAQAI1.OverallInputRange = cmbInputRange.ListIndex
ScanTimer.Enabled = True
End Sub
Private Sub cmdStop_Click()
DAQAI1.CloseDevice
UIControl (True)
ScanTimer.Enabled = False
End Sub
Private Sub Form_Load()
Call cmdSelectDevice_Click
txtDeviceNum.Text = DAQAI1.DeviceNumber
txtDeviceName.Text = DAQAI1.DeviceName
cmbDataType.ListIndex = DAQAI1.DataType
End Sub
Private Sub Form_Unload(Cancel As Integer)
DAQAI1.CloseDevice
End Sub
Private Sub ScanTimer_Timer()
Dim bReading As Integer
Dim vReading As Single
Select Case (cmbDataType.ListIndex)
Case 0
bReading = DAQAI1.RawInput(cmbChannel.ListIndex)
txtReturnData.Text = Hex(bReading)
Case 1
vReading = DAQAI1.RealInput(cmbChannel.ListIndex)
txtReturnData.Text = vReading
End Select
End Sub
Private Sub txtDeviceNum_Change()
DAQAI1.DeviceNumber = Val(txtDeviceNum.Text)
txtDeviceName.Text = DAQAI1.DeviceName
End Sub
Private Sub txtScanTime_Change()
ScanTimer.Interval = Val(txtScanTime.Text)
End Sub
Private Sub UIControl(ByVal b_value As Boolean)
cmdExit.Enabled = b_value
cmdRead.Enabled = b_value
cmdStart.Enabled = b_value
cmdSelectDevice.Enabled = b_value
cmbInputRange.Enabled = b_value
cmbDataType.Enabled = b_value
cmbChannel.Enabled = b_value
cmdStop.Enabled = Not b_value
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -