The term ActiveX surfaced in the Microsoft world in early 1996. It was a natural extension of the Common Object Model (COM) that was originally released by Microsoft in 1993, and later grew into Distributed Common Object Model (DCOM). There are many websites that try to clarify these terms, and the one given by National Instruments at http://zone.ni.com/devzone/cda/tut/p/id/3831 is one of the better examples.
With LabVIEW 4.1 came support for ActiveX clients. LabVIEW 5.0 added support for ActiveX servers and ActiveX containers. LabVIEW 5.1 added support for ActiveX events. And finally LabVIEW 6i added support for the To Variant function that converts any type of LabVIEW data to a Variant datatype for input into an ActiveX method, property, or event. Several other features for handling Variant datatypes are found in the Advanced>>Data Manipulation>>Variant palette.
There are many positive and negative aspects of ActiveX, and many LabVIEW users argue against the use of it. Added complexity, lower performance and compatibility, lower security and reliability are some arguments used. This article is not intended to add to that debate. Rather, it shows an interesting example of how you can make use of complex ActiveX components--components you would not dream of constructing yourself. The example application also demonstrates, once again, the power of the queue-driven state machine (QDSM).
One of the more exciting ActiveX controls that I have come across is Microsoft Agent (MS Agent) version 2.0. I accidentally stumbled across it on Info-LabVIEW some years ago when I found an example showing how to use MS Agent in LabVIEW. The examples were written by Hank Walters.
These MS Agent ActiveX objects give you the possibility to have live cartoon-like characters on the screen, speaking through the Lernout and Hauspie speech engine to the operator using simple text-string inputs from within LabVIEW. The characters are very vivid and alive. I have set up a system for exploiting these live speaking characters as guides in a LabVIEW program. The initial idea was to have a much more impressive attention catcher than the standard About window. It turned out to be a useful guide to the user interface of the top-level VI of the program. The example is not set up to interact further with subwindows (routines) of the main program.
Figure 1: The Interface of the Mission Editor 1.0 for LabVIEW 6i
You can find the MS Agents on the LTR Resource CD. To install the Microsoft Agent files, you must perform the following steps:
1. Copy the Microsoft Agent core components (MSAgent.exe, 395 KB).
2. Copy the Microsoft Agent character files:
b) Merlin (1.8 MB exe)
c) Robby (2.2 MB exe)
d) Peedy (3.3 MB exe)
American English (1 MB exe)
You will have six executable files on your hard disk. Install them one-by-one in the same order as you downloaded them. (MSagent.exe, Genie.exe, Merlin.exe, Robby.exe, Peedy.exe and tv_enua.exe). After running all six installers you will see that the characters are installed as .ACS files in the folder C:\WINDOWS\MS AGENT/CHARS (Win 9x) or C:\WINNT\MSAGENT\CHARS(WIN NT).
Included on this issue’s LTR Resource CD, you will find two versions of the Mission Editor.
- The Mission Editor 1.0 for LV6.llb for Win 9x
- The Mission Editor 1.0 for LV51.llb for Win 9x/Win NT
There is a bug in LabVIEW 6i that disables ActiveX communication with the MS Agent library. National Instruments is aware of this problem.
The Mission Editor is created using the QDSM presented in a previous LTR by Gregg Fowler ("Interactive Architectures Revisited," LTR Volume 4, Number 2). The Mission Editor is a good example of how powerful the QDSM template can be. An Agent job is set up as an array of steps (clusters). Each step contains information about what the character should say, if and where it should move on the screen, and if and where it should gesture. You can save a job as a .job file and load it later for editing or use it in the application program as described in the next section.
You use the first row of buttons below the step window (see Figure 1) to move backward and forward in the job steps and to add new and delete old steps. The second row of buttons allows you to load a job, save a job, run an entire job or just the current step, or stop the Editor. You use the character control (on the right) to select which character to run, and there are indicators showing the current step and the total number of steps (on the left). When running the job or the current step in the Editor, you can use the Stop Agent button, which becomes enabled while some other buttons are disabled.
When you have familiarized yourself with the Mission Editor, you can try setting up a job for one of your own applications. You will have to open the main window of your application so it lies right beneath the Mission Editor. This is necessary to coordinate the X and Y positions of MS Agent with respect to your application's main window. Once the main window is opened and positioned, you can edit step-by-step the Agent's movements or gestures on your application's interface and also what the Agent will say. For instance, you can make the Agent move to all controls and indicators and let him explain their function for visitors or new users of your application. If needed, you could set up a short job for visitors, and a more detailed job for new users.
Implementing the job into an application can be done fairly easily by passing the job file you created with the Mission Editor into the Load Job file.vi and Run Agent Job.vi as shown in the diagram in Figure 3. The menu is configured via the Edit>>Runtime menu.
Figure 3: Implementing an Agent Job from the Menu in Your Application
When you start a job from the menu a small window from the Run Agent Job.vi panel will pop up showing a Stop Agent button. The operator can click this any time if the Agent is to be dismissed before the job is finished. It is normal in the first step of a real application to let the Agent introduce himself, tell you to turn up the volume if it is difficult to hear him, and point out how to stop the tour before it has finished.
Figure 2: How to Implement the Agent Job in Your State Machine
The example LabVIEW program, Test program 1.vi, included on this issue's LTR Resource CD and illustrated in Figure 2, shows how an MS Agent job can be set up and used in an application. The job running in this program is the included file Window tour 1.job. This example program is a simplified version of a typical test program found in the laboratories at the author's workplace. The example program finds the performance of a catalyst for a specific chemical reaction. To make this example program function, remember to place the Window tour 1.job in the C:\ directory.
Of course there are numerous other situations in which MS Agents can be applied to your LabVIEW programs, but they should be used with caution. If they appear too frequently, they might irritate and frustrate the user. One situation in which they might be worthwhile is special error or alarm situations that require the operator’s complete attention. In general, I would not recommend using MS Agents as a normal part of your GUI. (I think most people have all wanted to kill the Microsoft Word paperclip at one time or another.)
The features of the MS Agent shown so far only scratch the surface of this wide subject. At Microsoft's MSDN database, you can find documentation about Microsoft Agent by looking under the sections in the menu at Welcome to the MSDN Library>>User Interface Design and Development>>Microsoft Agent. There is an extensive documentation set that beats most I have seen for ActiveX components. On the same site there is an Agent Character Editor that can be used to create new characters using your own bitmaps. The Character Editor also provides the choice of a synthesized, text-to-speech (TTS) voice or a voice that uses recorded sound files. You can read more about the Character Editor in the chapter "Using the Microsoft Agent Character Editor," which also describes how to find and install it.
On the website under "Using the Microsoft Linguistic Information Sound Editing Tool," there is a Linguistic Information Sound Editing Tool available that you can read more about. Under "Programming the Microsoft Agent Control," you can read more about the character’s methods, properties, and events. And if you want more documentation, even more is available on those web pages.
Hank Walter's original work includes two characters he created that use voices only, no animation. This can be useful in special situations, and the characters require very little computer resources. These two characters are included on this issue’s LTR Resource CD as Betty.acs and Denny.acs. If you want to use them, just place them in the same folders as the other four characters that have been installed on your machine.
Imagination and time are the only limitations when working with applications under LabVIEW. Experience also comes in handy, of course.
LabVIEW Technical Resource (LTR) is the leading independent source of LabVIEW-specific information. Each LTR issue presents powerful tips and techniques and includes a Resource CD packed with VIs, Utilities, Source Code, and Documentation.
Martin Plassen works at the institute of Applied Chemistry, Department of Hydrocarbon Process Chemistry in SINTEF, a contract research institute located in Norway. For several years he has been working with LabVIEW as a programming tool applied to the discipline of combinatorial chemistry. Martin Plassen can be reached at firstname.lastname@example.org.
Thanks to Hank Walters for creating and sharing his original work.