frmstart.frm

来自「16 relay output channels and 16 isolated」· FRM 代码 · 共 552 行 · 第 1/2 页

FRM
552
字号
VERSION 5.00
Begin VB.Form frmDevSel 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Temperature Measurement Demo: Select  Device"
   ClientHeight    =   4590
   ClientLeft      =   4215
   ClientTop       =   2970
   ClientWidth     =   6510
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   8.25
      Charset         =   0
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H80000008&
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   4590
   ScaleWidth      =   6510
   Begin VB.ComboBox cmbBTEnable 
      Height          =   315
      Left            =   4320
      TabIndex        =   15
      Top             =   3360
      Width           =   1695
   End
   Begin VB.ListBox lstThermocouple 
      Height          =   840
      Left            =   4320
      TabIndex        =   11
      Top             =   1920
      Width           =   1695
   End
   Begin VB.ListBox lstExpChl 
      Height          =   1035
      Left            =   4320
      TabIndex        =   10
      Top             =   480
      Width           =   1695
   End
   Begin VB.ListBox lstVoltageRange 
      Height          =   1035
      Left            =   2040
      TabIndex        =   8
      Top             =   3240
      Width           =   1935
   End
   Begin VB.ListBox lstChannel 
      Height          =   1035
      Left            =   240
      TabIndex        =   5
      Top             =   3240
      Width           =   1455
   End
   Begin VB.ListBox lstModule 
      Enabled         =   0   'False
      Height          =   840
      Left            =   240
      TabIndex        =   4
      Top             =   1920
      Width           =   3735
   End
   Begin VB.CommandButton cmdExit 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "E&xit"
      Height          =   495
      Left            =   5280
      TabIndex        =   2
      Top             =   3840
      Width           =   1095
   End
   Begin VB.CommandButton cmdRun 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "&Run..."
      Height          =   495
      Left            =   4080
      TabIndex        =   1
      Top             =   3840
      Width           =   1095
   End
   Begin VB.ListBox lstDevice 
      Height          =   1035
      Left            =   240
      TabIndex        =   0
      Top             =   480
      Width           =   3735
   End
   Begin VB.Label Label1 
      Caption         =   "Burn Test Enable"
      Height          =   255
      Left            =   4320
      TabIndex        =   14
      Top             =   3000
      Width           =   1695
   End
   Begin VB.Label labModule 
      Caption         =   "Select a Module"
      Height          =   255
      Left            =   480
      TabIndex        =   13
      Top             =   1680
      Width           =   3375
   End
   Begin VB.Label labThermocouple 
      Caption         =   "Thermocouple Type"
      Height          =   255
      Left            =   4320
      TabIndex        =   12
      Top             =   1680
      Width           =   1815
   End
   Begin VB.Label labExpChl 
      Alignment       =   1  'Right Justify
      Caption         =   "Exp. card channel"
      Height          =   255
      Left            =   4320
      TabIndex        =   9
      Top             =   240
      Width           =   1575
   End
   Begin VB.Label labVoltageRange 
      Caption         =   "DAS Card Voltage Range"
      Height          =   255
      Left            =   2040
      TabIndex        =   7
      Top             =   3000
      Width           =   2175
   End
   Begin VB.Label labChannel 
      Alignment       =   1  'Right Justify
      Caption         =   "DAS card channel"
      Height          =   255
      Left            =   240
      TabIndex        =   6
      Top             =   3000
      Width           =   1575
   End
   Begin VB.Label labDevLst 
      Caption         =   "Select a device from list"
      Height          =   255
      Index           =   0
      Left            =   480
      TabIndex        =   3
      Top             =   240
      Width           =   3375
   End
End
Attribute VB_Name = "frmDevSel"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim gnNumOfSubdevices As Integer
Dim lpAIGetConfig As DEVCONFIG_AI
Dim tempStr As String
Dim bRun As Boolean
Function TestStr(SStr As String, TStr As String) As Boolean
  Dim lenS, lenT As Integer
  Dim I As Integer

  TestStr = False
  lenS = Len(SStr)
  lenT = Len(TStr)

  ' if source string is empty, return true
  If SStr = "" Then
    TestStr = True
    Exit Function
  End If

  ' if it find a target string in source string, return true
  For I = 1 To (lenS - lenT + 1)
    If (Mid(SStr, I, lenT) = TStr) Then
      TestStr = True
    End If
  Next I
End Function

Private Sub cmdExit_Click()
  ErrCde = DRV_DeviceClose(DeviceHandle)
  If bRun Then
    If (ErrCde <> 0) Then
      DRV_GetErrorMessage ErrCde, szErrMsg
      Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
    End If
  End If
  End
End Sub

Private Sub cmdRun_Click()
  Dim tempNum As Integer
  Dim BoardID As Integer
  Dim Length As Long
  
 
  ptTCMuxRead.DasChan = lstChannel.ListIndex
  
   If (BurnOutSupport = True) Then
      BurnOutProperty(ptTCMuxRead.DasChan) = cmbBTEnable.ListIndex
      Length = 4 * MaxAIChl
      ErrCde = DRV_DeviceSetProperty(DeviceHandle, CFG_BURNTEST, BurnOutProperty(0), Length)
      If (ErrCde <> 0) Then
          DRV_GetErrorMessage ErrCde, szErrMsg
          Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
          Exit Sub
      End If
   End If
  ' Gain code no use for ADAM series
  BoardID = lpAIGetConfig.Daughter(lstChannel.ListIndex).dwBoardID
  If gnNumOfSubdevices = 0 Then
       If BoardID > 0 And BoardID <> BD_PCLD8710 Then
          ptTCMuxRead.DasGain = 0
          ptTCMuxRead.ExpChan = lstExpChl.ListIndex
       Else
          tempNum = lstVoltageRange.ListIndex
          ptTCMuxRead.DasGain = lpDevFeatures.glGainList(tempNum).usGainCde
          ptTCMuxRead.ExpChan = 0
       End If
  End If

  ptTCMuxRead.TCType = lstThermocouple.ListIndex

  frmRun.Show
  frmRun.tmrRead.Enabled = True
  frmRun.cmdRead.SetFocus
  frmDevSel.Hide
End Sub

Private Sub Form_Load()
  Dim gnNumOfDevices As Integer
  Dim nOutEntries As Integer
  Dim I, j As Integer
  Dim lpDeviceList As Long

  ' initialize the device open/close flag
  bRun = False

  ErrCde = DRV_DeviceGetNumOfList(gnNumOfDevices)
  If (ErrCde <> 0) Then
    DRV_GetErrorMessage ErrCde, szErrMsg
    Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
    Exit Sub
  End If

  If (gnNumOfDevices > MaxDev) Then
    gnNumOfDevices = MaxDev
  End If

  ' retrieve the information of all installed devices
  lpDeviceList = DRV_GetAddress(devicelist(0))
  ErrCde = DRV_DeviceGetList(lpDeviceList, MaxEntries, nOutEntries)
  If (ErrCde <> 0) Then
    DRV_GetErrorMessage ErrCde, szErrMsg
    Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
    Exit Sub
  End If

  ' Display a list of device name
  For I = 0 To (gnNumOfDevices - 1)
    tempStr = ""
    For j = 0 To MaxDevNameLen
      tempStr = tempStr + Chr(devicelist(I).szDeviceName(j))
    Next j
      lstDevice.AddItem tempStr
  Next I


  If (gnNumOfDevices > MaxDev) Then
    gnNumOfDevices = MaxDev
  End If

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?