Introduction
A virtual (or remote) laboratory is one in which the student interacts with an experiment or activity which is intrinsically distant from their physical location. In an academic setting, typically a virtual lab refers to a teaching activity in which the participants interact (view or control) with physical apparatus of the activity through a network connected computer terminal, either in or outside of the normal classroom. Some of the purported benefits of employing virtual labs are:
- participants don’t necessarily need to be in the same physical location as the laboratory hardware – thus virtual labs can enrich a distributed classroom or a distance learning curriculum.
- participants are able to access physical equipment that would be otherwise unavailable to them, perhaps due to the location of their institution, access restrictions, the desire to minimise risk when working with dangerous equipment, or due to the general unavailability of equipment.
- participants have the opportunity to practice ICT skills inherent to hosting, controlling, or simply accessing networked equipment – thus instilling skills that may be called upon in their future career.
In previous lessons, we have demonstrated how National Instrument’s LabVIEW software package provides a streamlined interface for the development and use of virtual instruments (VI) - programmes that offer vast range of capabilities in instrumentation, control, and data processing. In this lesson, we shall introduce how virtual instruments can be implemented as distributed applications thus offering the ability to develop a virtual or remote lab. In LabVIEW this is achieved through their implementation of remote panels.
Remember that in LabVIEW, the virtual instrument contains two main parts:
- The Front Panel, on which controls and indications are placed and which forms the end user’s HMI; and
- The Block Diagram, which controls the dataflow through the program and the code that is applied to process data.
When implementing a remote panel, the Front Panel of the VI can be interacted with on a terminal that is separate from where the VI itself is executed. The Front Panel can also be embedded into a webpage and accessed remotely through a web browser. This second mode requires only that the accessing machine has the LabVIEW run-time engine and browser extension plugins installed.
Note that the associated Block Diagram (i.e., the underlying executable code) is not available remotely.
The figure below illustrates the networking of a remote panel VI:
Figure 1: Remote Panel Network - Doug Rattray, LCC, UHI
The following sections shall describe how to setup the Server Machine and access the Remote Panel via a Client Machine:
Server Machine · Configuring network settings for a web server · Definition of client access permissions. · Hosting requirements for VI files |
Client Machine · Accessing the Remote Panel through web browser · Operating a Remote Panel |
Hosting a Remote Panel
Whether the Remote Panel is to be accessed from within LabVIEW via a network connected terminal or embedded into a webpage, the Server Machine needs to be configured to host the LabVIEW Web Server.
There are three steps required to configure the Server Machine to use the LabVIEW Web Server:
- Configure network settings for the web server.
- Define client access permissions.
- Specify VI files to be hosted.
When embedding the Remote Panel on a webpage, a single additional step is required:
- A web page must be created and published to host the remote panel through the LabVIEW Web Server.
Configure Network Settings for the Web Server
The network settings for the LabVIEW Web Server are configured within the LabVIEW software environment by selecting:
- Tools / Options / Web Server.
Under the Remote Panel Server section make the following configurations:
- From within the Dialogue Box, select Enable Web Server by clicking the appropriate checkbox.
- Allow LabVIEW to select the default HTTP Port – in our case ‘8000’ but is also often set as ‘80’.
Allow LabVIEW to use the default Root Directory – in our case ‘C:\Program Files\National Instruments\LabVIEW 2020\www’.
Define Client Access Permissions
The next step is to define client access permissions. When configuring the LabVIEW Web Server, a list of client IP addresses can be allowed access. Each individual IP address may be granted varying degrees of access permission: allow viewing and controlling, allow viewing only or to deny access.
In the LabVIEW Web Server configuration:
- Tools / Options / Web Server.
Under the Browser Access section make the following configurations:
- Specify the Browser address as an asterisk (*), alternatively specify each participants IP address individually if known.
Note that an asterisk (*) can be used as a wildcard to grant the selected access permissions to all IP address.
Select to ‘Allow viewing and controlling’ by selecting the appropriate checkbox.
Specify the VI Files to be Hosted
The final step is to specify a list of VIs that can be accessed remotely.
In the LabVIEW Web Server configuration:
- Tools / Options / Web Server.
Under the Visible VIs section make the following configurations:
- Add the name of the VI to be hosted – in our case: ‘vi’
- Select to ‘Allow access’ by selecting the appropriate checkbox.
- Allow LabVIEW to use the default Control Time – in our case ‘300 seconds’.
Note: The control time limit is required if your VI is to be accessed by multiple clients. Without a control time limit, a single client terminal could hold control of the application, preventing other users from using the remote panel VI.
Web Browser Access
To provide web browser access, one additional step is required: a web page must be created and published to host the remote panel through the web server. LabVIEW offers a simple tool for publishing a basic Remote Panel called ‘the Web Publishing Tool’.
LabVIEW’s Web Publishing Tool allows a user to create a HTML file of a web page based on a very simple template. The template includes the embedded VI along with some basic metainformation. The tool then publishes the webpage to the internet. This tool can be appropriate if the VI Front Panel contains all of the necessary user interface desired for the associated activity.
Note: you also can create your own HTML page manually to host an embedded remote panel. Doing so, would allow the webpage designer to add significantly more information or functionality to the hosted Remote Panel. Refer to LabVIEW online help for detailed guidance.
Access the Web Publishing Tool by selecting:
- Tools / Web Publishing Tool.
In the dialogue box make the following configurations:
- Select the VI name you wish to publish – in our case: ‘vi’
- Select the Viewing mode to ‘Embedded’
- Click ‘Next >’ to move onto the next config step.
In the next dialogue box provide the VI with a Title, Header and Footer if desired.
- Click ‘Next >’ to move onto the final config step.
In the final dialogue box provide the VI with a Local Directory and Filename.
- Before continuing, make a note of this URL – this URL shall be the website address used to access the Remote Panel.
Select ‘Save to Disk’ to create and publish the webpage to the internet.
In the next Section, we shall describe how to access a Remote Panel from a Client Machine.
Accessing a Remote Panel from a Client Machine
This section shall provide a walkthrough for accessing the Remote Panel from within LabVIEW via a network connected terminal or one that is embedded into a webpage.
Accessing a Remote Panel from within LabVIEW (Network Connected Terminal)
On your Client Machine, from the LabVIEW development system menu, select Operate / Connect to Remote Panel to display the ‘Connect to Remote Panel’ dialog box.
- In the Server address field, enter the IP address of the Server Machine – in our case a dummy IP address: ’0.0.1’.
- In the VI Name field, enter the name of the Remote Panel VI – in our case ‘vi’.
- In the Port field, enter the HTTP Port that was enabled during the Web Server configuration – in our case ‘8000’.
- Select to request control by ticking the appropriate checkbox.
Note: You can request control later by right-clicking on the remote front panel window when it appears.
- Click the ‘Connect’ button to continue.
The remote panel will appear on your computer. If access is denied, an error message will appear in the Connection Status section of the Connect to Remote Panel dialog box.
Accessing a Remote Panel from a Web Browser
To operate a Remote Panel from a web browser, the Client Machine needs to have the LabVIEW run-time engine and browser plug-in installed.
- If the Client Machine does not have the LabVIEW programming environment installed the user can chose to install the run-time engine separately from the NI downloads resource: https://www.ni.com/nl-nl/support/downloads/software-products/download.labview-runtime.html#346222.
- Plug-ins are available to enable access through various web browsers, however, NI recommends that the Client Machine uses Microsoft Explorer to access Remote Panels. The standard MS Explorer install does not require any additional plug-ins to be installed.
Once prepared, a user can access a Remote Panel by browsing to the URL in which the VI is embedded.
Note that the URL was created during the configuration of the Web Publishing Tool above and should have been noted down. In general, the URL should comprise the [server IP], [domain name] and [HTML file name]. Generic examples may take the following form:
- Via a LAN - http://PcName: Port/ViName.htm.
- Via the internet - http://lpAddr:Port/ViName.htm.
Once the Remote Panel is accessed through the browser, right-click on the panel to display a pop-up menu.
Use this panel to ‘Request Control of VI’.
Test the VI by executing the VI and checking the functionality of the Remote Panel in the web browser.
When Terminating the Remote Panel in a web browser, control shall be passed back to the Server Computer.
Notes
- To host a Remote Panel, the VI you wish to host must be loaded into memory on the Server Machine but not necessarily running.
- The Server Machine can reclaim control of the VI at any time.
- Various aspects of functionality that are normal when operating a VI locally [e.g.: manipulating window position and size, system sounds, ActiveX controls, calling up of other VIs from within the active VI Front Panel, manipulating the active Front Panel] may not work as intended on the remote panel. It is best to test required functionality before using Remote Panels as a teaching tool.
- For web-embedded Remote Panels, the size of the Remote Panel is the same as the size of the Front Panel used to create the HTML file. To change the size of the Remote Panel, you must resize the VI on the Server Machine and republish the HTML file.