Example Code

Remote User Events Library using VI Server

Code and Documents

Attachment

This Remove Event library provides a network layer for invoking LabVIEW User Events on remote targets. A server can host a User Event that one or more clients on a local or remote computer can register for. The clients receive an Event Registration Refnum that they can wire directly into an Event Structure.

The API for these functions is based off the standard LabVIEW User Event functions:

  • Create User Event
  • Destroy User Event
  • Generate User Event
  • Register for Event
  • Unregister for Event

There are some slight differences from standard User Events that facilitate remote registration and generation over the network. The Remote Event User Events are named, like Queues and Notifiers. This allows a remote client to obtain a reference to the event by its name. The Create User Event function accepts a name as an input parameter. In addition, the Create User Event function has a set of polymorphic inputs for determining where the User Event server location is. This can be specified using an IP Address and Service Name, an IP Address and Port, or a custom LabVIEW Application Refnum.

Once the client creates the user event reference from the specified server, the client can register for that event using the Register for Event function. That function returns an Event Registration Refnum for a local bound event that the user can directly wire into an Event Structure and use like any other event.

The Remote Event library provides five basic data types that can be used, and a set of polymorphic wrappers for the different types. The data types are:

  • String
  • Boolean
  • LabVIEW Object
  • Variant
  • Command (a cluster with a string command and a variant data field)

To use these functions the user must set up VI Server access in their applications. However, the Remote Event library automatically adds its server command entry points to the list of available VIs when the server first creates a Remote Event. This makes it easier for the developer.

To get started download the attached files and open the Example Client and Example Server. The Remote Event library is a top-level library that wraps individual implementation libraries for the different data types.

Note that this library was developed with LabVIEW 2010.

Jarrod S.
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors