Appendix 2. Programming Examples
324
Example 2. Checking the Instrument Ready State
Normally, the user control program starts when the analyzer executable module is
running, the instrument booting is completed, and the instrument is ready for use. In
some cases, it is recommended to check if the instrument is ready for use. The
instrument may be not ready for use if it is not connected to PC via USB cable.
Moreover, if the analyzer executable module has not been started in advance, the
CreateObject
function will automatically start the application and then within about 10
seconds the instrument booting will be in progress. The instrument will not be ready
for use until the booting is completed. The
Ready
property is used to check if the
instrument is ready for use.
The following program checks the
Ready
property right after a COM object has been
created. If the analyzer executable module has been started in advance and the
booting is completed,
“Analyzer is ready”
will be displayed. If the
Ready
property value
is
False,
10 second delay is activated for the case the analyzer executable module has
been started by the COM object creation. In 10 seconds the program rechecks the
Ready
property. If the value is
True, “Analyzer is ready”
will be displayed, if otherwise,
“Analyzer is not ready”
will be displayed, what means the instrument is not turned on or
it is not connected to PC via USB cable.
Dim app As Object
Sub Example2()
Set app = CreateObject("TRVNA.Application")
If app.Ready = False Then
Application.Wait (Now + TimeValue("0:00:10"))
If app.Ready = False Then
MsgBox ("Analyzer is not ready")
Exit Sub
End If
End If
MsgBox ("Analyzer is ready")
End Sub