Programming Examples 12
Agilent InfiniiVision 5000 Series Oscilloscopes Programmer's Guide 741
' Get the result string.
Dim fResultsArray As Double()
fResultsArray = VisaGetResultValues()
' Check for instrument errors (another command and result).
CheckForInstrumentErrors(strQuery)
' Return string results.
Return fResultsArray
End Function
Public Function DoQueryIEEEBlock(ByVal strQuery As String, _
ByRef ResultsArray As Byte()) As Integer
' Send the query.
VisaSendCommandOrQuery(strQuery)
' Get the result string.
Dim length As Integer
' Number of bytes returned from instrument.
length = VisaGetResultIEEEBlock(ResultsArray)
' Check for instrument errors (another command and result).
CheckForInstrumentErrors(strQuery)
' Return string results.
Return length
End Function
Private Sub CheckForInstrumentErrors(ByVal strCommand As String)
' Check for instrument errors.
Dim strInstrumentError As New StringBuilder(1000)
Dim bFirstError As Boolean = True
Do
VisaSendCommandOrQuery(":SYSTem:ERRor?")
strInstrumentError = VisaGetResultString()
If strInstrumentError.ToString() <> _
"+0,""No error""" & Chr(10) & "" Then
If bFirstError Then
Console.WriteLine("ERROR(s) for command '{0}': ", _
strCommand)
bFirstError = False
End If
Console.Write(strInstrumentError)
End If
Loop While strInstrumentError.ToString() <> _
"+0,""No error""" & Chr(10) & ""
End Sub
Private Sub VisaSendCommandOrQuery(ByVal strCommandOrQuery _
As String)
' Send command or query to the device.
Dim strWithNewline As String
strWithNewline = [String].Format("{0}" & Chr(10) & "", _
strCommandOrQuery)
Dim nViStatus As Integer
nViStatus = visa32.viPrintf(m_nSession, strWithNewline)