Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Creating a New Process

NI InsightCM™ SDK Help

Edition Date: July 2017

Part Number: 375191C-01

»View Product Info
Download Help (Windows Only)

Parent Topic: Overview: Developing Software for Devices in an NI InsightCM System

To provide a starting point when you create your own process, the NI InsightCM SDK provides a project library template with customizable files. Creating a new process involves two main steps: customizing files in a template library and developing the code in the process VI. This topic provides instructions for these steps. Integrating the process into the device code requires additional steps, which the end of this topic outlines.

Starting from the Process Template

Complete the following steps to create a copy of the template library:

  1. Open InsightCM Process Template.lvlib in the following directory: <InstallDir>:\Program Files (x86)\National Instruments\labview\examples\InsightCM\ProcessTemplate.
  2. Select File»Save As, enter a filename that describes the process, and click Continue.
  3. Save the directory in a new folder at <InstallDir>:\Program Files (x86)\National Instruments\labview\vi.lib\addons\InsightCM\Devices\Shared\ProcessName Folder\, where ProcessName is a name that describes the process.
  4. Select File»Recent Files and open the new project library (.lvlib) file. This LabVIEW library file contains template files you must customize. Add additional files, such as subVIs and type definition controls, to this library as you develop the process.

Customizing Template Files

Customize the following files in the project library (.lvlib) file to provide process-specific information to the device code:

Tip  When you customize each VI template file, edit its VI icon so the icon indicates the purpose of the VI. To launch the Icon Editor dialog box, double-click the icon in the upper right corner of the front panel window or block diagram window.

Process Name VI

On the block diagram of the Process Name VI, enter the name of the process. The same string must be used throughout the device code when initializing Qbus, sending messages from and to the process, and so on. This subVI provides the process name to several VIs, such as Create Listener, Send Routed Message, and Set Listener Process State.

Registered Messages VI

On the block diagram of the Registered Messages VI, enter the names of any broadcast messages you want Qbus to store in its message queue. You will build an array of those message names in the Registered Messages VI.

TracePoint VI

If the process will either send messages or log tracepoints, complete the following steps for each unique message and tracepoint name:

  1. Open the subVI appropriate for the type of name you want to define.
  2. Select File»Save As. In the dialog box that appears, select Open additional copy and enable the Add copy to ProcessName.lvlib checkbox. Click Continue.
  3. Enter a unique name that describes the message or tracepoint name the subVI will return, and then save the file in the same subVIs folder as TracePoint.vi and MsgMyMessage.vi.
    Tip  Consider naming message subVIs with a format that includes the exact message name. For example, MsgLogTracepoint.vi for a message whose name is LogTracepoint. This improves code readability by not requiring you to open the subVI block diagram to see the message name.
  4. Save your changes.

config.ctl

Complete the following steps to define the configuration data that the process reads or writes and then transfers from iteration to iteration between its message-handling subdiagrams:

  1. Add controls to the config cluster. Enter descriptive labels that will help document the process code when you bundle and unbundle them by name within the process VI and subVIs.
  2. Rename or delete the placeholder control depending on if you want to store configuration in different states of the process.
Tip  It might be helpful to wait to define this cluster until after you have developed message-handling code in the process VI. You might not know which values the process requires from this cluster until you finish developing the process VI.

Developing the Process VI

Open the Process VI from the template library. The following illustration shows the components you typically customize within the process VI template and provides general instructions for how to customize the components.

Note  At the left side of the block diagram, notice that the VI calls the following template files you customized in the previous section: ProcessName.vi, config.ctl, and RegisteredMessages.vi.

Add a case to handle each broadcast and routed message the process can receive, as well as each priority and default action the process sets in any location.
Implement code in each case to handle the message or action to which it corresponds. Update the template Initialize case so it performs any tasks that must be complete before the first message is handled, such as populating the configuration cluster.
To get or set values that are shared between subdiagrams, unbundle and bundle elements in the configuration cluster.
At the end of a subdiagram, define a priority action you want the process to perform the next time it executes. To allow the process to read from its message queue, specify an empty string.
Set a default action that you want the process to perform if there is no priority action set and its message queue is empty.
If the Receive Messages VI returns a message, you have access to the value sent with the message as a variant. Convert this value from a variant to its original data type to act on the value.
Define the amount of time to wait to receive a message in the Qbus message queue before timing out. If the subVI times out, it returns the name of the default action shift register.
If the process will receive only routed messages, you can remove the RegisteredMessages VI and the RegisterForMessages VI and instead wire the Qbus in reference directly to the While Loop.

Integrating the Process into Device Code

Adding a new process into existing device code involves the following main steps:

Related Information

Components of a Process

Providing Configuration Data to a Process

Handling a Qbus Message

Preempting the Message Queue with a Priority Action

Setting a Default Process Action


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit