Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Use DAQ assistant properties

I used the DAQ assistant in a project. I do a little bit of processing and then generate an output file (text format).
 
For my application I want to read the DAQ properties such as sample rate, clock type, etc and store them in a file for further analysis by Diadem. I do not want to write code to creae the DAQ task because the DAQ Assistant already does this. However, I cannot find in online help (looked at Creating a Measurement Studio DAQ .NET Application hyperlinks plus other places). Tried using intellisense too. All I can find is an autogenerated DAQTaskComponent1 object that doesn't expose very many properties and none of the task.timing ones.
 
How do I navigate thru this to get to things like terminal configuration, scaled units, input range, etc?
 
Thank you.
0 Kudos
Message 1 of 5
(3,565 Views)
Hey Steve,
 
Whenever you set up the DAQ Assistant to create all of the code for you (which, by the way, you are wise not to attempt to recreate because that would be a pain), it generates a file in your project corresponding to the name of your mxb file (DAQmx task) that you created.  If you are using C#, this file shows by default; however, if you are using another language like VB or C++, these files are hidden.  To view this file, click on any item under your project in the solution explorer and then click on the "Show All Files" button at the top of the solution explorer (this should be the second button from the left, depending on version).  Now, you should have a *.mxb file inside of your project (named according to your DAQ task name, such as "DaqTask1.mxb".  If you click on the plus sign next to this, two things should show up underneath this file: one file with the same name of the mxb file, except .vb or .cs (or whatever else) and a file that contains the word "User".  Click on the second file with the word User.  This file is a customization of the DAQTaskComponent1 object that you are referring to. 
 
Essentially, the Task is a protected object, keeping in line with the object-oriented design of protecting variables.  The DAQTaskComponent generically speaking is used for basic task operations (Starting, Stopping, etc).  It can, however, be modified in the user file specified above.  Simply add in a method to this file that works as a "getter", returning whatever values of the task you might want to know.  For instance, the method below can be added to this file to return the terminal configuration of analog input 0. 
 
public AITerminalConfiguration GetTerminalConfig () {
      return Task.AIChannels[0].TerminalConfiguration;
}
 
(Note that this can be a property or method.  The access of the Task variable is simply limited to members of the DaqTaskComponent class.)
 
Now that this method is added to the class, we can easily refer to this method from the DAQTaskComponent1 object you mentioned using intellisense.
For more information on this functionality, you can find a good explanation in the native Help at url
ms-help://MS.VSCC.v80/MS.VSIPCC.v80/NI.MeasurementStudio.2005/DAQIntegration/XML/Add_Custom_Func_NET_DAQ_Component.html
or just search your local help in VS for "Adding Customer Functionality DAQ".
Please let me know if you need further help with this.
 
Thanks,
Andy McRorie
Applications Engineer
National Instruments
Thanks,

Andy McRorie
NI R&D
0 Kudos
Message 2 of 5
(3,550 Views)
Hi Steve

For some advanced property discovery, take a look at this.

DAQmx Capability Discovery: Property Filtering examples
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=1A972CCAA93134FFE0440003BA7CCD71&p_node=%20201181&p_source=External

This doesn't use the DAQ Assistant, but it shows the kinds of queries you can make to the DAQ driver in .NET

Bilal Durrani
NI
0 Kudos
Message 3 of 5
(3,537 Views)

Andy,

Interestingly, I had found the link you show w.r.t adding functionality, but it didn't occur to me to add another property or method for my own personal use.

Also, when I tried the example shown with OnTaskCreated it generated a compile error. My suggestion is to augment online help with what is shown there with the example that you supplied. The present help refers to advanced capability not included in the assistant.

Is there any movement afoot for NI to offer MS training? It would sure help.

Steve

0 Kudos
Message 4 of 5
(3,536 Views)

Bilal,

Thank you for the link. I downloaded and ran the example. Bit too advanced for me right now, but I'll keep it in mind when I get more proficient.

Steve

0 Kudos
Message 5 of 5
(3,532 Views)