712 Agilent InfiniiVision 5000 Series Oscilloscopes Programmer's Guide
12 Programming Examples
' enough time for the data acquisition process to collect data,
' and the results may not be accurate. An error value of 9.9E+37
' may be returned over the bus in this situation.
'
err = viVPrintf(vi, ":DIGITIZE CHAN1" + vbLf, 0)
End Sub
'
' Analyze
' -------------------------------------------------------------------
' In analyze, we will do the following:
' - Save the system setup to a file and restore it.
' - Save the waveform data to a file on the computer.
' - Make single channel measurements.
' - Save the oscilloscope display to a file that can be sent to a
' printer.
' -------------------------------------------------------------------
Private Sub Analyze()
' Set up arrays for multiple parameter query returning an array
' with viVScanf/viVQueryf. Set retCount to the maximum number
' of elements that the array can hold.
paramsArray(0) = VarPtr(retCount)
paramsArray(1) = VarPtr(byteArray(0))
' SAVE_SYSTEM_SETUP - The :SYSTEM:SETUP? query returns a program
' message that contains the current state of the instrument. Its
' format is a definite-length binary block, for example,
' #800002204<setup string><NL>
' where the setup string is 2204 bytes in length.
Dim lngSetupStringSize As Long
err = viVPrintf(vi, ":SYSTEM:SETUP?" + vbLf, 0)
retCount = ByteArraySize
' Unsigned integer bytes.
err = viVScanf(vi, "%#b\n" + vbLf, paramsArray(0))
lngSetupStringSize = retCount
' Output setup string to a file:
Dim strPath As String
Dim lngI As Long
strPath = "c:\scope\config\setup.dat"
Close #1 ' If #1 is open, close it.
' Open file for output.
Open strPath For Binary Access Write Lock Write As #1
For lngI = 0 To lngSetupStringSize - 1
Put #1, , byteArray(lngI) ' Write data.
Next lngI
Close #1 ' Close file.
' IMAGE_TRANSFER - In this example, we will query for the image data
' with ":DISPLAY:DATA?", read the data, and then save it to a file.
err = viVPrintf(vi, ":DISPLAY:DATA? BMP, SCREEN, COLOR" + vbLf, 0)
retCount = ByteArraySize