Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How to display a char* array with NI graph control?

How to display a char* array with NI graph control?

 

My developing environment is VC2005sp1 + MeasurementStudio8.1.1.

 

It seems that PlotY could only accept CNIVector type as input data source and PlotY could not accecpt char* array or unsigned int array as input data source. Is it true?

 

My data is stored in a large char* array. Each character(or Byte) of this array represents a value point. The size of this char* is of LARGE_INTEGER type. How could I display every Bytes of this char* array with NI graph control?

 

My code looks like this:

     CNiReal32Vector        mNIVectorforDisplay;        // NI vector for display.

//   pYDisplay is the points of char* array.  liSizeofField is the size of this array, which is of LARGE_INTEGER type

     mNIVectorforDisplay    =    CNiReal32Vector(liSizeofField.QuadPart, (char*)pYDisplay);

//   The above two line can work through, while the following trigers an error.

     pWaveGraph->GetPlots().Item("Y").PlotY(mNIVectorforDisplay);    

Would you plz tell me how to realize this scenario?

I’m looking forward to your response and kindly help.

Thank you.

0 Kudos
Message 1 of 5
(6,774 Views)

I need your help...

0 Kudos
Message 2 of 5
(6,765 Views)

Hi

 

I am not very familiar with Measurement Studio, so correct me if I am wrong.

It seems that you mistakenly take method PlotY as function PlotY. From the help doc of Measurement Studio, you could see the differences.

1.JPG

2.JPG

0 Kudos
Message 3 of 5
(6,761 Views)

I partially solve this problem now. I use "for" loop and "=" operator to fufill the task, which is quiet slow and looks ugly.

The code looks like this:

    for (int i=0; i<1000; i++)
    {
        mNIVectorforDisplay[i] = *(LPBYTE)((unsigned char*)((pYData)+i));
    }
    m_Wave.Plots.Item("Y").PlotY(mNIVectorforDisplay);

 

My question is : Could NI Graph control support native C++ arrays and pointers, not wrapped CNIVector** class.

I go through some of the code behind, I found that inside the CNIVector** class constructor, low efficient "for" loop and "=" operator are used to convert a C++ array to

wrapped CNIVector** class. This manner could not be attractive in the need for speed and efficiency.

 

Who can tell me how to solve this problem?

 

0 Kudos
Message 4 of 5
(6,712 Views)

The graph can take in a char* and plot it to the graph directly without having to use a for loop.

 

Here is partial code that uses a char array and sends it to a waveform graph. You might want to try something similar to this:

 

 

char* data;
double value;
long size = 10;
long x = 0;
data = new char[size];

for(x = 0; x < size; x++)
{
   const double maxValue = 10.0;
   value = (double)rand() / RAND_MAX * maxValue;
   data[x] = (char)floor(value);
}

m_Graph.PlotY(CNiUInt8Vector(size, data));
delete[] data;

 

Hope this helps!

 

Chris T.
0 Kudos
Message 5 of 5
(6,677 Views)