Part 6: Displaying RT Data on the User Interface

In this part of the tutorial, you use network streams to receive RT target data over the network. You also display the data graphically on the user interface. Visit ni.com/info and enter EmbUIOptions to learn more about creating interfaces for displaying RT target data.

Configuring the Network Stream Reader

To configure a network stream for receiving data, you must specify the reader name, data type, and reader buffer size. These properties specify the endpoint reading the data, the type of data being read, and how much data to read. You also specify a time limit, which specifies how long the reader endpoint waits for data.

Complete the following steps to configure a Create Network Stream Reader Endpoint function:

  1. Add a Create Network Stream Reader Endpoint function to the block diagram of Windows Main.vi.
  2. Delete the error wire between the error in constant and the left error tunnel of the While Loop.
  3. With Stop Application selected in the Event structure selector label, connect the error wires sequentially between the error in constant, the Create Network Stream Reader Endpoint function, and the Active? variable.
  4. Right-click the reader name input of the Create Network Stream Reader Endpoint function and select Create»Constant from the short-cut menu.
  5. Enter HostDataReader as the constant to name the reader endpoint.
  6. Wire a DBL Numeric Constant to the data type input of the Create Network Stream Reader Endpoint function.
  7. Right-click the timeout in ms input of the Create Network Stream Reader Endpoint function and select Create»Constant from the short-cut menu.
  8. Enter 1000 as the constant to specify that the reader waits one second for new data before passing execution to the next part of the VI.
  9. Right-click the reader buffer size input of the Create Network Stream Reader Endpoint function and select Create»Constant from the short-cut menu.
  10. Enter 4096 as the constant.

Creating a Control to Specify the RT Target

Before a network stream can read data, it needs the IP address or hostname of the RT target sending the data.

Complete the following steps to create a control on the front panel to specify the IP address of your RT target:

  1. Add a Concatenate Strings function to the left of the Create Network Stream Reader Endpoint function.
  2. Expand the Concatenate Strings function to include three inputs.
  3. Right-click the top input of the Concatenate Strings function and select Create»Constant from the short-cut menu.
  4. Enter // as the constant.
  5. Right-click the bottom input of the Concatenate Strings function and select Create»Constant from the short-cut menu.
  6. Enter /RTAcqData as the constant to specify the writer endpoint.
  7. Add a string control to the front panel.
  8. Name the string control Target IP Address.
  9. In the Target IP Address text box, enter the IP address for your RT target.
    Note   Any time you reopen the application, ensure that the IP address you enter in the front panel matches the IP address of your RT target. Depending on your network settings, the IP address of your RT target may change.
  10. In the block diagram, wire the Target IP Address control to the middle input of the Concatenate Strings function.
  11. Wire the concatenated string output of the Concatenate Strings function to the writer URL input of the Create Network Stream Reader Endpoint function.

Receiving Streaming Data from the RT Target

Similar to the network streams writer endpoint, the reader endpoint requires a Read Single Element from Stream function and a Destroy Stream Endpoint function to receive data.

Complete the following steps to complete the networks streams reader endpoint in Window Main.vi:

  1. With Timeout selected in the selector label, place a Read Single Element from Stream function within the Event structure.
  2. Add a Destroy Stream Endpoint function outside and to the right of the While Loop.
  3. Delete the error wire between the While Loop and the error out indicator.
  4. Delete the error wire within the Event structure.
  5. Connect the error wires sequentially between the Create Network Stream Reader Endpoint function, the Read Single Element from Stream function, the Destroy Stream Endpoint function, and the error out indicator.
  6. Wire the reader endpoint output of the Create Network Stream Reader Endpoint function to the endpoint in input of the Read Single Element from Stream function.
  7. Wire the endpoint out output of the Read Single Element from Stream function to the endpoint in input of the Destroy Stream Endpoint function.

Displaying the Data in the Front Panel

To display the data from the RT target on the UI, you can use a waveform chart.

Complete the following steps to display the data from the RT target on the Windows Main.vi front panel:

  1. Right-click the data out output of the Read Single Element from Stream function and select Create»Indicator from the short-cut menu.
  2. In the front panel, right-click the data out indicator and select Replace»Silver»Graph»Waveform Chart from the short-cut menu.
  3. In the block diagram, right-click the Boolean tunnel in the Event structure and select Create»Constant from the short-cut menu.
  4. Specify a False constant.
  5. Save the VI.
  6. Run Real-Time Main.vi.
  7. Run Windows Main.vi.

The front panel should match the following image.