Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to plot AnalogWaveform data on a Tank object?

hello,do you solve this problem? i have the same proble,can you teach me the way  you get the data and plot the data in the tank?

0 Kudos
Message 11 of 19
(2,512 Views)

Hi tangjkd,

 

Can you tell us what you have done so far?

 

G-IV

0 Kudos
Message 12 of 19
(2,494 Views)

Tangjkd, sorry I did not have the time to finish this yet. After reading the replies from the other members, I realized my mistake and I’m going to try and attempt to solve this on my own, just haven’t had time yet.  My mistake, was that I was trying to plot an array to a tank object, which you cannot do.  What I was going to do was, take an average of the array and plot that to the tank instead, then repeat as necessary. 

0 Kudos
Message 13 of 19
(2,486 Views)

Hello, 

 

I've been able to get the data to plot on a Waveform graph using the Daq Assistant:

 

private void daqTaskComponent1_DataReady(object sender, DaqTaskComponentDataReadyEventArgs e)

        {

            System.Threading.Monitor.Enter(daqTaskComponent1);

            NationalInstruments.AnalogWaveform<double>[] acquiredData = e.GetData();

            waveformGraph1.PlotWaveforms(acquiredData);

            System.Threading.Monitor.Exit(daqTaskComponent1);

        }

 

But I don’t want the waveformgraph,I hope the data can be displayed in some other controls like Tank or Thermometer, I know I can’t plot the Array Variable to a tank object,because the tank control need a value :

 

tank1.Value = 10;

 

so how should I deal with the” NationalInstruments.AnalogWaveform<double>[] acquiredData”,maybe I can take an average or one element of the array and plot that to the tank instead,but can you teach me the way taking an average or one element of the array. Any help is greatly appreciated.

0 Kudos
Message 14 of 19
(2,468 Views)

thinks,if you solve your proble ,can  you share your code with me?

0 Kudos
Message 15 of 19
(2,466 Views)

Hi tangjkd,

 

I don't know how much research you have done up to this point, but if you are interested in being able to manipulate the data from an AnalogWaveform<double> variable, you could approach it like this:

 

1) Get the array by using GetRawData()

Let's say you are looking at the GlobalContinuousAI_USB example that ships with Measurement Studio. The data variable is an array of 5 channels.  To get the data from one of the five channels, index the data array by using an index value between 0-4:

AnalogWaveform<double> channel0 = data[0];

Now that you have one channel, you can use GetRawData() to get a double:

double[] rawData = chennel0.GetRawData();

2) To get the average of the data, you could simply use:

double sum = 0.0;
foreach (double value in rawData)
   {
      sum += value;
   }
double avg = sum / rawData.GetLength(0);

3) To get a particular value out of the array, just index the array:

double someValue = rawData[5];

G-IV

0 Kudos
Message 16 of 19
(2,435 Views)

Instead of G-IV's step 2, I would recommend:

 

// Top of your file
using System.Linq;

// Other code
double average = rawData.Average();
Daniel Dorroh
National Instruments
0 Kudos
Message 17 of 19
(2,430 Views)

think you very much,do you have the GlobalContinuousAI_USB example's code?

0 Kudos
Message 18 of 19
(2,403 Views)

i have made it ,think you for your help again

0 Kudos
Message 19 of 19
(2,391 Views)