Logical devices – Measurement Computing ADLIB WIN User Manual

Page 19

Advertising
background image

Chapter 4 Application Development

4-3

Visual Basic for Windows Postmessage Handler Example

Global lpDataBuffStat As DATABUFFSTATUS
Global DataBuff(2048) As Integer
Global EngUnits(2048) As Single

Sub MsgBlaster1_Message (MsgVal As Integer, wParam As Integer, lParam As Long, ReturnVal As Long)

lBuffNum& = wParam

‘ Get the buffer status
errnum& = AL_GetBufferStatus(gblLhld&, lpDataBuffStat, DONE_BUFFER)
If errnum& < 0 Then End

' Check the status and error flags
If lpDataBuffStat.lStatusFlags <> BUFFER_FULL Then OnBufferError(lBuffNum&)
If lpDataBuffStat.lErrorFlags <> 0 Then OnBufferError(lBuffNum&)

errnum& = AL_CopyBuffer(gblLhld&, lBuffNum&, DataBuff(0), BufferStart, BufferEnd)
If errnum& < 0 Then End
errnum& = AL_DemuxDataSet(gblLhld&, lBuffNum&, EngUnits(0), BufferStart, BufferEnd)
If errnum& < 0 Then End
errnum& = AL_ClearBufferDoneFlag(gblLhld&, lBuffNum&)
If errnum& < 0 Then End

ReturnVal = 0

End Sub

4.3 LOGICAL DEVICES

The Interface Library defines a “Logical Device Subsystem” as being a software representation of a
functionally distinct subset of the hardware on a DAQ board. Each logical device deals with either Input or
Output data, but not both.

Typical Logical Devices on DAQ boards include:

ADC section (with N channels).

DAC section (with N channels).

Digital Input section.

Digital Output section.

Counter/Timers


You can also allocate multiple Logical Devices for the same piece of hardware. Since a logical device is a
“software representation” of a subsection of a board, you can have more than one representation of the same
subsection of a board. In other words, you can assign more than one logical device to the same piece of
hardware.

It might be convenient, for example, to assign more than one logical device to an ADC subsection on a
board. Each logical device could be configured entirely differently (for things like channel/gain, sample rate,
buffer size, etc.) and an application program could switch between the two devices. To do this, the app
would have to separately allocate the logical devices, and do the “set” functions to configure each device.
Then, the first device would be initialized and started. To switch to another logical device attached to the
same physical hardware, the app would stop the running device and initialize and start another.


Advertising