Generating Code in LabWindows/CVI
This section describes what happens during code generation in LabWindows/CVI and how to generate code using the DAQ Assistant.
Types of Code Generation
You can generate two types of code in LabWindows/CVI. For general information about the types of code and special considerations, refer to Generating Code.
- Example—This option creates a function that has the task and adds the source files to the project.
- Configuration—The DAQmxLoadTask function is replaced with a call to a DAQ Assistant-generated function that builds the task programmatically.
Caution Although generated configuration code includes code to create global virtual channels and tasks, it does not include code to create scales. If you generate configuration code for deployment of applications that include scales, you must ensure that the scales are configured in the target computer. Refer to Deployment in the NI-DAQmx Help for deployment options.
Generating Code in LabWindows/CVI
To generate example code in LabWindows/CVI, complete the following steps:
- Right-click a call to DAQmxLoadTask in a source file.
- Select Generate DAQ Example Code.
- Specify the name of the function that runs your task and the file to contain the generated example code.
- Click OK.
The generated code includes source and header files that define the run task function. LabWindows/CVI automatically adds these files to the project and modifies the current source file to call the run task function. When called, the run task function programmatically creates a user interface panel that allows you to start the task and display the data.
To generate configuration code, you can store a task in your project, which causes the DAQ Assistant to generate source code to create the specified task programmatically. The generated source and header file define an entry point function that configures the task and returns a task handle. A generated binary file (.mxb) contains a binary description of the task that is used when editing the task in the DAQ Assistant. The DAQ Assistant adds all three files to the project when you create a project-based task. You can convert a MAX-based task to a project-based task by right-clicking DAQmxLoadTask in a source file and selecting Copy DAQ Task To Project from the context menu. This option performs the following actions:
- Generates and adds files to the project
- Replaces DAQmxLoadTask with a call to the generated entry point function
- Adds an include statement for the generated header file