A design pattern is a building block you can use within your LabVIEW Real-Time Module application to address common problems in software engineering. By using design patterns in your applications, you can take advantage of the accumulated experience of the software engineering community. The benefits of design patterns include:

  • Faster development time
  • Greater robustness
  • Better code reusability
  • Easier debugging
  • Enhanced maintainability

National Instruments recommends the following design patterns for LabVIEW Real-Time Module applications on all RT hardware platforms. If you have installed NI-DAQ or NI-RIO drivers, you can view examples of these design patterns in LabVIEW applications by using the Create Project dialog box to open sample projects designed for CompactDAQ, PXI with DAQ, and CompactRIO platforms.

Use Case Design Pattern Description
Transitioning between program states Simple State Machine, available from the Create Project dialog box. An application design composed of a finite number of states, transitions between those states, and actions associated with each state.
Communicating between parallel loops Queued Message Handler, available from the Create Project dialog box. An application design used to transfer data between processes that produce and consume data at different rates.
Creating an RT data server Client-Server An application design in which the client requests an action or service from the provider of service, the server.

Refer to the NI LabVIEW for CompactRIO Developer's Guide, available at ni.com, for information about CompactRIO-specific design patterns.

Note The Producer/Consumer design pattern can be a good starting point for inter-task communication in an RT application. However, when communicating with a deterministic loop, use either a single-process shared variable with the RT FIFO enabled or the RT FIFO functions.