Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Why is WaveformGraph.ZoomXY not working?

I am using Measurement Studio .NET 7.0
 
I have the following code:
 

private void PlotData(System.Byte[] oDataArray)

{

double nNumberOfPoints = 65536.0;

double nSampleRate = 1000000.0;

// Convert and Normalize the Data Byte[] to a Double[]

double[] oYData = new double[nNumberOfPoints];

for(Int32 nIndex = 0; nIndex < nNumberOfPoints; nIndex++)

{

    oYData[nIndex] = System.Convert.ToDouble(oDataArray[nIndex]) / System.Convert.ToDouble(System.Byte.MaxValue);

}

// Set the X Delta to milliseconds

double nDeltaX = (1.0 / nSampleRate) * 1000.0;

// Plot the Data Double[]

this._oGraph.PlotY(oYData, 0.0, nDeltaX);

// Change the X-Axis range of the Time Domain

this._oXAxis.Range = new NationalInstruments.UI.Range(0.0, (nDeltaX * nNumberOfPoints)); // 0.0 to 65.536 milliseconds

// Change the Y-Axis range of the Time Domain

this._oYAxis.Range = new NationalInstruments.UI.Range(0.0, 1.0); // Always Normalized

// Set an initial zoom for the user, he needs to be able to zoom out from this point if he wants to.

// ZoomX into the first 10 milliseconds of data.

this._oGraph.ZoomXY(this._oTimeDomainPlot, 0.0, 0.0, 10.0, 1.0); // <--*** This never works ***

}

0 Kudos
Message 1 of 4
(3,706 Views)
I couldn't find where the _oTimeDomainPlot was declared. I need to know what kind of data this is, Xplot, YPlot or XYPlot. This needs to be an XYPlot. I noticed that earlier you used the PlotY method.

this._oGraph.PlotY(oYData, 0.0, nDeltaX);

to plot the data. Please tell me which language you are using, C# or C++? If possible, please zip up your program so I can see all of the code.

Thank you

Nandini
NI
0 Kudos
Message 2 of 4
(3,686 Views)
Sorry for the confussion.  I had pulled it over to another project to "clean" it up before submitting here.  I missed somethings.  Anyways, thank you for looking at it, but I seem to have found the problem --> Measurement Studio 7.0.  I tried it on a system with Measurement Studio 7.1 loaded, and it works fine.  Measurement Studio 7.0 is so buggy.  So many bugs, so little time.
0 Kudos
Message 3 of 4
(3,681 Views)

This code segment works in Mesaurement Studio 7.1, but as far as 7.0 it does not.

The ZoomXY never works on the screen, but it does raise the Zoom Event.

 

using System;

using System.ComponentModel;

using System.Drawing;

using System.Windows.Forms;

using NationalInstruments;

using NationalInstruments.UI;

using NationalInstruemtns.UI.WaveformGraph;

namespace TestWaveformGraph

{

public class Form1 : System.Windows.Forms.Form

{

private Container _oComponents = null;

private WaveformGraph _oGraph = null;

private XAxis _oXAxis = null;

private YAxis _oYAxis = null;

private WaveformPlot _oPlot = null;

public Form1()

{

InitializeComponent();

double nFrequency = 5;

int nNumberOfPoints = 65536;

int nSampleRate = 1000000;

PlotData(CreateTestData(nNumberOfPoints, nFrequency), nSampleRate);

}

[STAThread]

static void Main()

{

Form1 oMainForm;

oMainForm = new Form1();

Application.Run(oMainForm);

}

protected override void Dispose(bool bDisposing)

{

if(bDisposing)

{

if(this._oComponents != null)

{

this._oComponents.Dispose();

}

}

base.Dispose(bDisposing);

}

#endregion

private void InitializeComponent()

{

this._oGraph = new WaveformGraph();

this._oPlot = new WaveformPlot();

this._oXAxis = new XAxis();

this._oYAxis = new YAxis();

((ISupportInitialize)(this._oGraph)).BeginInit();

this.SuspendLayout();

// _oGraph

this._oGraph.Caption = "Time Domain";

this._oGraph.Dock = DockStyle.Fill;

this._oGraph.InteractionMode = GraphInteractionModes.DragCursor;

this._oGraph.Location = new Point(0, 0);

this._oGraph.Name = "_oGraph";

this._oGraph.Plots.Add(this._oPlot);

this._oGraph.Size = new Size(648, 366);

this._oGraph.TabIndex = 0;

this._oGraph.XAxes.Add(this._oXAxis);

this._oGraph.YAxes.Add(this._oYAxis);

// _oPlot

this._oPlot.XAxis = this._oXAxis;

this._oPlot.YAxis = this._oYAxis;

// _oXAxis

this._oXAxis.Caption = "Time (milliseconds)";

// _oYAxis

this._oYAxis.Caption = "Amplitude (Normalized)";

// Form1

this.AutoScaleBaseSize = new Size(5, 13);

this.ClientSize = new System.Drawing.Size(648, 366);

this.Controls.Add(this._oGraph);

this.Name = "Form1";

this.Text = "Form1";

((ISupportInitialize)(this._oGraph)).EndInit();

this.ResumeLayout(false);

}

private Byte[] CreateTestData(int nNumberOfPoints, double nFrequency)

{

double nAmplitude = .5;

double nOffset = .5;

double nPi = System.Math.PI;

double nPoints = Convert.ToDouble(nNumberOfPoints);

byte[] oDataArray = new byte[nNumberOfPoints];

for(int nIndex = 0; nIndex < oDataArray.Length; nIndex++)

{

double nY = nOffset + nAmplitude * Math.Sin(nFrequency * Convert.ToDouble(nIndex) * 2.0 * nPi / nPoints);

oDataArray[nIndex] = Convert.ToByte(nY * Convert.ToDouble(Byte.MaxValue));

}

return oDataArray;

}

private void PlotData(byte[] oDataArray, int nSampleRate)

{

double[] oYData = new double[oDataArray.Length];

for(int nIndex = 0; nIndex < oDataArray.Length; nIndex++)

{

oYData[nIndex] = Convert.ToDouble(oDataArray[nIndex]) / Convert.ToDouble(Byte.MaxValue);

}

double nDeltaX = (1.0 / Convert.ToDouble(nSampleRate)) * 1000.0;


this._oPlot.PlotY(oYData, 0.0, nDeltaX);


this._oXAxis.Range = new Range(0.0, (nDeltaX * Convert.ToDouble(oDataArray.Length)));


this._oYAxis.Range = new Range(0.0, 1.0);

//************* The next line does not work in Measurement Studio 7.0, but works in 7.1 ***************


this._oGraph.ZoomXY(this._oPlot, this._oXAxis.Range.Minimum, this._oYAxis.Range.Minimum, (this._oXAxis.Range.Maximum / 4.0), this._oYAxis.Range.Maximum);

}

#endregion

}

}

0 Kudos
Message 4 of 4
(3,677 Views)