|Download Help (Windows Only)|
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.
Complete the following steps to create a copy of the template library:
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.|
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.
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.
If the process will either send messages or log tracepoints, complete the following steps for each unique message and tracepoint name:
|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.|
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:
|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.|
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.|
Adding a new process into existing device code involves the following main steps: