Using Generic Driver with Test & Measurement Tool
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
\toolbox\instrument\instrument\driversdirectory, in the MATLAB® Command Window, make sure that the directory containing your driver is on the MATLAB path.
If you do not see the directory in the path listing, and the driver is not in the
\toolbox\instrument\instrument\driversdirectory, add the directory to the path with the command
directoryis the pathname to the directory containing your driver.
Open the Test & Measurement Tool.
In the Test & Measurement Tool tree, expand the
MATLAB Instrument Driversnode.
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.mddnode in the tree.
ie_drv.mddnode 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.
When the Test & Measurement Tool creates the device object, an entry for the object appears as a node in the tree. The
Browser-ie_drvnode 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.
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
Topin the Device object properties list.
The first value displayed for setting this property is
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
Topproperty. 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.
Vsizein the Device object properties list.
Enter a property value of
200, and click Set. Notice the IE window size.
Enter a property value of
400and 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
Vsizeproperty. Notice the value returned to the Response pane.
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.
goToin 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 nodein the tree and select Delete Object. Close the Test & Measurement Tool, and close the IE browser window you created in this example.