Code Reuse in LabVIEW NXG


With rapidly changing test requirements and shortening tester project development cycles, it is even more critical that you and your team gain the most reuse possible from existing test software and measurement libraries. So why aren’t more test engineers reusing software more often? Here are the responses we hear most from test groups:
  • There is legacy software developed by someone that is no longer in the group or in the company; and it is working, so there is significant risk and expense in changing the unknown.
  • There are tool and language personal preferences or group standardization across test and validation engineering teams; therefore, it is difficult to reuse code modules because the tools or software to use for a past project don’t translate to what we are using today.
  • There is a need to maximize software reuse and build abstraction layers or frameworks, but this is expensive and time-consuming. With short-term project demands, the focus on how to enable reuse standards and best practices is continuously being deferred.

The challenges of balancing longer term standardization benefits with existing code and software skills or preference is real. To help address this difficult balance, LabVIEW NXG as an open platform was designed to help you integrate all your test hardware and software systems together.

In LabVIEW NXG, you can combine multiple programming approaches alongside graphical data flow (G) in a single application. Use this flexibility to select your tool of choice for creating device under test (DUT) control, configuration, or measurement libraries. LabVIEW NXG integrates multiple languages, like C, into your application and interoperates with other software running locally or on the network to reduce your team’s time to success.



Calling Existing DLLs

In addition to importing source code onto a LabVIEW NXG block diagram, you can reuse existing applications and algorithms developed in other languages by calling them from a LabVIEW NXG application. For instance, if you have an existing C/C++ shared library and need to reuse it in LabVIEW NXG, you can call it using the Shared Library Interface (SLI). To make importing external libraries simple, LabVIEW NXG includes the Shared Library editor, which assists you in building a LabVIEW NXG SLI for incorporation onto the LabVIEW NXG block diagram.

Figure 1: Use the Shared Library editor to map existing libraries for use in LabVIEW NXG.

Figure 2: Use the Shared Library Interface to reuse existing C or C++ shared libraries in-line with G programming.

Integrate C Code

Use the C Node to import, write, and execute your existing C code with a familiar text-based development experience including function auto-complete and context help. You can call functions from the following libraries in the C Node:

  • ANSI C Library
  • Analysis Library

For more information, see the C Node Overview.

Figure 3: Use the C Node to integrate and edit C code in LabVIEW NXG.


Interface with MATLAB® Code

To enable complete reuse of your existing MATLAB® code, LabVIEW NXG includes an Interface for MATLAB. Developers can point to their MATLAB function or script saved on their computer and connect it to their LabVIEW block diagram. The Interface for MATLAB has full support for MATLAB toolboxes, as it calls into a licensed copy of the MATLAB software installed on the same computer as LabVIEW NXG.

Reference the Interfaces for MATLAB Help Topic for more details.


Call Registered .NET Assemblies

The .NET Framework allows you to access Windows services such as the performance monitor, event log, and file system as well as advanced Windows APIs. Or you may have existing .NET code or drivers that you wish to reuse in your LabVIEW NXG application. You can integrate a .NET assembly from the Global Assembly Cache (GAC) into your LabVIEW NXG application using the .NET Interface Document (.dni). 

Select the .NET namespaces and classes you want to use in your application and then new palette items are created for them that you can access from your .gvi block diagram. These new palettes contain properties and methods that are entry points to the .NET assemblies and can be wired like nodes in your code to exchange data.

Figure 4: Use the .NET Interface Document in LabVIEW NXG to incorporate .NET Assemblies from the Global Assembly Cache (GAC).


Reuse Python Code with LabVIEW NXG and LabVIEW

The Python programming language has grown in popularity across virtually all industries and is becoming increasingly used in test and measurement applications. What has helped make Python appropriate for the test and measurement space is its ability to integrate with NI hardware and software to leverage its scripting strengths with NI's rich measurement expertise. 

Click here to learn about all the available Python Resources for NI Hardware and Software.

Additional Resources