Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

NI MS UI for C#.NET (waveformGraph) Pls Help me~~~ urgent!!!

Pls Help me~~~ urgent!!!

Pls advise on how to set the waveformGraph to display a certain values (changing) Vs Time (assume the values in the format of array / a groups of numbers / integers, any NI MS Manual for C#.NET (I just have the NI MS Manual for VB.NET)???
0 Kudos
Message 1 of 10
(6,940 Views)
There are two things to consider here: 1.) The property configuration for the user interface such that the axis labels display date/time information, and 2.) the conversion factor between date/time and numeric values.

For 1.), look at the MajorDivisions property on the X axis (assuming you want the date/time labels on the X axis), then look at the LabelFormat property. The format string can be any of the standard .NET format strings that are supported by DateTimeFormatInfo and there are several canned formats available in the LabelFormat editor at design-time.

For 2.), the DateTime/double conversion factor that the Measurement Studio graphs use is a double value of 0.0 is equivalent to DateTime.MinValue and a double interval of 1.0 is equivalent to 1 second. The NationalInstruments.DataConverter class will convert from/to double and TimeSpan with this conversion factor.

Here is an example that generates arrays of time and data values, configures the axis to display date/time labels, and plots the data in a ScatterGraph:


// Configure the X axis to display date/time labels.
xAxis1.MajorDivisions.LabelFormat = new FormatString(FormatStringMode.DateTime, "h:mm");

const int sampleCount = 60;

// Create an array of DateTime values that start at midnight and continues at
// one minute intervals for an hour.
TimeSpan interval = TimeSpan.FromMinutes(1);
DateTime[] times = new DateTime[sampleCount];

times[0] = DateTime.Today;
for (int i = 1; i < sampleCount; ++i)
times[i] = times[i - 1] + interval;

// Convert the array of DateTime values to an array of doubles for the graph.
double[] timeValues = (double[])DataConverter.Convert(times, typeof(double[]));

// Create an array of sample values to plot against the time values.
double[] dataValues = new double[sampleCount];
Random rnd = new Random();

for (int i = 0; i < sampleCount; ++i)
{
dataValues[i] = rnd.NextDouble() * 10;
}

// Plot the sample values against the time values on the ScatterGraph.
scatterGraph1.PlotXY(timeValues, dataValues);


Note that this example uses the ScatterGraph instead of the WaveformGraph because ScatterGraph plots an array of values against another array of values, but the WaveformGraph plots an array of values against a start time and a fixed interval.

Hope this helps.

- Elton
0 Kudos
Message 2 of 10
(6,904 Views)

@cm2009 wrote:
...any NI MS Manual for C#.NET (I just have the NI MS Manual for VB.NET)???




I'm not sure what you mean by this. The Measurement Studio .NET class library online help is mostly language agnostic. The only language-specific parts of the help are code snippets; we provide both VB.NET and C# code snippets. If you are not seeing C# code snippets, you might have your MSDN help viewer configured to show only VB.NET. What are you seeing that looks like VB.NET-only help without corresponding C# help?
0 Kudos
Message 3 of 10
(6,895 Views)
Thanks for Elton’s reply (really useful info)!

BTW, I may need to use the WaveformGraph (instead of ScatterGraph, because the graph output / format in waveform is much better for our project) so what would be the difference if I use waveformGraph (according to the code)??? How could I find those related waveformGraph sample coding (actually I have tried the one installed in my local directory (when installed NI MS), but not sufficient...)

On the other hand, for the manual, where can I find the “MS .net class library online help” (in fact, I just have the hardcopy of the manual (VB.NET)?
0 Kudos
Message 4 of 10
(6,875 Views)
I misread your original post. I thought that the note in parentheses after "... Vs Time ..." was referring to time when it said that the format was an array of values, but I realize now you were referring to the values. The code for the WaveformGraph in this case is much simpler because WaveformGraph has PlotY overloads that accept DateTime and TimeSpan for the start and increment respectively. These overloads handle the conversion factor that I described above. For example, here's the WaveformGraph equivalent of the ScatterGraph example that I posted above:


// Configure the X axis to display date/time labels.
xAxis1.MajorDivisions.LabelFormat = new FormatString(FormatStringMode.DateTime, "h:mm");

const int sampleCount = 60;

// Specify the start time as midnight today and specify the interval such
// that there is one sample per minute.
DateTime start = DateTime.Today;
TimeSpan interval = TimeSpan.FromMinutes(1);

// Create an array of sample values to plot against the time values.
double[] dataValues = new double[sampleCount];
Random rnd = new Random();

for (int i = 0; i < sampleCount; ++i)
{
dataValues[i] = rnd.NextDouble() * 10;
}

waveformGraph1.PlotY(dataValues, start, interval);


- Elton
0 Kudos
Message 5 of 10
(6,864 Views)

@cm2009 wrote:
On the other hand, for the manual, where can I find the “MS .net class library online help” (in fact, I just have the hardcopy of the manual (VB.NET)?



The Measurement Studio help is integrated directly into the MSDN help that installs with Visual Studio .NET 2003. there are a few ways to get to the help:

  1. Start>>Programs>>National Instruments>>Measurement Studio 7.1 for VS.NET 2003>>Measurement Studio Docuentation.

  2. Put the cursor on a Measurement Studio data type, property, or method within the Visual Studio .NET source editor and press F1.

  3. In Visual Studio .NET 2003, click the Measurement Studio menu and choose NI Measurement Studio Help.

  4. In Visual Studio .NET 2003, click the Help menu and choose any of Contents, Index, or Search.



If none of these options work for you, there is probably an install problem. Let us know if you are able to find this help.
0 Kudos
Message 6 of 10
(6,853 Views)
Thanks Elton & drohacek.

By the way, just some queries:

1. Refer to the coding (Elton), it seems that the data inputs (y-axes) are random values, if I want to set the values as some integers (got from the serial port device), as well as the graph should be moving, right? as it gets the input constantly, then how can I do for the coding? (the existing one is perfect for my demo, ha!)

2. Can NI MS use in other open source languages say Java? Can I integrate them?

Thanks in advance!
0 Kudos
Message 7 of 10
(6,839 Views)
1.) It sounds like you want the graph to strip chart the data. Is that correct? If so, set the XAxis.Mode property to AxisMode.StripChart, then use the WaveformGraph.PlotYAppend method instead of WaveformGraph.PlotY.

2.) You can use any Common Language Specification (CLS) compliant .NET language with the Measurement Studio .NET libraries. If you want to use the Java language in your .NET application, your best option would be Visual J#. If you're wanting to write a .NET application that can also use Java libraries, there are several .NET/Java bridges available. I've looked at IKVM.NET and I've seen a few applications that use it and it seems pretty good. There are several more if you search on Google.

- Elton
0 Kudos
Message 8 of 10
(6,826 Views)
Thanks!

Can you guide me on writing the program (step-by-step approach)? As I am new on writing programs in Microsoft C# .NET as well as the Measurement studio (I have tried, but fail :-<), by the way, some queries as follows:

1. How to write the codings to display the waveformGraph (numbers Vs Time), I think it should have several sections, rights?

(a. dataManager - get the data and convert the data into certain format (I have tested to use the Hyperterminal to get the data, it works, but the data is in hash format.)

(b. displayManager - display the converted data in the waveformGraph.)

(c. scrollManager - allos the users to view the history of the graph - scroll backward, maybe users can first pause and then click to see the previous waveform.)

2. How to use the thermometer display UI to show the status of the thermometer (may get the values - numbers repeatedly in certain time period) (actually, where I could find the UI fro thermometer in C#.NET under the toolbars and aslo how to set the value display?)

Pls kindly advise!!!
0 Kudos
Message 9 of 10
(6,786 Views)
Best place to learn about programming in C# with MStudio would be the example programs located at C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\UI\Graph. For more help on Measurement Studio please refer to comments by drohacek

For dataManager, I would suggest you get the string data and parse it for the hash values in a loop. There are some C# commands that help in the conversion. Please refer to the conversion functions available in C# at .NET Framework Class Library. Also, you might want to look at Verifying a Hash.

For displayManager you can refer to the code provided by Elton earlier. All you need to do is Create a New Measurement Studio C# Project, add a graph and include the code above in the code view.

For scrollManager, you will need to keep track of the historical data programatically and display it based on the user events.

The thermometer UI Control should be located in the easurement Studio .NET Controls Palette. If it is not visible then "right click" on the palette select "add items" and in the list select "Thermometer".

I hope it helps,
Rajiv
0 Kudos
Message 10 of 10
(6,750 Views)