Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems plotting data from a data source

Solved!
Go to solution

Visual Studio 2010, Measurement Studio 2010 standard, C#, .NET

 

 

I made a new NI Windows (forms) Application. Added a MySQL database as a datasource, added a table control to check data is there....yes displayed fine.

 

Next I put in a NI WaveformGraph. Right-click, properties, data, databindings, binding data and added the datasouce.

 

compile, nothing, no plot.

 

any ideas?

0 Kudos
Message 1 of 7
(4,826 Views)

The waveform uses the WaveformGraph.BindingData property for binding to a data source which has the attribute as Browsable(false).

 

1) The data that is assigned to through the binding should be one of the following,

double[]

double[,]

AnalogWaveform<double>

AnalogWaveform<double[]>

AnalogWaveform<double[,]>

ComplexWaveform<ComplexDouble>

ComplexWaveform<ComplexDouble[]>

ComplexWaveform<ComplexDouble[,]>

 

2) See if the Binding related properties are set correctly in order to cosume the data by the BindingData property. For example, you cannot set BindingMethod to PlotWaveformAppend and suply data as double[]. Because the graph is expecting a waveform but data supplied is double[].

 

If everything fails, you can use,

 

WaveformGraph.BindingData = <your data here>;

or

WaveformGraph.PlotXXXXXX(<your data here>);

 

 

Vijet Patankar,

National Instruments.

0 Kudos
Message 2 of 7
(4,820 Views)

Thanks for replying! Help much appreciated.

 

Here is my little test app showing there is a data binding setup for the mysql table considting of double, float and in columns. The top graph shows a plot I do manually like this:

double[] data = new double[] { 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0 };
waveformPlot1.PlotY(data);

 

This bottom graph show my attemp at binding data in to the plot....see graph properties on the right....I choose the "double" column to bind too.

 

No joy.

 

So far from what I have read.....if you want to plot from a datasource you have to: have "double" datatype, use "waveformgraph", bind data in properties, data in columns, PlotY. I did all that...

 

Perhaps an expert programmer is needed here, I just thought that with these tools I could get this going with a minimum of programming.

 


ni datasource test

 

 

 

 

 

 

 

0 Kudos
Message 3 of 7
(4,816 Views)

Hi there,

 

We are sorry, as the solution that we gave didn't work out for you.

Could you please attach that test project so that we can take a keen look at what you are trying to do and why it is not working.

 

Vijet Patankar,

National Instruments.

0 Kudos
Message 4 of 7
(4,811 Views)

Great thanks. Attached is the test project...

 

also this was the create statement for my mysql table

 

delimiter $$

CREATE TABLE `pgs`.`ni_test` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`double` double NOT NULL,
`float` float NOT NULL,
`int` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1$$

 

0 Kudos
Message 5 of 7
(4,807 Views)

update: I have this working now. Thanks for the help 🙂

0 Kudos
Message 6 of 7
(4,787 Views)
Solution
Accepted by topic author dr_white

I'll write in here what it was so it is available for any other C# newbie who may have the same issue.

 

The problem was my understanding of how "binding" works. I had the binding setup fine to the database but the values had not been read out. I ended up doing this:

 

private void load_DB_data_and_plot(object sender, EventArgs e)
{
waveformPlot2.PlotY(getCol("meter_out"));

}

 

private double[] getCol(string col_name)
{
int col_index = 0;
foreach(DataColumn col in getColumns() )
if (col.ColumnName == col_name)
col_index = getColumns().IndexOf(col);

 

double[] values = new double[getRows().Length];
for (int i = 0; i < getRows().Length; ++i)
{
values[i] = Convert.ToDouble(getRows()[i].ItemArray[col_index]);
}
return values;
}

 

 

0 Kudos
Message 7 of 7
(4,785 Views)