.NET Support in LabVIEW 7 Express

Publish Date: Sep 06, 2006 | 28 Ratings | 2.86 out of 5 |  PDF

Overview

With the release of LabVIEW 7 Express, you easily can connect to this new .NET technology as a .NET client. You can create instances of .NET classes and invoke methods to set and obtain properties on them. The usage paradigm is similar in LabVIEW 7 Express to that of ActiveX automation VIs.


Table of Contents

  1. Basics of .NET
  2. Comparison with ActiveX/COM
  3. .NET Support in LabVIEW 7 Express
  4. Other .NET LabVIEW Functions

1. Basics of .NET

The .NET framework is a new Microsoft computing platform designed to simplify application development in the highly-distributed environment of the Internet. The .NET framework has two main components – the common language runtime (CLR) and the .NET framework class library.

The CLR provides a type system that spans programming languages and operating system boundaries. The CLR introduces a level of abstraction that encourages developers to see the system as a world of type and objects rather than memory and threads. Developing applications for the CLR requires compilers and linkers to generate information in the new metadata format. The compilers generate CLR intermediate language (IL) code rather than the assembly code under the Win32 system. CLR executes the IL in an execution mode called the “managed” mode. Code generated in the traditional way, by nonCLR compilers, executes in a separate execution mode called the “unmanaged” mode. The .NET framework is a set of classes that perform the same functions, as did the Win32 functions under the Win32/COM system. With .NET, you can create classes in one .NET language and use them in another .NET language.

Back to Top

2. Comparison with ActiveX/COM


ActiveX/COM technology presented two kinds of applications. ActiveX servers exported functionality through classes and methods, as well as automation clients that used this functionality in their code. With .NET technology, similar roles exist, but the integration is much deeper. Classes that mark themselves as public export automatically along with their public functions. To use these classes, client classes would include them just as they would any other class from the .NET framework.

.NET Assemblies have an extension of .dll or .exe and contain meta data of .NET classes. Meta data contains required for debugging and garbage collection, as well as security attributes, marshaling data, extended class and member definitions, version binding, and other information required by the .NET runtime. However, assemblies are not true Win32 executables – rather they are .NET metadata libraries. These libraries also contain information about the exported classes, methods, properties, and events.

Back to Top

3. .NET Support in LabVIEW 7 Express


With the release of LabVIEW 7 Express, you easily can connect to this new .NET technology as a .NET client. You can create instances of .NET classes and invoke methods to set and obtain properties on them. The usage paradigm is similar in LabVIEW 7 Express to that of ActiveX automation VIs.

This section explores a simple VI that uses classes installed by the .NET framework to obtain processor usage statistics. This example uses PerformanceCounter class exported by the system .NET assembly.

Step 1: Create an instance of the class.

The system assembly exports the PerformanceCounter class.

i. Select Library and Class.
a. Go to the .NET palette in the communications palette and drop down the Constructor node.


This brings up a dialog that you can use to browse all the Assemblies registered globally in the system. The System.Diagnostics namespace in the system assembly exports the performance counter.

b. Select the system assembly from the list of assemblies.


c. Select the System.Diagnostics namespace

d. Select the PerformanceCounter class and the desired constructor.


e. Wire in the parameter values to the constructor node to finish its configuration


Step 2: Selection of a method

Now select the method NextValue, which returns the value of the selected counter. Drop an invoke node, wire the refnum output from the constructor node into the invoke node refnum input, and right click on the invoke node to select the method.


Step 3: Closing the Reference

Finally drop down a Close Reference function and close the .NET refnum that you had created an instance of.


The diagram below presents and the front panel of the VI.

Back to Top

4. Other .NET LabVIEW Functions


In addition to the constructor, invoke and property nodes and the Close Reference functions, the following functions are available from the LabVIEW 7 Express .NET palette.

To More Specific Class


This function downcasts a reference from a class to a more specific class in its inheritance hierarchy. For example, if Class A inherits from B, then you could have a variable of type B hold a value of type A. You then can use the above function to downcast from B to A. If the function fails, there is an error.

To More Generic Class


This function upcasts a reference from a class to a more generic class. For example, if Class A inherits from B, you can use the above function to downcast a variable of type A into one of type B. This function should always succeed.
Related Links:
Visit Microsoft's .NET home page.
Information on .NET Component Developers
Know the Basics of Microsoft.NET

Back to Top

Bookmark & Share

Ratings

Rate this document

Answered Your Question?
Yes No

Submit