Initialization And Default State - R&S ESR Series User Manual

Emi test receiver
Table of Contents

Advertisement

®
R&S
ESR
'adjust string length
Response = Left(Response, retCount)
End Sub
The following function illustrates status/error checking. The procedure raises an excep-
tion when a VISA error occurs:
Public Sub CheckError(ByVal vi As Long, status As Long)
Dim ErrorMessage As String * 1024
'Initialize error message string
ErrorMessage = ""
If (status < 0) Then
'Query the error message from VISA
If (viStatusDesc(vi, status, ErrorMessage) = VI_SUCCESS) Then
End If
Err.Raise (status)
End If
End Sub
3.6.1.2

Initialization and Default State

At the start of each program, the global variables used by all subroutines must be cre-
ated. The remote control and the instrument settings will then be changed to a defined
default state. The two subroutines InitController and InitDevice are used for this.
Creating Global Variables
In Visual Basic, global variables are stored in modules (data extension .BAS). Thus, at
least one module (e.g. GLOBALS.BAS) must be created that contains the variables
used by all subroutines, e.g. the variables for device addresses used by the remote
control driver.
For all example programs shown below, the file must contain the following instructions:
Global analyzer As Long
Global defaultRM As Long
Initializing the Remote Control Session
REM ------------ Initializing the remote control session -------------------
Public SUB Initialize()
Dim status As Long
'CALL viOpenDefaultRM to get the resource manager handle
'Store this handle in defaultRM.
'returns a text description of the status code returned by viOpenDefaultRM
status = viOpenDefaultRM(defaultRM)
status = viStatusDesc(defaultRM, status, Response)
'Open the connection to the device and store the handle
'Note: The timeout value in viOpen() applies only for opening the interface
'For setting the communication timeout, set the VI_ATTR_TMO_VALUE attribute
User Manual 1175.7068.02 ─ 12
Err.Description = ErrorMessage
Brief Introduction to Remote Control
The function viStatusDesc
Quick Start
122

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents