.netplotwaveformmeasurement-studio

Plotting AnalogWaveform<TData> on the Waveformgraph with PlotWaveforms method using Measurement Studio 2013 in .Net


I am using Measurement Studio 2013 with VS 2012.

I am fetching data from NI PXI 5122 which I want to plot on the graph. I can clearly see the records when printed in console or even on the gridview but I am unable to plot it on the WaveformGraph. Here is my code:

    static void PlotWaveformsOnGraph(AnalogWaveformCollection<double> waveforms)
     {       
           List<AnalogWaveform<double>> waveformList = new List <AnalogWaveform<double>>(waveforms);
           MainWindow main = new MainWindow();
           main.waveformGraph.PlotWaveforms(waveformList.ToArray());
     }

there is no error in the above code, also the data is present in WaveformList but not plotting on the graph.


Solution

  • Are you creating a MainWindow instance dynamically in your PlotWaveformsOnGraph method because you cannot reach the waveformGraph object from context of the method? If so, you might consider the following:

    1. Passing the waveformGraph object to which you plot your waveforms as a parameter to your PlotWaveformsOnGraph method. This way, you can access the PlotWaveformsAppend method on the waveformGraph from within your static method.

    This might look like:

    static void PlotWaveformsOnGraph(AnalogWaveformCollection<double> waveforms,
       WaveformGraph graph)
    {
        var waveformList = new List<AnalogWaveform<double>>(waveforms);
        graph.PlotWaveforms(waveformList.ToArray());
    }
    
    1. Remove the static keyword from the PlotWaveformsOnGraph method. Assuming PlotWaveformsOnGraph is a member of your MainWindow class, and your window has a WaveformGraph control on it, you can access the waveformGraph from within your method. Do you have a specific reason for making this method static?

    It looks like more progress on this issue is being made here.