The scripting module allows you to use Echoview COM objects to control and interrogate Echoview. COM automation allows third parties to develop scripts and applications that interact with Echoview in a well-defined and easy to use manner. Details about registered COM objects found by Echoview can be found on the Scripting page of the Echoview Configuration dialog box.
A useful overview of scripting for Echoview is Getting started with scripting.
COM provides several advantages over our previous scripting implementation:
This help file topic does not include a basic course in the use of COM objects. Some sources of general information on using COM objects that may assist you are:
This topic covers:
COM terms used in this Help file:
|
COM term |
Description |
|||||||||||||
|
An Echoview COM object is the interface between you (the user) and an internal Echoview object. An object is an instance of a COM class and contains methods and properties. A property, can itself be, a COM object such a Class or a Collection, or it can be a Member. |
||||||||||||||
| Class |
A Class describes the actions and things available to a COM object (of that Class). A Class can include Collections, other Classes, Methods and Members. For example:
|
|||||||||||||
|
The general term for an object which stores an indexed list of COM objects. Many of the objects exposed by Echoview are members of one or more collections. For example:
|
||||||||||||||
| Member |
Returns information about the state or an attribute of a COM object. The use of [] indicates that an array of values is available. Note: A Member is either read-only, or read-write. Attempting to write to a read-only property will have varying behavior depending on the language environment of your script and will not change the property. |
|||||||||||||
|
A procedure that:
|
||||||||||||||
|
An enumerated data type. That is, a set of named numeric constants. For example, an enum used to describe the seasons might be constrained to the following constants: eSummer, eAutumn, eWinter, eSpring. Enums are useful because they have names describing their function avoiding the need to deal with numbers. For example eSpring is much more understandable than season 3. Note: Due to VBS language design constraints, VBS users will need to use the numerical values for the Enums used with Echoview COM objects. See the Echoview COM Enum values page for more detail. See also:
|
||||||||||||||
|
A logical data type. Values available are: True, False. Note: When used to indicate a method's Return state, True indicates the function was successful. |
||||||||||||||
|
A string data type where the string is a sequence of alphanumeric characters. |
||||||||||||||
|
An integer data type. |
||||||||||||||
|
A floating point number data type. A number stored with double-precision. |
COM objects are accessed through their properties and methods.
The syntax of properties and methods are documented in the following way:
Feature
IsLicensed example
1. The name of the method or property.
IsLicensed is an Ev.Application method.
2. The syntax of the method or property.
(a) The type of access can be implied or stated as (read-only) or (read-write).
(a) The type of access is implied (read-only).
(b) The syntax specifies the data type of required and optional input and the data type of the resulting output.
(b) The output for IsLicesned is boolean (yellow highlight).
No input required is required for IsLicensed (pink highlight).(c) Further information is displayed under the headings:
Summary
Parameters
Return
(c) Summary, Parameters and Return briefly describe the use of IsLicensed.
Refer to the IsLicensed example (above).
|
DetectSurface |
DetectSurface(string SurfaceName, int FirstPing, int LastPing, double BetweenPingInterpolation) SummaryPerform bottom surface detection on the multibeam variable Parameters
ReturnEvObject3d |
DetectSurface is a method of the EvVariableAcoustic object.
DectectSurface inputs:
DetectSurface returns a detected bottom surface (with a specified name) that is accessed by the COM object EvObject3D.
A data type for the date as specified by Microsoft Office DATE or Microsoft Visual Studio 2005/.NET Framework 2.0 DATE .
|
DepthRangeMode |
(read-only) EDepthRangeGridMode DepthRangeMode SummaryGet the depth/range grid mode. This is specified by an enum for EDepthRangeGridMode. |
DepthRangeMode is a read-only property of the EvGrid object. The property returns information about the grid on an echogram. The information is an enum for EDepthRangeGridMode where
Start by creating a file in a text editor (Notepad, for instance) and name it with the .vbs extension, for example, echoviewscript.vbs.
To connect to Echoview, first create an instance of the EvApplication object:
' Open Echoview (if Echoview is already open, connects to the
' open Echoview instance)
Dim EvApp
Set EvApp = CreateObject("EchoviewCom.EvApplication")
Notes:
The Echoview COM scripting module automatically creates a scripting log file when a script is run. See Scripting errors for more information about the log file.
This scripting log file can become very large, and slow down your processing. To ensure that your scripts run efficiently, create a command to delete the scripting log file before running the script. This command is inserted at the start of the script. For example,
Dim EvApp
Set EvAPP = CreateObject ("EchoviewCom.EvApplication")
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.DeleteFile(EvApp.LogFileName)
To view examples of complete COM scripts refer to Example scripts for COM automation.
See also Getting started with scripting - Script content and structure.
When Echoview COM objects are requested (by scripts), Microsoft Windows finds the COM object in the last registered version of Echoview that was opened. The last registered version can be:
Notes:
The relationship of COM objects and collections to each other is discussed in the topic COM object hierarchy. The hierarchy page displays a schematic with image links to relevant COM object documentation.
All Echoview’s COM automation functionality is begun through the EvApplication object. Many of the create, detect and export command methods for an acoustic variable in an EV file are accessed via the EvVariableAcoustic object.
The relationship between a COM object and Echoview is decscribed in Summary of COM objects.
It is desirable to detect a failure, or error, in a running script. VBS usually produces an exception after a failure which is not very informative. An alternative for detecting failure of a method is to include a test of the validity of the returned value in the script.
The value returned for a method is usually: the object created; the number of objects created; or a boolean. In each case there is a recognised value that signals failure. NULL and -1 are used for objects or counts, and false is used for booleans. Validity of objects, for example, can be tested in VBScript by comparing them to Nothing (NULL) as in the 'Is Nothing' test for acoustic variables in the example below.
Setting the value of property does not return a value, but the set can be checked with get. A report of the reason for a failure may be accessed using the EvApplication method GetLastLogMessage().
For example:
Dim FSO: Set FSO = CreateObject("Scripting.FileSystemObject")
Dim fOut: Set fOut = FSO.OpenTextFile("tmp.txt", 2, true)
Dim EvApp: Set EvApp = CreateObject("EchoviewCom.EvApplication")
Dim EvFile: Set EvFile = EvApp.OpenFile("MyEvFile.ev")
for VarIndex = 0 to EvFile.Variables.Count-1
Dim Var: Set Var = EvFile.Variables.Item(VarIndex)
Dim VarAc: Set VarAc = Var.AsVariableAcoustic
If VarAc Is Nothing Then
fOut.WriteLine Var.Name & " is not an acoustic variable"
Else
Dim iCount: iCount = VarAc.DetectFishtracks("Detected Fish")
If iCount = -1 Then
fOut.WriteLine VarAc.Name & ": " & EvApp.GetLastLogMessage
Else
fOut.WriteLine Var.Name & " Schools: " & CStr(iCount)
End If
End If
Next
fOut.Close
Note: In the VBS language, NULL is returned as Nothing.
The VBS language handles optional parameters and optional object parameters differently.
For example, VBS will not accept the omission of Nothing in the following:
If Not VarAc.ExportIntegrationByCells("SomeFile.csv", Nothing) Then
For example VBS will accept the following:
Set Surface = VarAc.DetectSurface("Surface”)
The above script snippet sets a variable to be the surface which is the result of the EvVariableAcoustic.DetectSurface method. In this case the omitted optional parameters default as follows: FirstPing: -1, LastPing: -1 (the whole echogram) and Maximum triangulation distance: 20.0.
Echoview COM (known as the Echoview Automation Library) is built into the Echoview software. To register the Echoview Automation Library with Windows (especially with Vista or Windows 7and their tigher security) you will need to run Echoview (once) under Run As Administrator. This registers Echoview and the Echoview Automation Library.
About automating Echoview
Getting started with scripting
Scripting errors
Summary of COM objects