Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Sep 6, 2006


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links - Products and Services

Creating Simultaneous Instances Remote Panels LabVIEW Applications

1 ratings | 5.00 out of 5
Print
This tutorial teaches you how to use the new remote panel feature in LabVIEW in conjunction with VI templates to build LabVIEW applications that have a unique user interface for each new user instead of displaying a common user interface to everyone. We will refer to such applications as "Simultaneous Instances Remote Panels" applications. This functionality is useful in the case where you want a lot of people to have access to your LabVIEW application, but you want each user to see different data that is unique to that individual. For example, this is useful in the case of distance learning applications where you want every student to use the same LabVIEW VIs, but each student has a different idea for how to use the VI to solve the problem and therefore wants to interact and control it differently. By following this tutorial you can learn how to use the remote panels feature in LabVIEW and use VI templates to build these applications.

LabVIEW remote panels allow you to view and control VIs through a standard Web browser. Creating a remote panel Web page is easy with the LabVIEW Web Publishing Tool. A few mouse clicks creates a Web page with the embedded VI front panel image that can be viewed through the client's Web browser.

Remote Panels allow multiple clients to simultaneously view the front panel of the same VI (if multiple remote panel licenses are enabled). However, only one client can control the VI front panel. By default, the execution system cannot execute multiple calls to the same VI simultaneously. For our distance learning example, this means that every student would see the same application and all of them would have to interact with it in the same way since only one student could control it and everyone else is watching what that one student is doing.

However, if you make a VI re-entrant, each instance of the call maintains its own state of information. Then the execution system runs the VI from its own separate dataspace. Although LabVIEW allows multiple calls to the same VI to occur and for each call to have unique data, LabVIEW does not allow the VI to be in use by multiple students at the same time. In this case, each student could have unique control of the application but the VI would be accessible by only one student at a time, and the next student would not be able to use the VI until the student currently using the VI finishes. This is a result of how the LabVIEW VI Server actually calls the VI. When you call a VI using a Virtual Instrument Class Reference (Open VI Reference, Property/Invoke Nodes, Close Application/VI Reference), it is treated as if you had opened the front panel and were running the VI. You cannot have multiple copies of a top-level VI running simultaneously.

The solution therefore must both allow all students to have unique control of the LabVIEW VI, and allow all of these individual instances of the VI to run simultaneously. This can be achieved by using the VI templates. Each time a template VI is called simultaneously with VI server, LabVIEW creates a replica VI with unique name. At the end of execution, you can close and delete these uniquely named VIs. When you open the VI as a template VI, each connection to the Web page results in a new instance of the VI and each client can gain control of its instance through the remote panels. In this case, each student gets a unique instance of the VI to work with each time they open the web page.

To show how these technologies can be used, let's walk through an example application that uses this technique. The following example uses CGI scripting to dynamically access the LabVIEW VI Server and return individual instance of the template VI. The LabVIEW Internet Toolkit provides the ability for your LabVIEW applications to respond to CGI scripting commands.

<HTML>
<HEAD>
<TITLE>Simultaneous Instances Remote Panels</TITLE>
</HEAD>
<BODY>
<H2>Simultaneous Instances Remote Panels</H2><P>
Click Submit to be redirected to the selected database viewer.

<FORM action=/cgi-bin/test/RemotePanels.llb/redirect.vi method=post>
Database Viewers (Test CAtegories):
<INPUT TYPE ="RADIO" NAME="radio" VALUE="FieldPoint"> FiledPoint
<INPUT TYPE ="RADIO" NAME="radio" VALUE="DAQ"> DAQ
<INPUT TYPE ="RADIO" NAME="radio" VALUE="IMAQ"> IMAQ
<INPUT TYPE ="RADIO" NAME="radio" VALUE="Motion"> Motion
<INPUT TYPE ="RADIO" NAME="radio" VALUE="CAN"> CAN
<INPUT TYPE ="RADIO" NAME="radio" VALUE="GPIB"> GPIB
<INPUT TYPE ="RADIO" NAME="radio" VALUE="FileIO"> FileIO
<INPUT TYPE ="RADIO" NAME="radio" VALUE="NetIO"> NetIO
<INPUT TYPE ="RADIO" NAME="radio" VALUE="Jitter"> Jitter
<INPUT name=Submit type=submit value=Submit>
<INPUT name=Reset type=reset value=Reset>
</FROM>
</BODY>
</HTML>

Pressing the Submit button on this page invokes the CGI VI – redirect.vi.

This CGI script clones a new handler from the handler template (handler.vit), create an HTML document in the LabVIEW/www that contains an embedded link to the handler.vi, and return HTML code to the web browser that redirects the browser to the HTML document just created.

[+] Enlarge Image
Figure 1. Block diagram of redirect.vi

The redirect.vi is a state machine which is run from a Web Browser. The VIs circled in red are the crucial VIs that will be contained in every CGI VI that you create. The VIs circled in blue are specific to decoding the form elements that were passed to the CGI, as well as building the HTML page to be returned to client's browser.


[+] Enlarge Image
Figure 2. Block diagram of CreateAndLoadHandler.vi

The CreateAndLoadHandler VI checks all the VIs in memory and searches for a VI whose name starts with "handler" string. If there is no such VI already in memory, it will open a reference to handler VI template, and name the VI "handler0". If LabVIEW finds a handler VI, the created reference increases the number by one and points to a new handler VI, named "handler1".

Once the reference to the handler VI has been created, CreateHandlerHTMLFile VI executes. This VI will create an .htm page with the embedded VI, and save it in the LabVIEW\www directory.


[+] Enlarge Image
Figure 3. Block diagram of CreateHandlerHTMLFile.vi

This embedded page is operated by the LabVIEW built-in G Web server. The second string element in this array of strings, has the HTML code that creates an alert page with the time restriction message. This page informs the user that the browser will be redirected to the default.html page after 5 minutes, or when a user clicks the Finish button. The elapsed time is displayed in the Windows status bar at the bottom of the window. The time restriction is added to prevent indefinitely opened remote panel pages.

After adding some heading tags, the final page is constructed with the Modified HTML Document.vi.


Figure 4. Block diagram of the Modified HTML Document.vi

The Modified HTML Document.vi runs the referenced handler VI, and measures the time needed to display this VI in the remote window. The DelayedClosedRef.vi (below) uses this time to provide a more deterministic release of the VI references.


[+] Enlarge Image
Figure 5. Block diagram of the DelayedClosedRef.vi

The DelayedClosedRef.vi allows 30 seconds for the browser to load the handler VI remote panel image, before closing the reference to this VI. Once a user opens a VI remotely, the VI remains in memory on the server as long as a remote client is viewing the panel and the VI reference from the CGI is open. By default, the reference from the CGI panel closes when the CGI VI is stopped, because it has not been accessed in 120 sec (default CGICacheTime that idle CGIs are cached). This time is specified in the lvhttp.cfg file located in the LabVIEW\internet\http\conf\ directory.



[+] Enlarge Image

Figure 6. Final page with embedded handler VI

Related Links:
Upgrading from LabVIEW 6.0 to LabVIEW 6.1
Upgrading Remote Panel Licenses
CGI Basics
Simultaneously Controlling Remote Panel Instances of VI Templates

1 ratings | 5.00 out of 5
Print

Reader Comments | Submit a comment »

Pictures are very poor, even the Enlarge Image does not help. Please make them clearer.
- Jul 3, 2007

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).