Using Generic Driver with Test & Measurement Tool
Note
The Test and Measurement Tool app will be removed in a future release. Use the TCP/IP Explorer, UDP Explorer, Serial Explorer, or VISA Explorer app instead.
Creating and Connecting the Device Object
With the Test & Measurement Tool you can scan for your driver, create a device object that uses that driver, set and get properties of the object, and execute functions.
This example illustrates how to use the generic driver you created in Writing a Generic Driver.
If your driver is not in the
matlabroot
\toolbox\instrument\instrument\drivers
directory, in the MATLAB® Command Window, make sure that the directory containing your driver is on the MATLAB path.path
If you do not see the directory in the path listing, and the driver is not in the
matlabroot
\toolbox\instrument\instrument\drivers
directory, add the directory to the path with the commandaddpath directory
where
directory
is the pathname to the directory containing your driver.Open the Test & Measurement Tool.
tmtool
In the Test & Measurement Tool tree, expand the
Instrument Drivers
node.Select the
MATLAB Instrument Drivers
node.Your driver might not be listed yet, so click Scan in the lower-right corner of the tool. If the tool found your driver, it is listed in the tree as
ie_drv.mdd
.Select the
ie_drv.mdd
node in the tree.Right-click the
ie_drv.mdd
node in the tree, and select Create Device Object Using Driver. The following dialog box appears.Select the Select the created device object in the tree on dialog close check box. The device object in this example does not need a resource, so keep that field empty.
Click OK.
When the Test & Measurement Tool creates the device object, an entry for the object appears as a node in the tree. The
Browser-ie_drv
node should already be selected in the tree. This refers to the device object you just created.Click Connect in the upper-right corner of the Test & Measurement Tool. This establishes a communication channel between the tool and the IE browser window, and an empty IE window appears on your screen. Remember that the Create code for your driver creates an object for the IE browser, and the Connect code and makes its window visible.
Accessing Properties
The driver you created allows you to specify where the browser window appears on your screen and how large it is.
Click the Properties tab, and then select
Top
in the Device object properties list.The first value displayed for setting this property is
0.0
.Click Set. The IE browser window shifts upward to the top edge of your screen.
With the mouse, grab the IE window, and drag it down some distance from the top of the screen.
Now return to the Test & Measurement Tool window, and click Get for the
Top
property. Notice in the Response pane how many pixels down you have moved the window.
Use your driver Vsize
property to change
the size of the browser window.
Select
Vsize
in the Device object properties list.Enter a property value of
200
, and click Set. Notice the IE window size.Enter a property value of
400
and click Set. Notice the IE window size.Try resizing the IE browser window directly with the mouse. Then in the Test & Measurement Tool, click Get for the
Vsize
property. Notice the value returned to the Response pane.
Using Functions
Use the goTo
function of your generic driver
to control the Web page that the browser displays.
In the Test & Measurement Tool, click the Functions tab for your device object.
Select
goTo
in the list of Device object functions.In the Input argument(s) field, enter
'www.mathworks.com'
. Be sure to include the single quotes.Click Execute. Observe the IE browser and see that it displays the MathWorks Web site.
Experiment freely. When you are finished, right-click the
Browser-ie_drv node
in the tree and select Delete Object. Close the Test & Measurement Tool, and close the IE browser window you created in this example.