Example Code

Webinar Example Code, Build a Web App for Your Test System

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • G Web Development Software
  • LabVIEW

Code and Documents

Attachment

Third-Party Code Repository

Some users manage their code in repositories outside of ni.com. Use your best judgment when following links to third-party sites. https://github.com/ni/webvi-examples

Description

This example is the finished example created during the "Build a Web App for your Test System" webinar. It includes the following examples

- Test System Code Modified with the SystemLink API

- Web App (WebVI) Example Code

 

In the webinar, we talked about building a web application for your LabVIEW, C#, or Python test system. We showed a brief step-by-step tutorial of creating a WebVI, a complete test system with SystemLink APIs for data communication and how to deploy your webVI to SystemLink Cloud.

 

 

How to Use

To run these examples you will need:

 

Test System

-LabVIEW

  • Example Code Supports LabVIEW 2016+
  • Download and install at NI.com or NIPM

-SystemLink API (Free)

  • LabVIEW SystemLink Toolkit
    • Download and install at NI.com or NIPM

-NI MAX

  • Simulated Hardware
    • cDAQ 9171 with and NI-9213

 

Hosting

-SystemLink Cloud (Free Trial)

 

Web Application

-G Web Development Software

  • Download at NI.com or use NIPM
  • Purchase includes SystemLink Cloud access

 

General Instructions on Running the Examples

 

  • Test System Code

1. Open the Test System code in LabVIEW

2. Examine the addition of the SystemLink APIs

3. Add Simulated Hardware in NI MAX

1. Open NI MAX

2. In the Left Panel, right-click on Devices & Interfaces and select New

3. In the Create New… Wizard, select Simulated NI

4. DAQmx Device or Modulated Instrument, and then select Finish

5. In the Create Simulated NI DAQmx Device window, search for a 'cDAQ-9171' and then select 'OK'

6. Select the just created simulated device. Then go to Configure Simulated cDAQ Chassis and then scroll to a NI 9213.

7. In the example code, this should already be configured and selected as cDAQ1Mod1/ai0. If not, configure accordingly.

4. Go to SystemLink Cloud and create a trial account.

5. In SystemLink Cloud go to Manage Security and create a new API key (make sure to copy this to the clipboard!)

1. Replace the API key in the example code with your new API key 

6. Run the Test System Code

1. The SystemLink APIs will automatically create new tags

2. Ensure these tags get created and are updating by going to SystemLink Cloud.com then >> Data >> Tags.

 

  • Web App (WebVI) Code

1. Open G Web Development Software and load the example code associated with the Test System Example Code chosen

2. Examine the Diagram of the WebVI and notice how the SystemLink API is used

3. Enter the API Key and Server URL

4. Create a Package of the WebVI by 

1. In the left-hand Project Pane, right-click the .gcomp and select Create Package/Installer with item. This will create a .lvdist.

2. In the right-hand Document Pane while the .lvdist is open, change the Output Type to Package

3. Select Build in the right-hand Document Pane or select the hammer at the top toolbar to build the Package

 

  • Hosting on SystemLink Cloud

 

1. Go to Systemlinkcloud.com

2. Navigate to Visualizations >> WebVIs

3. Select Upload in the upper right-hand corner. Upload the package you created in the previous steps

4. Once the package is uploaded, you can choose your sharing permissions by selecting the 3 dots to the right of your package, and select Share. 

1. For this example and we recommend keeping it private, meaning only your account can access it

2. If you have specific people you want to share your WebVI with, add their email addresses to the list

3. If you'd like to make it public to anyone who has the link, type in "Everyone".

 

  • Running the Examples 

1. Start the Test System Code.

2. Open the WebVI you uploaded to SystemLink Cloud

3. View the data coming in on the WebVI. Change the values on the WebVI to see those new limits change on the Test System code.

1. Bonus: Try opening the WebVI on your mobile phone! 

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors