Have you tried building user interfaces with the Web Module in LabVIEW NXG? In this blog post, Poul Lindholm Pedersen, PhD in Physics, provides an overview of the possibilities.
One of the major innovations in LabVIEW NXG is the Web Module. The Web Module enables you to create web pages directly in LabVIEW and makes the transition between VIs and the internet much simpler. This is done through the new webVIs, where you can essentially turn the front panel into a web page while retaining the block diagram’s functionality.
WebVIs
The advantage of webVIs is that, as a LabVIEW developer, you can easily create a web page without having to worry about HTML, CSS, JavaScript, etc. It is easy to connect a webVI to a standard VI, so you can readily create a more modern user interface for your application that can be accessed from anywhere. Unlike web publishing in earlier versions of LabVIEW, webVIs do not require any downloads to work—any browser will be able to open it.
In many ways, webVIs work like standard VIs. The usual controls on the front panel have been replaced by widgets, but the visual appearance is exactly the same. When the webVI is compiled, the front panel is translated into HTML/CSS, and the block diagram is translated into JavaScript. Since the entire web page consists of HTML and JavaScript, it is also easy to modify the code outside of LabVIEW, and you can also add third-party widgets through the built-in JavaScript Library Interface.
To make webVIs compatible with mobile devices and tablets, the Web Module makes it easy to scale the front panel so the page can be viewed on screens of all sizes. In practice, this is done by grouping widgets into boxes that dynamically adapt to the screen size.
Data services
In addition to webVIs, the Web Module also provides various data services, allowing the web page to connect to, for example, a backend. There is currently the option to use three different APIs: HTTP, WebSocket, and SystemLink. HTTP is the well-known internet protocol, and from a webVI you can access any API that meets REST requirements. WebSocket is a continuous TCP connection and, unlike the HTTP protocol, it is full duplex. This means data can be transmitted in both directions at the same time. SystemLink is NI’s service for integrating and managing distributed systems.
HTTP is a good all-round choice, as it offers high flexibility and is widely used. WebSocket is well suited for streaming and low-latency communication, but can be more cumbersome to implement on the server side, as there is not yet a solution where security has been implemented. SystemLink is well suited for communication between LabVIEW applications or with an NI Web Server.
NI Web Server
NI Web Server is also part of the Web Module, and it allows you to set up a server that can host a webVI. One of the most important features is that the server has built-in security configuration, so you can secure access to your user interface. As an alternative to NI Web Server, you can also host your webVI through SystemLink Cloud, avoiding the need to maintain a server yourself.