Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

I need to get the float values returned in the OnProgress or On Acquired events in a CWAI control

I'm using Component Works for developing a generic Acquisition software for multiple devices. I need to know the float or double values returned in the ScaledData variable. The type of ScaledData is TVariant*, and I don't know how to get specific data from it. I also need to know how can I get the different data from different channels in order to have each value in a different Graph. Thanks a lot.
0 Kudos
Message 1 of 4
(3,429 Views)
Hi Ignacio,

The Variant returned inside ScaledData is stored as a 2-D array internally when you sample multiple channels, or a 1-D array if you sample a single channel.
If you want to get the array(s) inside it into VC++, I'd suggest you construct a CNiReal64Matrix (2-D) or a CNiReal64Vector (1-D) as follows:

void CContDAQDlg::OnAcquiredDataCwai1(VARIANT FAR* ScaledData, VARIANT FAR* BinaryCodes)
{
CNiReal64Matrix wave(ScaledData); // constructs a 64-bit floating point 2-D array
m_graph.PlotY(wave); // plot the data in the CWGraph
}

You can do this because the constructors of CNiReal64Matrix and CNiReal64Vector can take Variants and extract the array(s) from it into a new variable, in this case "wave".
To get the data for individual chann
els, you can extract the 1-D arrays inside it. Keep in mind that the data for channel one is stored in the first column of the 2-D array, the data for channel two is stored in the second column, and so on.

Another tip: To index the CNiReal64Matrix variable "wave", you need to use parentheses. For example to get the element in the first row and first column of the 2-D matrix, you need to write:

float myval = wave(0,0); // indexing wave at row 0, column 0

Hope this helps,

Azucena Perez
National Instruments
Message 2 of 4
(3,429 Views)
Thanks Azucena, your answer was very fast and complete, but I think I should have said I'm working with the free Component Works and I cannot have acces to CNi... classes, only to CW... classes, and they don't work in the same way.
0 Kudos
Message 3 of 4
(3,429 Views)
Hi Ignacio,

In that case, it's going to take some real work. I would suggest you look in MSDN for "safearray" and "variant". In C++ the Safearray datatype can hold arrays from VB Variants. It gets more complicated when we have multi-dimensional arrays and we can only blame Microsoft for making VB store 2-D arrays completely different from the way VC++ stores 2-D arrays.

Good luck,

Azucena
0 Kudos
Message 4 of 4
(3,429 Views)