Superior results are obtained by employing a single set of developer tools, automating common low-level programming tasks and building and reusing libraries and components that work across many programming languages and computing devices.
Over the years engineers developing applications to control test and measurement (T&M) equipment have employed a variety of languages and development environments. Often it is the comfort level of workersrather than overall value, productivity, ease of use, scalability or capabilitiesthat determines just which programming language they choose. Since a number of individuals or groups support products through the entire product life cycle, companies must often manage and maintain multiple, homegrown applications, including the various in-house experts with their numerous programming languages. Also, some 90 percent of all test equipment connects to a computer or a network.
Given all of these points, it is clear that productivity in the T&M world would benefit greatly from a move to a programming environment based on an open software standard. In addition, by adopting an open standard established by the computer industry, T&M engineers could then fully exploit the gains in computer technology that have blossomed over the last decade.
The .NET environment, which is indeed an open software standard, will enable T&M programmers to boost productivity, reduce costs, and accelerate time-to-market. They will now be able to work with an open software standard to install, manage, and grow their environment. Developers who choose to work within the .NET platform to create and test new products will be able to focus their creativity on solutions and leverage a development platform created by 4000 Microsoft engineers. As for managers, they will be able to draw upon a larger pool of developers and protect their investment in the creation of intellectual property.
This article explores the portions of the .NET platform that are most important to the daily lives of the design and test engineer.
.NET in a nutshell
There are two major parts of the new .NET platform that are important to writing those "Plain Old Windows Applications" (Figure 1). The first is the .NET Framework comprising the Common Language Runtime (CLR) and the Framework Class Library (FCL), while the second is the Visual Studio .NET development environment.
Figure 1: .NET and its major components
Common Language Runtime
The Common Language Runtime (CLR) is, as the name denotes, a runtime that is usable by the different and varied .NET programming languages. CLR was built to try to simplify development and is "object oriented" to the core, which means that Classes and inheritance are fully supportedeven across languages. A class written in VB.NET can be inherited from it in another language, such as C#, and vice-versa. For the COM programmer, the CLR eliminates the need for some of the nasty plumbing that was requiredno registering of classes, no dealing with GUIDs, no more IDL files, HRESULTs, IUnknown, AddRef/Release, or CoCreateInstance. When you are in .NET., you don't have to consume time learning the arcane minutia of COM/ATL/MFC objects. CLR provides easy mechanisms to export .NET classes as COM classes with no extra workthere are of course a few caveats to thisand you can easily import COM classes to use as .NET classes.
Microsoft did do a very good job of backwards-compatibility here. One of the new nice features of the CLR is that all .NET objects are garbage collected. You will not have to deal with stray pointers, memory leaks, missing object releases, and so on. Memory leaks in managed code will be a thing of the past. This problem has consumed a fair amount of time in development teams and is the source of many bugs. It also makes exception handling a first-class class concept. This means you don't have to check function return values using Boolean data types or HRESULTs. These are built into the languages and you will learn to use the structures of TRY/CATCH/FINALLY in your codingthis is much better than what you needed to do in the past.
The CLR is also usable on any language that is built for .NET. You can write application components in multiple languages and use them in multiple other languages. It is far easier to share the components between different languages. The tools are also the same for all languages; hence the debuggers, profilers, code coverage analyzers, and the like, work for all languages. There is also exactly one development environment.
Framework Class Library Design Goals
The main benefit of the Framework Class Library (FCL) is that it unifies application-programming models. Figure 2 shows the migration over time for the different programming APIs used prior to .NET. The consistent API available in any language really makes it simple to use. You don't have to learn different APIs depending on what language you are using. FCL is also factored and extensible because most of the framework allows you to inherit from it, to make changes if you do not like what the base classes are doing.
Figure 2: Programming API migration over time
Simple to Use
The FCL is organized in hierarchical namespaces and classes. It is far easier to find the API you are interested in than in the "old days" of looking through the Windows APIwhich organized its 3000-plus functions alphabetically (the help system did organize things a little bit better, but the API was not organized like the Framework). The Framework also has a unified type system, which means that everything is an object. There are no variants data types, there is exactly one string type, and all character data is Unicode. For those COM and MFC programmers out there, this is a huge change. All properties, methods, events, and attributes are first-class constructs. Any .NET class is available for you to extend through inheritance. And, unlike COM, you're using and extending the class itself, not a "wrapper" on the classthis allows for cross-language inheritance.
With approximately 167,000 methods, 37,000 properties, and 13,000 events inside this framework, the FCL is enormous. Therefore, a challenge for those who want to become proficient in .NET is to find the parts of the .NET framework that are going to be useful to them and learning those well. We have found that we have implemented a class or data structure thinking that it did not exist in the FCL, but later found out it did, indeed, exist. It pays to spend some time searching the documentation and asking other .NET-savvy programmers embarking on a new class/data structure design.
Because the .NET Platform is language neutral, all .NET languages are first-class players. You can easily mix and match components built with different languages and will be able to leverage your existing skills far easier than if you had to learn another language and development environment. The language neutrality of the framework allows consumers of .NET components to easily use all the components.
If you want, you can pretty easily extend the .NET Framework components. Microsoft is providing Visual Basic, C++, C#, and JScript. Third parties are building FORTRAN, APL, COBOL, Pascal, Eiffel, Haskell, ML, Oberon, Perl, Python, Scheme, and Smalltalk. At the time of this article, there are already more than 26 supported programming languages.
Visual Basic .NET
There are some pretty big changes to the Visual Basic language. VB.NET is now a first-class, object-oriented programming language with new featuressuch as implementation inheritance, overloading, and parameterized constructors. VB.NET includes true structured exceptions, a single form of assignment, and optional stricter type checking. For instance, in VB.NET:
Dim X As Integer = 1
is equivalent to these statements:
Dim X As Integer
X = 1
in VB6, or prior versions. The runtime, VBRUNxx.DLL, is replaced by .NET Framework and every feature of the .NET Framework is directly available. The Framework is substantially larger than the old VB runtime. When moving your existing code to the .NET Framework, Microsoft provides an Upgrade Wizard that will "upgrade" your code to Visual Basic .NET code. Anything the upgrade wizard does not know how to convert is marked with "TODO" in your upgraded code as well as building a report of any issues that it has found.
Note that this wizard is only available in Visual Studio, .NET Professional, and higher editions. The wizard is not available in the Visual Basic .NET Standard Edition. Also, the initial version of VB.NET does not support converting VB6 User Control Projectsthese will have to be rewritten in .NET or else just used directly by the .NET interoperation abilities.
The short answer is that it's still C++. There were minimal extensions and nothing was taken away. It is possible to mix native and managed code, using non-garbage-collected data, which allows you to gradually migrate. There are some language extensions (new keywords) that allow you to write managed C++ code. Your old C++ code can be used together with managed code allowing you to migrate it whenever you want to do so. You get full access to the .NET Framework.
This is a brand new language developed for .NET. In fact, it is the first component-oriented language in the C/C++ family. C# has its properties, methods, events, attributes, and XML documentation all in one place. There are no header files and no IDL files. You can embed C# in ASP+ pages. The language was built to simplify C++, while also preserving its heritage. You can do integration through COM and P/Invoke. There are millions of lines of C# in .NET Framework.
The biggest change here is that any language in the .NET Framework can be used with a single IDE. There is not a separate environment for VB, another for C++, and a third for VJ++, as in Visual Studio 6. VS.NET IDE most closely resembles the Visual Basic Rapid Application Development (RAD) environment, so most VB programmers will be immediately comfortable in this environment. The IDE is fully extensible and programmable (more on these features to follow).
VS.NET IDE has a new feature called dynamic help. This is where the IDE "knows" what language keyword/component you are working on and changes the dynamic help pane accordingly. Debugging with different languages is done easilyin the same debugger. You won't have to hassle with the mechanics of debugging a project with VB and C++ components. Remote debugging is also a lot easier. This was possible in C++, but non-trivial and it was not possible in VB6. The bottom line for debugging is that you can debug multiple programs, using multiple languages, on multiple machines, all at the same time.
A Fully Extensible and Programmable IDE
Microsoft has "opened up" the IDE and published an API so tool vendors can easily integrate their languages and tools into the environment. This makes it possible to have 26 new programming languages in one IDE. It also makes it possible for tool vendors, such as Agilent, to develop tools that are targeted specifically at the T&M programmer and are totally and seamlessly integrated into the environment.
We have created the Agilent T&M Programmers Toolkit for Visual Studio .NET. The Toolkit is a series of tools and APIs that are part of the .NET programming environment. Our set of extensions to the .NET Framework Class Library is the T&M Framework, a programming API targeting the T&M programmer. Just as the FCL was built to handle the mundane tasks you deal with in programming, the T&M Programmers Toolkit was built to handle the mundane tasks of T&M programming.
T&M Programmers Toolkit
The Toolkit comprises a set of Tools and APIs.
Project wizardsAn extension of the VS.NET New Project Wizard with guided steps to create skeleton programs. These programs include all the necessary references to T&M Assemblies against which you will need to program.
Instrument explorerAn integrated tool to search for and configure instruments on USB, GPIB, RS-232, VXI, and LAN. Instrument Explorer also allows drag and drop from the explorer to your code buffer. Just drop an instrument icon into your work window to generate code to talk to the instrument (Figure 3).
Driver wrappers and wizardsYou use these to create a .NET wrapper to easily call VXIplug&play and IVI C-based drivers. This makes it possible to use these drivers in the .NET environment as if they were actual .NET objectsinstead of calling out to a C DLL. These tools enable the convenient use any of the hundreds of drivers available from Agilent and other instrument vendors in .NET applications.
Interactive IOThis API is used for communicating with instruments with calls such as ReadIEEEBlockAsString( ) and overloaded Write( ) methods. The API provides an easy way to control instruments using the instrument's native command set (SCPI).
Integrated helpFully integrated with Visual Studio.NET help system with dynamic help,
along with IntelliSense to shorten the programming learning curve (Figure 4).
IO monitorTracks and aids in instrument IO debugging. This is a stand-alone tool that is called via a button on the toolbar or as a menu pick.
Engineering graph objectsThese .NET graphs allow the visualizing, scaling, and tracking data from measurement and data stores. There are display types for X vs Y, Y only, Waveform, Complex, Magnitude Spectrum, Phase Spectrum graphs and Strip-Chart graphs.
Data analysisAn API is included for math and data analysis.
Digital signal processing (DSP) functionsIncludes the usual list such as Bartlett, Blackman, Hanning, Convolution, Rectangular and Hamming windowing functions; FFT and IFFT; Bessel functions; Statistical functions (Gamma, Mean, Median, Mode, Beta, Binomial, Factorial, Perm, Comb, RMS, Standard Deviation, and Variance); and Regression functions (Lin, Log, Exp, and Power Curve).
Complex number classThere is a .NET structure for representing complex numbers as might be returned from a network analyzer.
Engineering FormatterAn extension to the .NET formatter enables printing in engineering units such as exponent value which is always a multiple of three such as "123.5E3". Another mode allows for a full SI prefix name such as "123.5 kilo".
By adopting .NET and the opportunities it affords, the T&M community can immediately access a wealth of innovations, secure its investment, and accelerate design and test productivity. It is expected that engineers will experience up to a 50% decrease in time spent programming instruments and displaying data by working within the .NET home base and leveraging .NET code portability, its enormous inherent functionality, and its growing user community.
Developers who choose to work within the .NET platform to create and test new products will be able to focus their creativity on T&M solutions and leverage a development platform created by a huge number of Microsoft engineers over the last 5 years. As for managers, they will be able to draw upon a larger pool of developers who know this standard environment and protect their investment in the creation of intellectual property. Finally, for those using VEE or Labview, it makes sense to stay with them. However, the T&M Programmers Toolkit provides a way to call and utilize code already created in VEEin such cases it will be easier to generate that code from VEE.
About the Author
Ken Colasuonno is a Software Project Manager at Agilent Technologies responsible for the development of the Agilent T&M Programmers Toolkit. He has been part of T&M software development in Agilent and HP for 13 years. Ken has a MCS from Rice University in Houston, TX and a BS Chemical Engineering from the University of Missouri-Rolla.