LabSocket - The Easy Way to Extend LabVIEW to the Web

LabSocket System

A Potential Solution to the "Engineer Crunch"

John Bergmans, Feb 21 2014

TL;DR - Consider the use of data flow programming and automatic HTML/JS generators to help alleviate the "Engineer Crunch".

The article The Engineer Crunch by @sama suggests a number of good solutions to a shortage of technical talent available to startups in the Bay Area, including - improving employee compensation, making do with fewer engineers, recruiting outside one's network and fixing immigration laws.

One solution that is not mentioned in the article, but is worth considering, is the use of new programming tools that can increase the productivity of existing developers and enlarge the developer talent pool by simplifying the software development process.

For firms developing web applications, an example of such a solution is the LabSocket System. This system enables LabVIEW (a well-established graphical dataflow programming language) to be used to easily create dynamic web applications. Just as LabVIEW enables non-programmers to readily create data acquisition and control software, the combination of LabVIEW and LabSocket could contribute to alleviating the "Engineer Crunch".

Introduction to LabVIEW

LabVIEW is a graphical dataflow programming environment from National Instruments Corp. (NI). The relative ease with which complex software can be developed using graphical programming techniques, combined with the hardware devices offered by NI and others, has made LabVIEW a popular programming tool with scientists and engineers for decades. Typical applications for LabVIEW are data acquisition and control systems for manufacturing and laboratory testing.

LabVIEW applications are written, or more precisely, drawn, on a "Block Diagram" and the user interface is created by dragging and dropping controls and indicators onto the "Front Panel". The Front Panel and Block Diagram are two parts of an entity defined as a "Virtual Instrument" (or "VI") and saved together in a single file.

The Front Panel and Block Diagram for a very simple logic application are shown below. The figure also includes the Front Panel and Block Diagram palettes which contain a large selection of User Interface elements and software functions and structures.

LabVIEW applications are typically written and executed on Windows platforms, though Mac OS and Linux platforms may also be used.

Power of Graphical Programming

The potential of graphical programming to address the issue of developer scarcity is evident when considering a basic math quiz application written in LabVIEW. The front panel and a snippet of the block diagram of the quiz are shown below. (Access to the quiz in a web browser will be discussed in more detail momentarily.)

Quiz Front Panel
Front Panel of Simple Quiz Application

The code snippet shows the logic used to process the results of the two simple math questions that are presented to the user in the quiz. On the left side of the snippet is an array of references to string indicators that display the results of each question in the quiz. Within each iteration of the For Loop, the correct answer and user's answer are input into a comparator. The output of the comparator then determines how the user interface and the score data are updated:

  • Answers Match - "True" case executes. The inputs to the property node are set such that the background color of the response string is set to green and the string "Correct" is displayed for that result. The user's score is also incremented.
  • Answers Do Not Match - "False" case (not shown) executes. The property node inputs are set such that background color for the response string is set to red and the string "Wrong" is displayed. The user's score is not changed.

Upon exiting the For Loop, the user's score is also updated on the User Interface.

This code snippet illustrates one of the most notable benefits of a graphical data flow language such as LabVIEW - the code for a moderately complicated task (eg. data processing; UI updates; and, state management) is easy to develop, understand and modify. This code can be easily understood by even a novice programmer and could be created from scratch by someone with modest programming skills and a basic level of familiarity with LabVIEW.

Extending this capability to developing a web application only requires the use of the LabSocket system, as described in the next two sections.

Extending LabVIEW to the Web Using LabSocket

The LabSocket System is an add-on package for LabVIEW that enables remote access to a LabVIEW application from desktop or mobile web browsers. To access a LabVIEW application, or "Target Virtual Instrument (VI)", over the Web, the LabSocket software operates on the LabVIEW Host Platform in parallel to the Target VI, as shown in the figure below. The LabSocket Support VIs operate unobtrusively and perform two key functions:

  1. Upon starting the system, the Support VIs automatically perform a Screenscrape of the Target VI front panel. This function involves generating a web page using HTML and JavaScript code representing the Target VI front panel. This code is then posted to an HTTP server on the LabSocket Server platform.
  2. After performing the screenscrape, the Support VIs enter Dynamic Synchronization Mode. In this mode, the properties of the elements on the front panel of the Target VI are continuously synchronized with those in the browser.

LabSocket Overview
LabSocket System Overview

Messages between the browser and Support VI pass via a Message Broker on the LabSocket Server platform. Of special note is the WebSocket interface between the browser and Message Broker that enables continuous, bi-directional communication with the browser. The use of this interface contributes to the system name: "LabSocket = LabVIEW + WebSocket".

LabSocket: A LabVIEW-based Web Authoring Tool

The original purpose of the LabSocket system was to simply allow LabVIEW developers to make applications available over the web. A new version of the system named "LabSocket-MultiClient" now exists in which each browser client is connected automatically to a unique instance of the LabVIEW Target VI. With this one-to-one mapping between browser and Target VI instance, the combination of LabVIEW and LabSocket permits the easy and rapid development of dynamic web applications.

LabSocket Overview
LabSocket-MultiClient System Overview

The following figure illustrates the LabSocket-MultiClient system in action as a web authoring tool. In this figure, the simple math quiz application described earlier is used as the Target VI and three browsers have been pointed to the URL for the VI. Note that the browsers are operating independently from each other as evidenced by the fact that the quiz data, and the user scores, in each browser are different. Each browser shows the same time stamp value since the quiz VI always displays the current time on the front panel.

Distinctly different application states are also evident in this figure - the browser in the center is waiting for the user to enter quiz data and press the "Submit" button while the left and right browsers are waiting for the user to press the "Next" button to begin another round of the quiz.

Real-World Applications

On-line Quizzes for Engineering Students
The LabSocket system has been purchased by, and is currently undergoing evaluation at, a university in California for the purpose of creating on-line quizzes for engineering students. The primary motivation for the use of on-line quizzes at this school is that it enables the implementation of automated quiz grading which in turn eliminates the time and effort required to manually grade quizzes. As an added benefit, the fact that the quizzes can be configured such that each student receives unique content in their quiz, greatly reduces the chances of student cheating.

The LabSocket system is an attractive solution to this customer primarily because the professors developing the quizzes are comfortable with creating LabVIEW applications, but do not have the resources to rapidly create web applications. The system therefore enables the professors to create on-line quizzes and auto-grading algorithms themselves without the help of scarce web developer talent.

In the bigger picture, this application serves as a good example of the use of the LabSocket system as a solution to the "Engineer Crunch" problem. It shows that the system can enlarge the pool of talent available to create web applications by allowing non-web experts to create sophisticated, dynamic web applications.

Additional information about the use of LabSocket in this application will be released after the system enters production.

SportJury - Ski Competition Judging Application
An early prototype of the LabSocket-MultiClient system was used in 2011 by Dynasys, D. Kölliker (www.dynasys.ch), a Swiss custom LabVIEW development firm, to create SportJury, a mobile, multi-user application for judging ski competitions.  The primary objectives of SportJury were to improve the accuracy of score data entry and speed the aggregation of judge scores relative to previous paper based systems.

The comments of Daniel Kölliker, owner of Dynasys, D. Kölliker echo the above-mentioned benefit of LabSocket as a productivity enhancing tool for web application development:

“For SportJury, we could have created a native application for the mobile component of the system, but that would have required either contracting out to a specialized development firm or going up a learning curve for native application development.”

“Instead, since Dynasys has a long history of developing complex LabVIEW applications, we decided to employ Bergmans Mechatronics’ LabSocket system to allow us to create the client software as LabVIEW VIs and then to extend these VIs to the browsers on the iPod touch devices.  This approach allowed us to rapidly and inexpensively develop the mobile component and to write all of our code in-house in LabVIEW.”

This White Paper (PDF, 0.3 MB) provides details of the use of the LabSocket in the SportJury application.

Contact

If you have any questions about the LabSocket system and how it could be used to address the "Engineer Crunch" or would like to arrange for a live on-line demo, please contact me or leave a comment below.

John Bergmans
Bergmans Mechatronics LLC
e: jbergmans /at/ bergmans \dot\ com
t: @jbergmans

comments powered by Disqus

 

Back to Top of Page Top