📄 frmsyncao.frm
字号:
Index = 10
Left = 1440
TabIndex = 29
Top = 890
Width = 1260
End
Begin VB.CheckBox chkSyncEnable
Caption = "Ch.9 Enable"
Enabled = 0 'False
Height = 195
Index = 9
Left = 1440
TabIndex = 28
Top = 600
Width = 1260
End
Begin VB.CheckBox chkSyncEnable
Caption = "Ch.0 Enable"
Enabled = 0 'False
Height = 195
Index = 0
Left = 165
TabIndex = 17
Top = 330
Width = 1260
End
Begin VB.CheckBox chkSyncEnable
Caption = "Ch.1 Enable"
Enabled = 0 'False
Height = 195
Index = 1
Left = 165
TabIndex = 16
Top = 610
Width = 1260
End
Begin VB.CheckBox chkSyncEnable
Caption = "Ch.2 Enable"
Enabled = 0 'False
Height = 195
Index = 2
Left = 165
TabIndex = 15
Top = 890
Width = 1260
End
Begin VB.CheckBox chkSyncEnable
Caption = "Ch.3 Enable"
Enabled = 0 'False
Height = 195
Index = 3
Left = 165
TabIndex = 14
Top = 1170
Width = 1260
End
Begin VB.CheckBox chkSyncEnable
Caption = "Ch.4 Enable"
Enabled = 0 'False
Height = 195
Index = 4
Left = 165
TabIndex = 13
Top = 1530
Width = 1260
End
Begin VB.CheckBox chkSyncEnable
Caption = "Ch.5 Enable"
Enabled = 0 'False
Height = 195
Index = 5
Left = 165
TabIndex = 12
Top = 1815
Width = 1260
End
Begin VB.CheckBox chkSyncEnable
Caption = "Ch.6 Enable"
Enabled = 0 'False
Height = 195
Index = 6
Left = 165
TabIndex = 11
Top = 2085
Width = 1260
End
Begin VB.CheckBox chkSyncEnable
Caption = "Ch.7 Enable"
Enabled = 0 'False
Height = 195
Index = 7
Left = 165
TabIndex = 10
Top = 2370
Width = 1260
End
End
Begin VB.CheckBox chkSyncAOEnable
Caption = "S&ynchronously AO Enable"
Height = 225
Left = 120
TabIndex = 8
Top = 360
Value = 1 'Checked
Width = 2475
End
End
Begin DAQAOLib.DAQAO DAQAO1
Height = 495
Left = 6840
TabIndex = 27
Top = 120
Width = 495
_Version = 65537
_ExtentX = 864
_ExtentY = 864
_StockProps = 0
End
Begin VB.CommandButton cmdExit
Caption = "&Close"
Height = 375
Left = 6360
TabIndex = 6
ToolTipText = "Close application"
Top = 720
Width = 1335
End
Begin VB.Frame Frame1
Caption = "Select Device :"
Height = 1185
Left = 120
TabIndex = 0
Top = 120
Width = 5895
Begin VB.CommandButton cmdSelectDevice
Caption = "&Select Device"
Default = -1 'True
Height = 375
Left = 4420
TabIndex = 3
ToolTipText = "Selecting device to operation"
Top = 240
Width = 1200
End
Begin VB.TextBox txtDeviceName
Height = 285
Left = 1320
TabIndex = 2
Text = "AdvanTech"
ToolTipText = "Device Name"
Top = 720
Width = 4305
End
Begin VB.TextBox txtDeviceNum
Height = 285
Left = 1320
TabIndex = 1
Text = "-100"
ToolTipText = "Device Number"
Top = 300
Width = 855
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "Device Name :"
Height = 195
Left = 120
TabIndex = 5
Top = 765
Width = 1065
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Device No. :"
Height = 195
Left = 120
TabIndex = 4
Top = 310
Width = 900
End
End
End
Attribute VB_Name = "frmSyncAo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub chkSyncAOEnable_Click()
If chkSyncAOEnable.Value = Checked Then
DAQAO1.SetSynchronous (True)
Else
DAQAO1.SetSynchronous (False)
End If
End Sub
Private Sub cmdExit_Click()
Unload Me
End
End Sub
Private Sub cmdOutputStart_Click()
'Open Device
If DAQAO1.OpenDevice Then
MsgBox DAQAO1.ErrorMessage, vbOKOnly
Exit Sub
End If
'Set Outputtype & initialize output value
If optVoltageOut.Value = True Then
gOutputValue(0) = 0#
gOutputValue(1) = 1.25
gOutputValue(2) = 2.5
gOutputValue(3) = 5#
DAQAO1.OutputType = adVoltage
End If
If optCurrentOut0.Value = True Then
gOutputValue(0) = 0#
gOutputValue(1) = 5#
gOutputValue(2) = 10#
gOutputValue(3) = 20#
DAQAO1.OutputType = adCurrent
End If
If optCurrentOut4.Value = True Then
gOutputValue(0) = 4#
gOutputValue(1) = 10#
gOutputValue(2) = 15#
gOutputValue(3) = 20#
DAQAO1.OutputType = adCurrent
End If
'Reset button state
cmdSelectDevice.Enabled = False
cmdOutputStart.Enabled = False
cmdOutputStop.Enabled = True
cmdExit.Enabled = False
'Enable ScanTimer
ScanTimer.Enabled = True
End Sub
Private Sub cmdOutputStop_Click()
'Disable ScanTimer
ScanTimer.Enabled = False
'Close Device
If DAQAO1.CloseDevice Then
MsgBox DAQAO1.ErrorMessage, vbOKOnly
Exit Sub
End If
cmdSelectDevice.Enabled = True
cmdOutputStart.Enabled = True
cmdOutputStop.Enabled = False
cmdExit.Enabled = True
End Sub
Private Sub cmdSelectDevice_Click()
Dim i As Integer
Dim j As Integer
Dim bRet As Boolean
DAQAO1.SelectDevice
txtDeviceNum.Text = DAQAO1.DeviceNumber
txtDeviceName.Text = DAQAO1.DeviceName
DAQAO1.DeviceNumber = DAQAO1.DeviceNumber
DAQAO1.DeviceName = DAQAO1.DeviceName
' Open device
If DAQAO1.OpenDevice Then
MsgBox DAQAO1.ErrorMessage, vbOKOnly
Exit Sub
End If
If DAQAO1.MaxChannel = 0 Then
MsgBox "Function Not Supported"
Unload Me
End
End If
'Initialize channel check box
For i = 0 To 31
If i < DAQAO1.MaxChannel Then
chkSyncEnable(i).Enabled = True
Else
chkSyncEnable(i).Enabled = False
End If
Next i
'Set SyncAo enable
DAQAO1.SetSynchronous (True)
'Close Device
If DAQAO1.CloseDevice Then
MsgBox DAQAO1.ErrorMessage, vbOKOnly
Exit Sub
End If
End Sub
Private Sub Form_Load()
' Select default device
Call cmdSelectDevice_Click
' Setting initial value
txtDeviceNum.Text = DAQAO1.DeviceNumber
txtDeviceName.Text = DAQAO1.DeviceName
End Sub
Private Sub Form_Unload(Cancel As Integer)
ScanTimer.Enabled = False
DAQAO1.CloseDevice
End Sub
Private Sub ScanTimer_Timer()
'Output value
For i = 0 To DAQAO1.MaxChannel - 1
If chkSyncEnable(i).Value = Checked Then
DAQAO1.Channel = i
If DAQAO1.RealOutput(gOutputValue(gIndex)) Then
MsgBox DAQAO1.ErrorMessage, vbOKOnly
Exit Sub
End If
End If
Next i
' Start SyncAO
If DAQAO1.SynchronousOutput Then
MsgBox DAQAO1.ErrorMessage, vbOKOnly
Exit Sub
End If
'Update text output value
txtOutputValue.Text = Str(gOutputValue(gIndex))
gIndex = gIndex + 1
If gIndex > 3 Then
gIndex = 0
End If
End Sub
Private Sub txtDeviceNum_Change()
DAQAO1.DeviceNumber = Val(txtDeviceNum.Text)
txtDeviceName.Text = DAQAO1.DeviceName
End Sub
Private Sub txtScanTime_Change()
ScanTimer.Interval = Val(txtScanTime.Text)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -