03-01-2016 03:06 AM
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?
03-02-2016 08:17 AM
Hi tangjkd,
Can you tell us what you have done so far?
G-IV
03-02-2016 08:28 AM
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.
03-03-2016 12:33 AM
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.
03-03-2016 12:38 AM
thinks,if you solve your proble ,can you share your code with me?
03-04-2016 09:49 AM
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
03-04-2016 10:14 AM
Instead of G-IV's step 2, I would recommend:
// Top of your file using System.Linq; // Other code double average = rawData.Average();
03-06-2016 06:04 AM
think you very much,do you have the GlobalContinuousAI_USB example's code?
03-06-2016 10:17 PM
i have made it ,think you for your help again