To establish connection with the COM server application, create an object reference in the client program. In COM programming, the object reference needs to be acquired preliminarily, to be used later to access the object functionality. To define an object, perform the following:
•Declare a variable as an object.
•Create a COM Object and assign it to this variable.
To declare a variable, use the Dim operator or another declaration statement (Public, Private or Static). The variables used for references should be Variant, Object, or a type of specific object. For example, the following three operators declare an app variable:
Dim app Dim app as Object Dim app as S4VNA.Application |
Use the Set operator and CreateObject (ObjectName, HostName) function to assign a specific object to a variable.
ObjectName |
Object name is always equal to "S4VNA.Application" |
HostName |
Network name of the PC hosting the COM server. This parameter is not specified in the case of a local server. |
For example, the following operators create an Application object and assign it to app variable:
Set app = CreateObject("S4VNA.Application") Set app = CreateObject("S4VNA.Application", "Analyzer_Name") Set app = CreateObject("S4VNA.Application", "192.168.1.149") |
note |
The first form of the operator is used to create the reference to the local COM server, the second and third forms are used to create the reference to the remote DCOM server. |
To allow access to the objects of a lower level on the hierarchy, these objects are specified after the reference to the higher-level object and separated from it by a dot. For example:
Dim SystObj Set SystObj = app.SCPI.SYSTem |
COM objects can have indices. For example, CALCulate, INITiate, SENSe, SOURce objects represent various aspects of the 16 measurement channels of the Analyzer. Therefore, it is necessary to write the channel index from 1 to 16 to acquire the data of these objects. For example:
Set SensObj1 = app.SCPI.SENSe(1) Set SensObj2 = app.SCPI.SENSe(2) |
Visual Basic allows omitting of such indices; in this case, the indices are considered as equal to 1. For example, the following VB operators are equivalent:
Set SensObj = app.SCPI.SENSe(1) Set SensObj = app.SCPI.SENSe |
note |
The models of vector network analyzers working with the S4VNA executable module share the same COM object. The name of COM object is S4VNA.Application. For example, the commands for creating a COM server for 4-port an Analyzer is:
For backwards compatibility, the old name is preserved for creating COM object for each model. The user can use the old and new name of the COM object interchangeably, since they all create the same COM object. For example:
|