1. Creating a Dashboard
Open Data Dashboard 2.0 on your device. When the app opens you will see the screen shown below. This main view is the dashboard carousel, you can use the dashboard carousel to manage your dashboards. To create a new dashboard tap the "+" sign at the bottom of the carousel and select New Dashboard.
You will then be prompted to choose the orientation of your dashboard, Portrait or Landscape. For this tutorial you can select either option.
Your new dashboard will open and appear as below. To place an indicator on the dashboard tap the Controls and Indicators Icon and select Indicators. This will open the indicators pallet.
To place an indicator on the dashboard drag it from the pallet onto the page. For this example we want to drag a Chart and a Numeric on to the page.
The next step is to link the indicators to the data connections. The processes for linking Network Published Shared Variables and Web methods are described in the following sections.
2. Deploying Shared Variables
Before you can link your dashboard controls and indicators you need to have variables to connect to. If you already have network-published shared variable deployed, you can move to the next section, Connecting to Shared Variables. To deploy network-published shared variables you will need to create a project in LabVIEW.
- In LabVIEW select File>>New Project to create a new LabVIEW project
- Add a shared variable to the project. Right-click My Computer in the Project Explorer window and select New>>Variable.
- Right-click the shared variable and select Rename. Rename the shared variable DDVariable1.
- Right-click My Computer and select New>>VI to create a new VI and add it to the project. This VI will periodically update the shared variable value with a random number.
- Save the project.
- Add a While Loop to block diagram of the VI.
- Place a Random Number (0-1) function and a Wait (ms) function inside the While Loop.
- Right-click the input terminal of the Wait (ms) function and select Create>>Constant. Set the value of the constant to 500 to update the value every half second.
- Drag the shared variable you created from the Project Explorer window onto the block diagram. Right-click on the shared variable and select Access Mode>>Write.
- Wire the output terminal of the Random Number (0-1) function to the input terminal of the shared variable.
- Right-click the input terminal of the stop terminal and select Create>>Control, to create a button for stopping and starting the program. Your block diagram should resemble the following example.
- You must deploy the shared variable before you can display its value in the Data Dashboard. In the Project Explorer window, right-click the project library that contains the shared variable and select Deploy.
- Build and run the application to continuously update the shared variable.
3. Connecting to Shared Variables
Now that you have placed your indicators and deployed your network-published shared variables you can link your dashboard to your shared variables.
- Tap the Chart indicator and select the Data Link icon shown in the following image. This will open the Connect dialog.
- Select Shared Variables in the Connect dialog. Then, enter the Shared Variable server DNS or IP address as shown in the following image. Tap Connect to connect to the Share Variable Engine.
- Tap the name of the library that contains the deployed shared variable. Then, select your shared variable, as shown below. The data type of each shared variable is listed below the variable name.
- Repeat steps 1-3 for your Numeric indicator. Data Dashboard 2.0 only allows you to select shared variables that are compatible with the data type of the selected indicator. In this example, the deployed Shared Variable is a double-precision floating point number, which you can display using a Chart or Numeric indicator.
- You can customize the chart's appearance by selecting the properties menu shown below.
- Run the dashboard by selecting Play in the upper right hand corner. The running dashboard should appear similar to the following image.
4. Deploying Web Services
In this section of the tutorial you will be creating a Web Service and a Web method to connect your data dashboard. The following steps describe the process of building a Web Service with LabVIEW.
- Create a new LabVIEW project.
- Name the project Data Dashboard Demo.
- Add a new VI to the project. Name the VI DDDemo-Method.
- Place a Random Number (0-1) function on the block diagram.
- Right-click on the output terminal of the Random Number (0-1) function and select Create>>Indicator.
- Edit the indicator label and rename the indicator as DDVariable1, as shown in the following image.
- Assign the indicator to a connector pane terminal for the VI so that the Data Dashboard can monitor the output of the Web method VI.
- On the front panel, select a connector pane pattern.
- Click a terminal of the connector pane. The terminal turns black.
- Click the DDVariable1 indicator on the front panel. A marquee highlights the indicator and the terminal changes to the data type color to indicate you connected the terminal, as shown in the following image.
- Save the project.
- Create a new Web service. Right-click Build Specifications in the Project Explorer window and select New>>Web Service (RESTful). Refer to LabVIEW Help: Building and Accessing a LabVIEW Web Service Application if you need a more detailed instructions on creating a LabVIEW Web service. Note: The instructions in this tutorial are for LabVIEW 2012 and earlier versions of LabVIEW. If you are using LabVIEW 2013 or later, create a web service based on LabVIEW Help: Building and Accessing a LabVIEW Web Service Application.
- On the Information page, select the name of the Web service and its destination directory. Use the default settings.
- On the Source Files page, use the Add Item arrow to move the VI you created from the Project Files tree to the Service VIs tree.
- In the Configure RESTful VI dialog box, specify the following settings for the Web method VI.
- Build the project.
- Right-click on Data Dashboard Demo build specification in the Project Explorer window and select Deploy to deploy the Web service application.
5. Connecting to Web Services
Now that you have placed down your indicators and deployed your Web Service, you can link your dashboard indicators to your Web methods. There are two ways to connect to a Web method, polling and calling. Polling a Web method calls the Web method continuously every .3 to 30 seconds as specified by the user. Calling a Web method only calls the Web method when the Call button is pressed. For this tutorial, we will use a polling connection to continuously populate the data on our chart and indicator.
- Tap the Controls and Indicators icon and select LabVIEW Web Services.
- Drag a Poll Web Service to the dashboard and select the Web Link icon.
- The Web Services connection dialog will open and you will be able to enter the server DNS or IP address, and Port of your Web Service. Tap Connect.
- Next, you will see a display of Web Services hosted on your target. Choose your Web Service and then, the Web Method you want to link to your poll.
- When the Web method connects successfully, you will see the Web Link icon turn green. To link your Poll to an indicator select the adorner of the variable you want to link.
- You will now see an overlay that shows you which indicators on the dashboard that you can link to your variable. Tap the Chart to link the your Web method variable to the chart indicator. You can also choose to create a new indicator from the overlay.
- When you finish linking your Web method variable, you will see the mappings as shown below.
- Repeat steps 1-7 to link your Numeric indicator to your Web method. Run your dashboard. The running dashboard should appear similar to the following image.