Connectivity


In some applications, you will want to share data with other programs, perhaps locally or across your local network. In many cases, you may want to share the data over the Internet and allow other people to view or control your system over the Web.

LabVIEW has built-in features (such as a web server, web publishing tool, email VIs, and network variables) and functions that simplify this process. These VIs facilitate communication over a network or over the Internet. LabVIEW can use the NI Publish and Subscribe Protocol (NI-PSP), which we'll learn more about in Chapter 16, "Connectivity in LabVIEW," to share data across networks, call and create dynamic link libraries (DLLs) or external code, and support ActiveX automation and .NET assemblies. Using additional add-on modules and toolkits, LabVIEW can also communicate with most SQL (structured query language) databases, such as MySQL, PostgreSQL, Oracle, SQL Server, and Access. Network variables can be defined in a LabVIEW project and easily shared across an entire distributed measurement system.

Internet Connectivity

LabVIEW has several built-in features that make it very easy to share your VIs and data over the Internet. Using LabVIEW's web server and Remote Panels, you can allow people to remotely view and control your VIs (without any additional programming), as shown in Figure 2.11.

Figure 2.11. A VI's front panel image viewed in Mozilla Firefox, generated by LabVIEW's web server


With the Enterprise Connectivity Toolkit, you can also use LabVIEW to ftp and telnet into remote systems, as well as provide enhanced web-serving capabilities. Emailing capabilities are built into the LabVIEW Professional version.

Networking

For our purposes, networking refers to communication between multiple processes that usually (but not necessarily) run on separate computers. This communication can occur on a closed, local area network (LAN), or over the Internet. One main use for networking in software applications is to allow one or more application to use the services of another application. In addition to the web publishing features of LabVIEW, you can use some of the networking functionality to communicate with other software or another LabVIEW program.

For communication between processes to work, the processes must use a common communications language, referred to as a protocol. LabVIEW supports the following protocols:

  • NI Publish and Subscribe Protocol (NI-PSP) a proprietary protocol from National Instruments for sharing instrumentation data. It has the advantage that it is very easy to use. Shared Variables (discussed in Chapter 16) use this technology under the hood.

  • TCP/IP the basic protocol of most networks, including the Internet.

  • UDP a basic protocol, similar to TCP/IP but without acknowledged data delivery.

This book will talk more about Internet capabilities and networking in Chapter 16.

ActiveX and .NET

ActiveX is a technology from Microsoft that defines a component-based architecture for building applications that can communicate with each other. ActiveX builds upon previous technologies such as OLE. With ActiveX, one application can share a piece of code (a component) with a completely different application. For example, because Microsoft Word is an ActiveX component, you can control and embed a Word document inside another ActiveX-capable application, such as LabVIEW VI. LabVIEW supports ActiveX automation and can contain ActiveX components.

The .NET framework is a newer technology from Microsoft designed to simplify application development in the highly-distributed environment of the Internet. In LabVIEW, you can easily 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. In this way, using .NET in LabVIEW is similar to using ActiveX automation VIs.

If you don't understand what we're talking about, don't worry. (ActiveX and .NET are fairly complicated advanced topics. They're discussed in more detail in Chapter 16.)

Shared Libraries, DLLs, and CINs

For increased flexibility, LabVIEW can both call and create external code routines (for example, code written in C++) as shared libraries and integrate these routines into program execution. In case you were wondering, a shared library is a library of shared functions that an application can link to at runtime, instead of at compile time. On Windows, shared libraries are called dynamic link libraries (DLLs); on Mac OS X, they are called frameworks; and on Linux, they are called shared objects (or just shared libraries).

You can use the Call Library Function in LabVIEW to call a shared library. You can also tell LabVIEW to compile its VIs as a shared library that other types of code (for example, C++) can use. Shared libraries on other (non-Windows) platforms do not have a .dll file extensionthere is a listing of platform-specific shared library file extensions in Table 2.1.

Table 2.1. Shared Library File Extensions

Operating System

Shared Library File Extension

Windows

.dll

Mac OS X

.framework

UNIX

.so


In addition to calling shared libraries, LabVIEW can also call external code using a special block diagram structure called a code interface node (CIN) to link conventional, text-based code to a VI. LabVIEW calls the executable code when the node executes, passing input data from the block diagram to the executable code, and returning data from the executable code to the block diagram. CINs are sometimes used when the external code doesn't fit neatly into a shared library structure. It is also important to note that CINs are statically linked into the VI. The CIN cannot be changed without editing the VI. (This is not true for shared libraries, which are only linked at runtime.) Also, VIs that use CINs are not cross-platform compatible.

Most applications never require the use of a CIN or DLL. Although the LabVIEW compiler can usually generate code that is fast enough for most tasks, CINs and DLLs are useful for some tasks that are time-critical, require a great deal of data manipulation, or that you have already written specific code for. They are also useful for tasks that you can't perform directly from the diagram, such as calling operating system routines for which LabVIEW functions do not exist. Also, many third-party (non-LabVIEW) software developers package their software as shared libraries. For example, the VXI plug&play compatible drivers mentioned in the section, "A Little Bit About PXI and VXI," are actually shared libraries (DLLs) with LabVIEW VIs that call the DLL functions.

Other Communication Mechanisms

In addition to these network protocols, LabVIEW provides support for some older and lesser-used protocols and application communication platforms, such as DDE (Windows), as well as named pipes in Linux and Mac OS X.




LabVIEW for Everyone. Graphical Programming Made Easy and Fun
LabVIEW for Everyone: Graphical Programming Made Easy and Fun (3rd Edition)
ISBN: 0131856723
EAN: 2147483647
Year: 2006
Pages: 294

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net