03-06-2012 11:24 AM
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?
Solved! Go to Solution.
03-06-2012 08:43 PM
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.
03-07-2012 03:31 AM
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.
03-07-2012 10:03 AM
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.
03-07-2012 10:17 AM - edited 03-07-2012 10:24 AM
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$$
03-08-2012 05:18 AM
update: I have this working now. Thanks for the help 🙂
03-08-2012 08:36 AM - edited 03-08-2012 08:37 AM
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;
}