Measurement-computing Personal Daq rev.6.0 Uživatelský manuál Strana 133

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 170
  • Tabulka s obsahem
  • ŘEŠENÍ PROBLÉMŮ
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 132
Personal Daq User’s Manual Appendix B, 887095 API Commands B-1
API Commands B
Overview
This appendix includes information regarding type-sensitive API function wrappers for Visual Basic,
Personal Daq driver commands for Windows
TM
in 32-bit mode, parameter definitions such as A/D
channels, event-handling, hardware, A/D gain, general I/O, digital I/O port connection (page B-29), and
API error codes (page B-33).
Type-Sensitive API Function Wrappers for Visual Basic
Each API function has a wrapper serving as an interface between the Visual Basic program and the actual
API function calls. API function prototypes (made available by
PDAQX.DLL) are declared in the header
file (
PDAQX.BAS) as follows:
Declare Function BdaqAdcTransferSetBuffer& Lib "pdaqx.dll" Alias _
"daqAdcTransferSetBuffer" (ByVal handle&, buf As Any, ByVal ScanCount&, _
ByVal transferMask&)
Ideally, any application written in Visual Basic should call the function above by using the function
wrapper,
VbdaqAdcTransferSetBuffer, rather than calling the API function directly via
BdaqAdcTransferSetBuffer. The standard wrapper for this function is:
Function VBdaqAdcTransferSetBuffer&(ByVal handle&, buf%(), ByVal ScanCount&,
ByVal transferMask&)
Dim lb1&
lb1& = LBound(buf%)
daqErrno& = BdaqAdcTransferSetBuffer&(handle&, buf%(lb1&), ScanCount&,
transferMask&)
If ((daqErrno& <> 0) And (daqErrnum& <> 0)) Then Error daqErrnum&
VBdaqAdcTransferSetBuffer& = daqErrno&
End Function
For Visual Basic versions preceding 5.0, proper error handling is made possible with the use of wrappers.
In cases where API functions return structured information, the function wrappers assist in presenting that
information to the programmer. For
VBdaqGetDeviceList the information in the byte array (returned by
the DLL) is transferred to a standard VB string array that is easier to work with on the programming end.
It is important to note that while every API function supported in Visual Basic has at least one associated
wrapper, the API functions that include buffer references have two different associated wrappers
(dependent on the buffer’s data type). For example, consider the
daqAdcTransferSetBuffer function.
The prototype has a buffer parameter declared as type
Any (see previous wrapper code). Data acquisition
buffers can contain either integers (16-bit numbers), or single-precision floating-point numbers (Single
data type).
VBdaqAdcTransferSetBuffer - would be used to call the daqAdcTransferSetBuffer function with a
buffer containing integers.
VBdaqAdcTransferSetBufferSingle - would be used for a buffer containing single-precision
floating-point numbers.
The only difference between the
VBdaqAdcTransferSetBuffer and VBdaqAdcTransferSetBufferSingle
functions is that the
buf parameters consist of different data types for each wrapper.
The following table lists buffer-related API functions and associated wrappers.
API Function Integer Wrapper Floating-Point Wrapper
BdaqAdcTransferSetBuffer VBdaqAdcTransferSetBuffer VBdaqAdcTransferSetBufferSingle
BdaqAdcTransferBufData VBdaqAdcTransferBufData VBdaqAdcTransferBufDataSingle
BdaqAdcRdScan VBdaqAdcRdScan VBdaqAdcRdScanSingle
BdaqAdcRdN VBdaqAdcRdN VBdaqAdcRdNSingle
BdaqAdcRdScanN VBdaqAdcRdScanN VBdaqAdcRdScanNSingle
BdaqAdcGetBufData VBdaqAdcGetBufData VBdaqAdcGetBufDataSingle
BdaqAdcRd VBdaqAdcRd VBdaqAdcRdSingle
BdaqCvtRawDataFormat VBdaqCvtRawDataFormat VBdaqCvtRawDataFormatSingle
Zobrazit stránku 132
1 2 ... 128 129 130 131 132 133 134 135 136 137 138 ... 169 170

Komentáře k této Příručce

Žádné komentáře