Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
What is Developer Zone?
United States

Document TypeTutorial
NI Supported: Yes
Publish Date: Apr 13, 2012


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links -Products and Services

NI Measurement Studio 8 - Extensible Architecture and .NET Measurement Designers Deliver Flexibility and Robust I/O Connectivity

18 Ratings | 4.11 out of 5
 Print |  PDF

Overview

Microsoft Visual Studio tools add power for text-based programmers, but can introduce complexities for engineers and scientists creating test and measurement applications. In order to efficiently develop applications within object-oriented, general-purpose Microsoft languages, such as Visual Basic .NET and Visual C# .NET, engineers look to Visual Studio add-ins to provide measurement and automation-specific tools. NI Measurement Studio delivers the native tools to dramatically reduce application development time including scientific user interface controls, measurement hardware classes, code-generating assistants, robust analysis class libraries, wizards, templates, and highly extensible .NET classes and user interface controls.

Table of Contents

  1. Write Less Code
  2. Measurement Studio 8 – Managed .NET Classes
  3. Measurement Studio Class Libraries
  4. Measurement Studio Integrated Tools and Help
  5. Acquire with NI Measurement Studio
  6. Analyze with NI Measurement Studio
  7. Present with NI Measurement Studio
  8. Extensibility
  9. Compatibility with NI TestStand
  10. Conclusion

Write Less Code


Measurement Studio is an integrated suite of native measurement and automation tools and class libraries for Visual Studio .NET.

Without NI Measurement Studio, you could spend weeks or months developing measurement-specific components and understanding low-level hardware connectivity. Valuable engineering time is wasted on programming classes and creating user interface controls instead of testing digital devices, developing automated manufacturing processes, or designing new protocols. For example, to set up a typical, yet simple, instrument connectivity application, an engineer or scientist must develop and understand more than 200 lines of code; simply to connect to and establish communication with an instrument in Visual Basic .NET. With Measurement Studio tools, the same professional can communicate with an instrument by using a Measurement Assistant and writing just one line of code.

Measurement Studio 8 – Managed .NET Classes

Just as Microsoft rewrote the Visual Studio languages for the .NET Framework, NI completely rewrote Measurement Studio with a new architecture to deliver native measurement and automation tools for optimal .NET development. Because of the true object-oriented nature of Visual Studio .NET, Measurement Studio controls and classes are designed for maximum customization through extensibility. An engineer can use a Measurement Studio base class as a foundation for extensibility and then inherit from and extend it to create customized classes such as a proprietary I/O bus communication interfaces.

In addition to porting most of the functionality from the previous version, Measurement Studio 8.1 also includes new features such as interactive graph zooming and panning, DataSocket architecture enhancements, more customizable properties, signal generation, code-generating measurement assistants, dynamic help capabilities, an optimized data acquisition driver, and tighter test management integration.

This paper will detail all of the new classes and components, as well as walk you through how Measurement Studio reduces the complexity of the fundamentals of any measurement application – acquisition, analysis, and presentation.

Measurement Studio Class Libraries


The Measurement Studio class libraries are designed specifically for engineers and scientists who build virtual instrumentation systems with Visual Basic .NET or Visual C# .NET in Visual Studio .NET. With integrated libraries for acquiring, analyzing, and displaying data, Measurement Studio includes everything you need for building advanced measurement and automation applications.

Measurement Studio provides the following .NET class libraries:

  • Analysis
  • Common
  • Network Variable 
  • NI-488.2
  • NI-DAQmx
  • NI-VISA
  • User Interface

Easily add references to the Measurement Studio .NET assemblies through the Measurement Studio project wizard.
 

Measurement Studio Integrated Tools and Help

The Measurement Studio tools integrate natively into Visual Studio .NET so you can use them exactly as you would Microsoft tools. Measurement Studio dramatically reduces application development time with project templates, wizards, and hardware API assistants.

 

  • Project templates create projects, according to your specifications, containing the Measurement Studio libraries and tools you need to design your measurement application.
  • Add/Remove class libraries wizard quickly adds or removes references to Measurement Studio class libraries from a project.
  • Hardware API assistants – NI Instrument I/O Assistant and NI DAQ Assistant – to interactively define reusable measurement and generation tasks and automatically generate code for your project.
  • Parameter Assistant discovers and inserts valid parameter values into your code for DataSocket, DAQ, GPIB, and VISA methods.

The Add New Item Wizard helps you add Measurement Studio components for DAQ and instrument control to your project.

NI Measurement Studio Help
As you work with Measurement Studio, you might need to consult other resources. For detailed Measurement Studio help, including function reference and in-depth documentation on developing with Measurement Studio, refer to the NI Measurement Studio Help within the Visual Studio .NET environment. NI Measurement Studio Help is fully integrated with the Visual Studio .NET help so that you can quickly access helpful information as you develop.

As you develop with Measurement Studio, you can use the context-sensitive help to quickly access function reference. You can use the following types of context-sensitive help:

  • F1 help – As you write code, put your cursor in a function name and press <F1> to access the function reference for that function.
  • Dynamic Help window – As you write code, the Visual Studio .NET Dynamic Help window updates to display links to relevant topics about the Measurement Studio class libraries. To view the Dynamic Help window in Visual Studio .NET, select Help»Dynamic Help.


Measurement Studio help is fully integrated in the Visual Studio .NET environment giving you quick access to design-time help information.

Acquire with NI Measurement Studio

Whatever you use to acquire your data – a GPIB, USB, or serial instrument, a plug-in data acquisition device, PXI hardware, or a modular instrument – Measurement Studio provides a high-level interface for your hardware that is native to your development language. In addition to the interfaces, Measurement Studio also provides innovative, code-generating hardware API assistants that you can use to quickly create measurement applications.

Shorter Time to Meaningful Measurements
Because hardware communication is often the most challenging component of any measurement application, Measurement Studio delivers rich, object-oriented hardware class libraries for high-level, intuitive interfaces to GPIB, VISA, and DAQ driver interfaces. These class libraries offer more than just basic instrumentation connectivity through:

  • Rich, object-oriented DAQ, GPIB, and VISA class libraries for Visual Basic .NET and Visual C# .NET
  • A powerful multithreaded DAQ driver with an intuitive API


While these interfaces simplify data acquisition and instrument connectivity processes by abstracting the low-level driver details, Measurement Studio extends these capabilities with two code-generating assistants and a native interface to the redesigned NI-DAQ driver framework (NI-DAQmx). These extensions help engineers and scientists write measurement applications faster than ever.

The Instrument I/O Assistant and DAQ Assistant, which are integrated into the Visual Studio .NET environment, allow you to interactively configure, test, and generate Visual Basic .NET or Visual C# .NET source, all before typing a single line of code.

Data Acquisition (DAQ)
Use the native .NET class libraries for NI-DAQmx with National Instrument DAQ hardware to perform the following types of tasks:

  • Analog signal measurement
  • Analog signal generation
  • Digital I/O
  • Counting and timing
  • Pulse generation
  • Signal switching


Measurement Studio also provides the following productivity tools to accelerate development and enable more powerful DAQ applications:

  • DAQ Assistant – Provides a user interface to interactively configure measurement tasks, channels, and scales. It is fully integrated into Visual Studio .NET. The DAQ Assistant simplifies the challenge of writing DAQ applications by automatically generating code from your configurations in Visual Basic .NET or Visual C# .NET.
  • Parameter Assistant – With this assistant, you can discover and insert valid parameter values into your code for DAQ methods. Parameter Assistant displays the current DAQmx devices on the system, the current DAQmx channels on the system, the current DAQmx scales on the system, the current DAQmx tasks, the current DAQmx terminals, the current DAQmx triggers, the current DAQmx switches, and the current DAQmx virtual channels.


DAQ Assistant provides an interactive interface to configure measurement tasks, channels, and scales. It is fully integrated into Visual Studio .NET.


Instrument Control
In addition to data acquisition, Measurement Studio provides a native .NET interface to NI-VISA and NI-488.2.

GPIB
The .NET NI-488.2 class libraries include a set of classes that communicate with IEEE 488 (GPIB) instruments and control GPIB interface devices. Use these libraries to design code that communicates with and controls instruments on a GPIB bus. Use the classes in these libraries to perform the following operations:

  • Configure and communicate with GPIB instruments and devices.
  • Perform I/O operations using the Device and Board classes.


You can use the NI-488.2 class library to create programs that interface with a device that is using GPIB and/or programs that perform low-level control of the bus using a National Instruments GPIB interface device.

VISA
If your test measurement system uses VXI, serial, USB, or GPIB instruments, you can use the unified instrument control API of the VISA library to create a program that controls all of your instruments, regardless of the interfaces that your instruments use.

The Measurement Studio NI-VISA class libraries include classes that provide an object-oriented interface to the NI-VISA driver. Use these NI-VISA class libraries to quickly create instrument control applications. Using the unified NI-VISA API, you can control your instrument with the same calls regardless of the interface used to connect to the instrument. The NI-VISA class libraries cover I/O operations, locking, event handling, and interface-specific extensions. With these class libraries, you can access the functionality available in NI-VISA for communicating with message-based and register-based instruments using the following interfaces:

  • GPIB
  • PXI
  • RS-232 and RS-485
  • TCP/IP
  • USB
  • VXI


Take advantage of the following powerful features with the Visual Basic .NET and Visual C# .NET languages to quickly connect to and control your instrumentation:

  • Instrument I/O Assistant – Provides a user interface to interactively write commands to a device, read data that the device returns, and specify how to parse the response into a format relevant to your application. It is fully integrated into Visual Studio .NET. Instrument I/O Assistant simplifies the challenge of writing instrumentation applications by automatically generating code from your configurations in Visual Basic .NET, Visual C# or Visual C++.
  • Parameter Assistant – With this assistant, you can discover and insert valid parameter values into your code for GPIB and VISA methods. The Parameter Assistant displays currently installed GPIB boards in the system, including an address pair for each device connected to it. It also lists any PXI, GPIB, VXI, or ASRL resource strings valid for your system.


    Instrument I/O Assistant provides an interactive interface to write commands to a device, read data that the device returns, and automatically parse the response. It is fully integrated into Visual Studio .NET.


Instrument I/O Assistant
Most existing drivers do not work with .NET without significantly rewriting much of the source code. With Measurement Studio, you can use the Instrument Driver .NET Wizard to instantly wrap existing IVI, VXIplug&play, and legacy instrument drivers to native Visual Basic .NET or Visual C# source code.

<PICTURE>
Specify an existing instrument driver function panel and instantly convert this Visual Basic .NET or Visual C# .NET source code.

After the data is acquired, analysis is the next fundamental step in any measurement application. Measurement Studio includes robust .NET analysis libraries to enhance your measurement application with advanced decision-making capabilities, digital signal processing, measurement analysis, and statistical computations.

 

Analyze with NI Measurement Studio

Measurement Studio provides powerful analysis classes in Visual Basic .NET or Visual C# .NET that are designed specifically for measurement analysis and signal processing. You can easily integrate these functions into Visual Studio .NET applications to create robust virtual instruments by transforming raw data into critical information.

Measurement Studio provides powerful algorithms and functions that are designed specifically for measurement analysis and signal processing.

With the Measurement Studio analysis functions you have everything you need to perform the following types of operations:

  • Advanced signal measurement functions such as peak detection, harmonic analysis, pulse analysis, and spectral analysis.
  • Perform statistical analysis of your data, including 1, 2, and 3-way analysis of variance (ANOVA), histograms, and common statistical functions
  • Generate complex composite signals for simulation or generation, using sine, triangle, square, and sawtooth signals, Gaussian noise, white noise, uniform noise, and arbitrary wavetables.
  • Digitally filter your data using versatile, configurable filters for all common filter designs
  • Perform time-domain signal processing such as convolution, deconvolution, correlation, decimation, integration, and differentiation.
  • Perform frequency-domain signal processing, such as windowing, and forward and inverse FFT, Hartley, Hilbert, and Laplace transforms
  • Perform linear algebra operations such as solving equation systems, computing eigenvalues and eigenvectors, decomposition, factorization, and vector and matrix algebra
  • Fit your data to linear, polynomial, exponential, and arbitrary nonlinear equations
  • Compute important mathematical functions such as probability distributions, error function, and complementary error function 

 

Present with NI Measurement Studio

Extensible .NET user interface (UI) controls deliver unparalleled flexibility through customizable features. This flexibility, combined with measurement-specific UI controls such as 2D graphs, switches, gauges, knobs, tanks, slides, and LED controls, empowers the creation of intuitive front panels for virtual instrument applications. For example, you can easily display waveforms acquired from data acquisition devices or GPIB instruments with built-in controls.

In addition to professional presentation capabilities, you can use National Instruments DataSocket to easily bind any user interface control, including NI controls and native Visual Studio controls, to live measurement data without writing code.

User Interface Controls
Once you have converted your raw data into more meaningful information with the analysis tools, you are ready to visualize and interact with the results.

Measurement Studio offers the following UI controls:

  • Waveform graph control
  • Scatter graph control
  • Digital waveform graph
  • Intensity graph control
  • Complex graph
  • Legend control
  • Switch and LED controls
  • Meter
  • Knob
  • Tank
  • Thermometer
  • Gauge
  • Numeric Edit

View the .NET User Interface Gallery


Choose from a variety of UI controls designed specifically for instrumentation.

Waveform and Scatter Graphs
Measurement Studio gives you insight into your data with .NET 2D waveform and scatter graph controls for displaying 2-dimensional data on a user interface such as a Windows Form. The scatter graph control displays a graph of X and Y data pairs. The waveform graph control displays data that is uniformly spaced in one dimension. Using annotations, you can easily highlight points or ranges of interest. Both graph controls include many properties that you can use to configure the appearance and behavior of the graph. For example, you can easily configure properties such as the caption text, caption background color, and color of the graph frame.


Use the Measurement Studio graph to plot waveform data and the scatter graph to plot two-dimensional data.

Key features of these graphs include:

  • Multiple x and y axes that are fully customizable
  • Linear and log scale
  • Multiple plots
  • Multiple cursors – a cursor displays a crosshair on a graph to mark a specific point or region on the graph.
  • Plotting and charting

Plotting deletes all previous data from an existing plot, and displays only the current data that you specify.

Charting appends the current data to any previous data that an existing plot contains, and you can display subsets of this data. Charting is useful for visualizing slowly changing data, such as temperature, pressure, or strain. Chart your data horizontally or vertically.

  • Annotations - use range or point annotations to dynamically select regions of interest
  • Zooming and panning – with these features you can see different views of your data.
  • Zoom in and out of your data either programmatically or interactively. Zoom around a point or on a selected rectangle.
  • Pan left and right to change the view of the graph that you see.
  • Grid lines


Design-Time Editors
In order to allow easy creation of professional user interfaces, Measure Studio includes productivity features that allow you graphically interact with your user interfaces. The .NET UI controls include auto format menus, editors, and property pages that allow you graphically customize and view property changes.

Auto format menus allow you to quickly choose from predefined property formats.

.NET editors are included for components like plots, annotations, and axes, allowing you interactively add and edit your user interface controls.

Integrated property page like arc editors depict graphical representations of user interface styles.


Editors such as the Plot Editor allow quick configuration of multiple plots. Measurement Studio also included editors for axes, annotations, and cursors.

Networking
Whether you pass data between applications or over the Internet, Measurement Studio makes sharing measurement data easy. With National Instruments network variables a programming tool designed for publishing and subscribing to live data in measurement and automation applications, you can publish or retrieve data, control remote applications, or distribute your system with one or more client applications on a network without worrying about data formats and network protocols.

Features

  • Read and write data between different data sources and targets
  • Specify data sources and targets through a URL scheme
  • Use browsing features to help you quickly locate data items on other computers
  • Bind to Windows Forms and Web Forms controls


With network variables, you have a single, simple API to easily and quickly access send or receive measurement data from the Visual Studio .NET environment.

See Also:
Measurement Studio User Interface Gallery

Extensibility

To make users highly productive, Measurement Studio has designed the .NET libraries from the ground-up to fully extensible architecture. Measurement Studio adds methods that are specifically for extensibility like as MapDataPoint( ) which accepts graph coordinates and returns the corresponding Microsoft Windows coordinates.

Here is an example of a typical use case. A user wants to modify the behavior of the graph’s plot so that it has a value-dependent plot line color:

  • Red plot line color for decreasing values
  • Green plot line color for increasing values

Measurement Studio provides an extensible architecture so you can modify the behavior to meet your requirements.


The WaveformPlot class provides two methods for controlling the drawing behavior:

  • OnBeforeDraw method – Use this method to perform any custom drawing in the plot area before the plot is drawn. You can also use this method to cancel the plot drawing code and take complete control of drawing the plot.
  • OnAfterDraw method – Use this method to perform any custom drawing in the plot area after the plot is drawn.


In order to achieve the correct behavior for this use case, all you have to do is derive from the WaveformPlot class and override the OnBeforeDraw method. The code below is what the code would look like in C#:

private void OnBeforeDrawPlot(object sender, NationalInstruments.UI.BeforeDrawXYPlotEventArgs e)
{

// Clip data, iterate through clipped data, map, and draw.
XYPlot plot = e.Plot;
double[] clippedXData = null, clippedYData = null;
plot.ClipDataPoints(out clippedXData, out clippedYData);

for (int i = 0; i < clippedXData.Length - 1; ++i){
double x1 = clippedXData[i], x2 = clippedXData[i + 1], y1 = clippedYData[i], y2 = clippedYData[i + 1];
PointF point1 = plot.MapDataPoint(e.Bounds, x1, y1);
PointF point2 = plot.MapDataPoint(e.Bounds, x1, y2);
PointF point3 = plot.MapDataPoint(e.Bounds, x2, y2);

Pen pen = null;
if (y2 > y1)
pen = Pens.Green;
else if (y2 == y1)
pen = Pens.Yellow;
else
pen = Pens.Red;

Graphics g = e.Graphics;
g.DrawLines(pen, new PointF[] { point1, point2, point3 });
}
e.Cancel = true;

}


The end result is a plot designed specifically to meet your requirements that is reusable in your other applications as well.

In addition to deriving from the classes to extend functionality, you can also very easily customize the following features of the User Interface objects:

  • Line styles for the WaveformPlot, ScatterPlot, grids on the WaveformGraph and ScatterGraph, and XYCursor.
  • Point styles for the WaveformPlot, ScatterPlot and XYCursor.
  • Border styles for the WaveformGraph, ScatterGraph, LED, Switch, and Legend.
  • Selection styles for the WaveformGraph and ScatterGraph.


Compatibility with NI TestStand

The .NET Adapter in NI TestStand allows test developers and test engineers to call Measurement Studio .NET assemblies written in any .NET compliant language such as Visual C# or Visual Basic .NET. The .NET Adapter in NI TestStand supports most .NET data types including numerics, enumerations, structs, objects, arrays and even generic types and can target the .NET Framework 1.1 and later. Test developers can also take advantage of TestStand's integration with Visual Studio to create, edit and even debug .NET assemblies (and Measurement Studio .NET assemblies if used in conjunction with Measurement Studio Enterprise Edition) from TestStand directly in Microsoft Visual Studio 2003 and later.


The .NET adapter handles most .NET data types including numeric, enumeration, struct, and array types using the .NET Framework v1.1 and later.
See Also:
NI TestStand

Conclusion

Thus, Measurement Studio provides the following benefits:

  • Productivity
  • Reduces product development and maintenance costs by providing proven software tools for adding acquisition, analysis and presentation to your applications.
  • Streamlines development with useful code-generating tools such as DAQ Assistant, Instrument I/O Assistant, Parameter Assistant, and Instrument Driver .NET Wizard.
  • Integration
  • Supplies fully integrated tools such as DAQ Assistant and Add/Remove Class Libraries Wizard for Visual Studio .NET.
  • Includes fully integrated help in Visual Studio .NET to provide you with useful documentation.
  • Flexibility
  • Offers you the option to select the environment best suited for your application.
  • Provides an object-oriented and intuitive hierarchy that makes it easy to extend.


The ease of use and reliability of Measurement Studio make it the product of choice for creating measurement and automation applications in Visual Studio .NET.

Note: Measurement Studio support for Visual Studio 6.0, Visual Studio 2003  and Visual C++ MFC is considered legacy. NI Measurement Studio for Legacy Environments/Languages includes this support and is available upon request for qualifying Measurement Studio customers.

Related Links

Measurement Studio Home Page
Measurement Studio for Visual C# .NET Home Page
Measurement Studio for Visual Basic .NET Home Page
Evaluate Measurement Studio

18 Ratings | 4.11 out of 5
 Print |  PDF

Reader Comments | Submit a comment »

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).