Monitoring a Measurement Studio Windows Application with Network Variables and the Web

Publish Date: Nov 13, 2012 | 47 Ratings | 1.00 out of 5 |  PDF

Overview

In this tutorial, you will take an existing Measurement Studio Windows application and monitor it with a Measurement Studio Web application. Before completing this tutorial, you need to complete the Adding Network Variables to a Measurement Studio Windows Application tutorial.

Table of Contents

  1. Exercise
  2. Next Steps

1. Exercise

You will now create a Web application to monitor the Measurement Studio Signal Filtering Windows application.

  1. Select File»New»Web Site. The New Web Site dialog box launches.

     
  2. In the Templates window, select NI ASP.NET Web Site. For the Location, select File System and specify a file path you wish to save to by clicking Browse and navigating to the directory of your choice.
  3. Use the drop-down box to select Visual C# or Visual Basic, depending on your language preference.
  4. Click OK. The Measurement Studio ASP.NET Web Site Wizard launches.
  5. Select Analysis, Network Variable Communication, and Web Forms User Interface Controls.  This will automatically add the appropriate Measurement Studio assemblies to your project.

    Note The exact name of the Analysis library depends on which edition of Measurement Studio is installed.

  6. Click Finish to display Default.aspx in the Web Forms Designer.
  7. You can rename the title of your Web page. Click inside the <title> tag and rename the title to Signal Filtering.

Configuring Network Variables for Web Applications

  1. Click Design in the lower left corner to switch from Source View to Design View.
  2. Select View»Toolbox to display the Toolbox. Over 15 Web Forms controls are available with Measurement Studio.
  3. Expand the Measurement Studio group in the Toolbox.

  4. Select the NetworkVariableDataSource control in the Toolbox and drag and drop it on the form. The Web Forms NetworkVariableDataSource can bind to the same network variables used in a Windows Forms application.
  5. Click the NetworkVariableDataSource smart tag and select Edit Bindings to launch the NetworkVariableBinding Collection Editor dialog box.

    Tip To access the smart tag, left click on a control to select it and then left click on the arrow button in the upper right corner of the control.

     

  6. Select Add.
  7. Add the OriginalSignal network variable by setting the following options on the NetworkVariableBinding Collection Editor: select Read for BindingMode, Object for BindType, set DefaultReadValue to 0, and type OriginalSignal for Name. 

  8. For the Location, browse to the \\localhost\Signal Filtering\OriginalSignal path in the Select Network Item dialog box. Click OK.

  9. Add the FilteredSignal network variable by setting the following options on the NetworkVariableBinding Collection Editor: select Read for BindingMode, Object for BindType, set DefaultReadValue to 0, and type  FilteredSignal for Name. 
  10. For the Location, browse to the \\localhost\Signal Filtering\FilteredSignal path in the Select Network Item dialog box. Click OK.

  11. Add the Cutoff network variable by setting the following options on the NetworkVariableBinding Collection Editor: select ReadWrite for BindingMode, Object for BindType, set DefaultReadValue to 0, and type  Cutoff for Name. 
  12. For the Location, browse to the \\localhost\Signal Filtering\Cutoff path in the Select Network Item dialog box. Click OK.

Adding ASP.NET Controls to the Web Interface

  1. Expand the Data group on the Toolbox. Select the FormView control and drag and drop it on the Designer.
  2. Click the FormView smart tag and select  NetworkVariableDataSource1 from the Choose Data Source drop-down list.

    Note You can bind controls to network variables by using the Microsoft Form View control.  The Form View control is a container that binds to a set of network variables, and each control that is placed in the Form View control can access the associated network variable.

  3. On the FormView smart tag, select Edit Templates. Select Item Template from the Display drop-down list.

    Note The controls placed in the Item Template will be displayed on the Web site. You can drag and drop the ASP.NET controls you want to use into the template view.

  4. Delete the default contents of the Item Template. To better visualize measurement data, we will use the Measurement Studio graph and slide controls.

  5. Select the WaveformGraph control in the toolbox and drag and drop it on the form.
  6. Click the WaveformGraph smart tag and select Edit DataBindings to launch the NetworkVariableBinding Collection Editor dialog box.
  7. Enter Original Signal for the Caption.

  8. In the Edit Bindings Collection Editor dialog box, bind the waveform graph to a network variable by setting the Bound to option to OriginalSignal from the drop-down list.

  9. Click  OK.
  10. Repeat steps 5 through steps 9, but bind WaveformGraph2 to FilteredSignal and enter Filtered Signal for the Caption.
  11. The following image shows the final result.

Setting Up the Edit FormView

  1. Set the Display option to EditItemTemplate  on the FormView smart tag .

  2. Note You can non-programmatically write to network variables with controls placed in the EditTemplate view. You can have controls write to network variables and controls that read from network variables all on the same view if you programmatically bind the controls to network variables.

  3. Delete the text boxes from the EditItemTemplate view.

     

  4. Drag a Slide from the Measurement Studio group in the Toolbox onto the EditItemTemplate, next to Cutoff label.
  5. Click on the slide smart tag and select Invert Orientation.
  6. Change the Range of the slide to 0,50.

  7. Click the slide smart tag and select Edit DataBindings to launch the NetworkVariableBinding Collection Editor dialog box.

  8. In the Edit Bindings Collection Editor dialog box, bind the slide to a network variable by setting the Bound to option to Cutoff from the drop-down list.

  9. Select OK. The following image shows the final result.

     

  10. Select End Template Editing on the FormView smart tag.

     

  11. Select the AutoRefresh control in the Toolbox and drag and drop it on the form. You can use the AutoRefresh control to update a Web control or a group of Web controls on the client at a specified interval.

  12. Click the AutoRefresh smart tag and check Enabled. Set Interval to 00:00:01.000 to refresh the page every second. Select Edit Default Refresh Items to launch the RefreshItem Collection Editor dialog box.

  13. Select Add. Enter WaveformGraph1 for the ItemID.

  14. Select Add. Enter WaveformGraph2 for the ItemID.

  15. Select Add. Enter Slide1 for the ItemID and click OK.

  16. The following image shows the final FormView control.

Running the Web Site

  1. Select File»Save Default.aspx to save your application.
  2. Select Debug»Start Without Debugging to run the application. This will launch your program in your default Web browser.

    Note Visual Studio includes a built-in test Web server.  When you run the application, the built-in ASP .NET
    Web server loads the previously designed Web site.

  3. Run the Signal Filtering Windows application.

  4. Select the Edit button on the Web site.

  5. Change the value of the slide to 20. This sets the cutoff frequency displayed in the Signal Filtering Windows application from the web.filter in the Windows Form from the Web Form.

Back to Top

2. Next Steps

 

Back to Top

Bookmark & Share

Ratings

Rate this document

Answered Your Question?
Yes No

Submit