Creating a .NET DAQ Component with Add New Item

  1. Open the project in which you want to create a DAQ component.
  2. Select Project » Add New Item to launch the Add New Item dialog box.
  3. In the Categories pane, select Visual Basic Items if you are using Visual Basic .NET. Select Visual C# Project Items if you are using Visual C#.
  4. In the Templates pane, select NI DAQ Component.
  5. Specify a name for the DAQmx task file and click Add. If you are creating a project task, the name you choose for the file becomes the name of your task class.
  6. In the Add DAQ Component Dialog box, specify one of the following options to create your DAQmx task:
    • Create a new project task—This option creates a new DAQmx task in your project. The settings that you specify are not saved in Measurement & Automation Explorer (MAX) and only affect the task in the project.
    • Create a new MAX task—This option creates a new DAQmx task in MAX. The settings that you specify are saved in MAX.
    • Create a reference to a MAX task—This option lets you reference a DAQmx task that already exists in MAX from your current project. Any changes that are saved to this task are saved in MAX.
    • Copy a MAX task to a project task—This option lets you create a copy of a DAQmx task that already exists in MAX and copy it to your current project. Any changes that you make to this task are not saved in MAX and only affect the copied task in the project.
    • Copy an existing .mxb—This option lets you create a copy of a task that is specified by an existing .mxb file in another project and copy it into the current project.
  7. Click Finish.
  8. If you selected an option to create a new task, the wizard launches the DAQ Assistant. Select the measurement type for the new task in the DAQ Assistant.
  9. Select the channel or channels to add to the task. Click Finish.
After you complete these steps, the wizard adds an .mxb file to the project and opens the task configuration editor. You use the configuration editor to configure the DAQmx task class. If the DAQmx task is a project task, the .mxb file stores the DAQmx task configuration information. If the DAQmx task is a MAX task, the .mxb file stores the MAX task name. The wizard adds references in the project to appropriate National Instruments class libraries.
Note To view these references, the .mxb file, and its source code in Visual Basic .NET, select Show All Files in the Solution Explorer toolbar. This step is not necessary in Visual C#.

The wizard also adds a partial class for the DAQ component which you can use to extend your application. This partial class has a .User.vb suffix for Visual Basic .NET projects and a .User.cs suffix for Visual C# projects.

Note The DAQmx task class and DAQ component are generated every time you change and save your configuration information, so any changes made in these classes are overwritten. Use the component partial class to add functionality to your DAQ component.

Save the .mxb file to generate source code. If the DAQmx task is a project task, the DAQ Assistant generates a DAQmx task class that contains your configuration settings and a DAQ component that uses the generated task. If the DAQmx task is a MAX task, the DAQ Assistant generates a DAQ component that loads the specified MAX task from MAX.

After you create the .NET DAQ component, you can use the DAQ Assistant task configuration editor to configure the DAQmx task of the component.