Your VIs on the Web: The LabVIEW Web Server


Often you'll want other people to be able to access your data or your VIs through a web browser. When you allow others to access your VIs over the Web, you should determine in advance if you want people to just monitor the VI (read-only) or control the VI (send data and events back) from the web browser.

LabVIEW makes publishing your VIs to the Web easy with the built-in LabVIEW web server. With the LabVIEW web server, you can dynamically create web pages with images of a VI's front panel on the fly, without the need for any special coding in your block diagram. In this next section, you'll see how simple it is to set up.

Configuring LabVIEW's Built-in Web Server

Don't confuse the VI Server with the web server in LabVIEW. They're unrelated and independent of each other. The web server is for allowing users to view and control a VI remotely (as well as view/download HTML and other files) using a web browser. The VI Server is for letting local and remote VIs call methods and properties of your VIs.


To enable the LabVIEW web server, do the following:

1.

To avoid system conflicts, make sure no other web server (e.g., Apache or IIS) is running on the same port before you enable the LabVIEW web server. If you don't know, most likely you do not have another web server running.

2.

If you have a firewall installed, or are using Windows' built-in firewall, you may need to ensure port 80 is not blocked. (Port 80 is the default port the web server runs on.)

3.

In LabVIEW, go to Tools>>Options>>Web Server:Configuration (as shown in Figure 16.1).

Figure 16.1. Web Server: Configuration options


4.

Check the box "Enable Web Server."

5.

If you desire, change the root directory. This is the directory on your hard drive where your web documents will reside.

6.

Click OK.

You can also control LabVIEW web server properties through the VI Server interface, using the property node for the Application class. This means you can programmatically turn the server on or off, set permissions for the access list, and so on (see Figure 16.2).

Figure 16.2. Web Server properties accessible via an Application Property Node



Publishing to HTML with LabVIEW's Web Server

With the LabVIEW web server, there is nothing to program on the block diagramall the details are handled by LabVIEW. The VI that is to be displayed in a web browser must already be loaded into memory (in LabVIEW) to be served by the LabVIEW web server. The LabVIEW web server can publish your VI to the Web in one of three ways:

  • "Snapshot" A static ("snapshot") image of a VI's front panel.

  • "Monitor" An image of a VI's front panel that you can configure to auto-refresh every N seconds.

  • "Embedded" A controllable version of the VI in the front panel. This option uses a browser plug-in to display the VI in real time and allows users to control the VI.

The following activity shows how easy it is to view the LabVIEW Example VI, Temperature System Demo.vi, through a web browser.

Activity 16-1: Using LabVIEW's Built-in Web Server to Publish Images and Animations

In this activity you will use LabVIEW's built-in web server to publish images and animations of a VI's front panel and view them in a web browser.

1.

Make sure you've turned on the built-in web server, as described earlier.

2.

Open the VI Temperature System Demo.vi (from the LabVIEW examples, in /examples/apps/tempsys.llb).

3.

Open your web browser.

4.

To see a static image of the VI, type in your web browser (on the same machine):

http://127.0.0.1/.snap?Temperature+System+Demo.vi

5.

To see an auto-refreshing image, you will need to use a browser that supports "push" features on images. With Netscape's browser, type this URL:

http://127.0.0.1/.monitor?Temperature+System+Demo.vi

You will see the image animate features like the graph. The push feature only works well on Mozilla Firefox, and not on Internet Explorer. On Internet Explorer, the whole page will auto-refresh continuously, instead of displaying pixel animation (see Figure 16.3).

Figure 16.3. An animated image of Temperature System Demo.vi viewed in a web browser


Let's examine the URL from the previous activity a little more closely:

127.0.0.1

This is just the special IP address for the local machine (if you were viewing the VI over the web from a remote host, you would have to type in the real IP address, of course).

.snap?

The .snap part of the URL is a special command that tells the LabVIEW web server to take a snapshot of the VI that will follow the ? character.

.monitor?

The other option, .monitor, is a special command that tells the LabVIEW web server to monitor and provide an animated image of the VI that will follow the ? character.

Temperature+System+Demo.vi

This is just the URL encoding for "Temperature System Demo.vi." In any URL, spaces must be replaced with the "+" sign or "%20" and any special characters (e.g., "?", "/") must use the appropriate URL encoding.

Note that these dynamic documents returned by the LabVIEW web server are simply front panel images; they are not HTML documents. However, it is very straightforward to create your own HTML documents that embed dynamic images of a VI's front panel; you do this by simply specifying the URL as the image source in an <IMG> tag.

Activity 16-2: Using LabVIEW's Built-in Web Server to Publish Interactive VIs

In conjunction with the LabVIEW web server, you can use the simple Web Publishing Tool (from the Tools menu). This little utility builds a simple HTML file for you where you can add text around your VI image. In addition to creating HTML files, it exposes the functionality of how to embed interactive VI panels into your HTML document.

1.

Make sure you've turned on the built-in web server, as described earlier.

2.

Open the VI Temperature System Demo.vi (from the LabVIEW examples, in /examples/apps/tempsys.llb).

3.

Open the Web Publishing Tool (from the Tools menu).

4.

Set the VI name drop-down list to "Temperature System Demo.vi" and set the Viewing Mode option to "Embedded," as shown in Figure 16.4. Then press the Preview in Browser button to open a preview HTML page in the default web browser (you can also press the Next button to complete the steps necessary to permanently save the HTML file).

Figure 16.4. Web Publishing Tool dialog


5.

In the page opened in your web browser, you will see the entire VI front panel (including the toolbar and menubar, if the VI is configured to show these while running). Right click on the panel and select Request Control of VI, as shown in Figure 16.5.



Figure 16.5. Requesting control of the VI in the web browser


6.

If control is granted (based on the Web Server: Browser Access settings in the LabVIEW Options . . . dialog), you will be able to control the VI, just as if you were running it from LabVIEW! Literally, all the functionality is theretry changing the scale values, or pop up on the graph and see the shortcut menu optionsit's all there!

7.

You can release control, from the panel's pop-up menu via the Remote Panel Client>>Release Control of VI option. Note that only one remote panel can have control, at any given time.

8.

You can regain control of the VI front panel (the real VI's front panel), from the pop-up menu of Temperature System Demo.vi, by selecting the Regain Control option. Additionally, you can also lock out other panels from gaining control by choosing the Remote Panel Server>>Lock Control option.

In addition to the built-in web server in LabVIEW, you can purchase the Internet Toolkit for LabVIEW from National Instruments. This toolset gives you an enhanced web server, with all the same features as the built-in web server, plus support for secure directories (user/password/groups), CGI capability, ftp, and telnet VIs. The following table shows the features that come with LabVIEW 8.0 and those that are part of the Internet Toolkit add-on:

LabVIEW 8.0

+ Internet Toolkit

http server (Web) server

telnet client

smtp client (email)

http server with added capabilities, such as CGI and password-protected directories

Remote panels

http client





LabVIEW for Everyone. Graphical Programming Made Easy and Fun
LabVIEW for Everyone: Graphical Programming Made Easy and Fun (3rd Edition)
ISBN: 0131856723
EAN: 2147483647
Year: 2006
Pages: 294

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net