gain.frm
来自「16 relay output channels and 16 isolated」· FRM 代码 · 共 223 行
FRM
223 行
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form frmGainCdeSet
BorderStyle = 1 'Fixed Single
Caption = "Gain code setting for individual channel"
ClientHeight = 5130
ClientLeft = 3270
ClientTop = 2595
ClientWidth = 4380
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
PaletteMode = 1 'UseZOrder
ScaleHeight = 5130
ScaleWidth = 4380
Begin VB.CommandButton cmdExit
Caption = "&Exit"
Height = 375
Left = 3000
TabIndex = 3
Top = 480
Width = 1095
End
Begin ComctlLib.ListView lvGain
Height = 3975
Left = 240
TabIndex = 2
Top = 960
Width = 3855
_ExtentX = 6800
_ExtentY = 7011
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = 0 'False
_Version = 327682
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 3
BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Key = ""
Object.Tag = ""
Text = "Physical Chan"
Object.Width = 1464
EndProperty
BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Alignment = 2
SubItemIndex = 1
Key = ""
Object.Tag = ""
Text = "Gain"
Object.Width = 1411
EndProperty
BeginProperty ColumnHeader(3) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Alignment = 2
SubItemIndex = 2
Key = ""
Object.Tag = ""
Text = "Configuration"
Object.Width = 1764
EndProperty
End
Begin VB.ComboBox cmbGain
Height = 315
Left = 240
TabIndex = 0
Text = "cmbGain"
Top = 480
Width = 1575
End
Begin VB.Label Label1
Caption = "Gain"
Height = 255
Left = 240
TabIndex = 1
Top = 120
Width = 495
End
End
Attribute VB_Name = "frmGainCdeSet"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Response As Integer
Private Sub cmbGain_Click()
Dim i As Integer
Dim tempStr As String
'Store individual gain code setting
usGainIndex(lvGain.SelectedItem.Index - 1 + PhyChanToLogChan(lpDEVCONFIG_AI, Val(frmDevSel.CmbStartChan.Text))) = cmbGain.ListIndex
tempStr = ""
For i = 0 To 15
tempStr = tempStr + Chr(lpDevFeatures.glGainList(cmbGain.ListIndex).szGainStr(i))
Next i
lvGain.ListItems.Item(lvGain.SelectedItem.Index).SubItems(1) = tempStr
End Sub
Private Sub lvGain_Click()
cmbGain.Text = cmbGain.List(usGainIndex(lvGain.SelectedItem.Index - 1 _
+ PhyChanToLogChan(lpDEVCONFIG_AI, frmDevSel.CmbStartChan)))
End Sub
Private Sub cmdExit_Click()
Dim LogChan As Integer
LogChan = PhyChanToLogChan(lpDEVCONFIG_AI, Val(frmDevSel.CmbStartChan.Text))
For i = 0 To frmDevSel.CmbNumChan - 1
usGainCode(i + Val(frmDevSel.CmbStartChan)) = lpDevFeatures.glGainList(usGainIndex(i + LogChan)).usGainCde
Next i
Unload frmGainCdeSet
frmDevSel.Show
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim j As Integer
Dim ptDevFeature As PT_DeviceGetFeatures
Dim tempStr As String
Dim rStyle As Long
Dim R As Long
'Dim lstItem As ListItem
Dim iPhyChan As Integer 'Physical channel number
'Close device
DRV_DeviceClose (DeviceHandle)
'Open selected device for getting more informations
ErrCde = DRV_DeviceOpen(dwDeviceNum, DeviceHandle)
If (ErrCde <> 0) Then
DRV_GetErrorMessage ErrCde, szErrMsg
Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
Exit Sub
End If
ptAIGetConfig.buffer = DRV_GetAddress(lpDEVCONFIG_AI)
ErrCde = DRV_AIGetConfig(DeviceHandle, ptAIGetConfig)
If (ErrCde <> 0) Then
DRV_GetErrorMessage ErrCde, szErrMsg
Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
DRV_DeviceClose (DeviceHandle)
Exit Sub
End If
'Clear gain code combo box
cmbGain.Clear
'Set gain selection
For i = 0 To (lpDevFeatures.usNumGain - 1)
tempStr = ""
For j = 0 To 15
tempStr = tempStr + Chr(lpDevFeatures.glGainList(i).szGainStr(j))
Next j
cmbGain.AddItem tempStr
Next i
cmbGain.Text = cmbGain.List(0)
'get the current ListView style
rStyle = SendMessageLong(lvGain.hwnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0&, 0&)
rStyle = rStyle Or LVS_EX_GRIDLINES Or LVS_EX_FULLROWSELECT
'set the new ListView style
R = SendMessageLong(lvGain.hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0&, rStyle)
'Only show valid channels for selection
iPhyChan = Val(frmDevSel.CmbStartChan.Text)
For i = 0 To Val(frmDevSel.CmbNumChan.Text) - 1
' For cards that can not combine differential and single-ended
' If all channel are differential, lpDEVCONFIG_AI.ulChanConfig = 1
' If all channel are single-ended, lpDEVCONFIG_AI.ulChanConfig = 0
If (lpDEVCONFIG_AI.ulChanConfig = 1) Then
If iLogChan >= lpDevFeatures.usMaxAIDiffChl Then
Exit Sub
End If
Else
If iPhyChan >= lpDevFeatures.usMaxAISiglChl Then
Exit Sub
End If
End If
Set lstItem = lvGain.ListItems.Add(i + 1, , "Chan " & Str(iPhyChan))
tempStr = ""
For j = 0 To 15
tempStr = tempStr + Chr(lpDevFeatures.glGainList(usGainIndex(PhyChanToLogChan(lpDEVCONFIG_AI, iPhyChan))).szGainStr(j))
Next j
lstItem.SubItems(1) = tempStr
If (lpDEVCONFIG_AI.ulChanConfig = 1) Then
lstItem.SubItems(2) = "Differential"
lstItem.Text = "Chan " & Str(iPhyChan)
Else
If iPhyChan < 32 Then
If (lpDEVCONFIG_AI.ulChanConfig And SHL(1, iPhyChan)) Then
lstItem.SubItems(2) = "Differential"
If (iPhyChan Mod 2) = 0 Then
iPhyChan = iPhyChan + 1
End If
lstItem.Text = "Chan " & Str(iPhyChan - 1) & "," & Str(iPhyChan)
Else
lstItem.SubItems(2) = "Single-Ended"
End If
Else
If (lpDEVCONFIG_AI.ulChanConfigEx(0) And SHL(1, iPhyChan - 32)) Then
lstItem.SubItems(2) = "Differential"
If (iPhyChan Mod 2) = 0 Then
iPhyChan = iPhyChan + 1
End If
lstItem.Text = "Chan " & Str(iPhyChan - 1) & "," & Str(iPhyChan)
Else
lstItem.SubItems(2) = "Single-Ended"
End If
End If
End If
iPhyChan = iPhyChan + 1
Next i
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?