Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Real Acquisition application with Measurement Studio and ASP.NET 3.5

Solved!
Go to solution

Hello!

 

I am trying to create a windows form application with visual studio 2008 that allows me to acquire signals from NI USB 6009 and store data into a network variable. Data type that results from my acquisition is AnalogWaveform<double>[]. Then I want to view that acquisition using a thin client application developed with ASP.NET 3.5 and Measurement Studio 8.6 Enterprise  on a simple waveform graph. The problem appers in my presentation stage, on ploting the waveform on the graph...in Autorefresh's Refresh function. I saw some examples on Data Acquisition with Network Variable....but the acquisition there was software simulated.

I need some help with the Refresh function, when I'm supposed to plot the data from my network variable.

In the example code from NI I found a member for the GraphWaveform called DataBind, but in NI MS 8.6 I can't find that anymore....

 

0 Kudos
Message 1 of 7
(5,432 Views)

You will need to Add a Network Variable Data Source to the Designer, select Edit Bindings and bind to the network variable you want to be displayed on your Measurement Studio Waveform Graph.


datasource.png


Then you can add a FormView control to the Designer and set the Data Source to the Network Variable Data Source control that you just added. You can then select Edit Templates in the FormFiew smart tag and add controls that you want to be visible on the web site.


designer.png


You can delete the populated binding that appears by default. Drag the Measurement Studio Waveform graph into this FormView control and select Edit DataBindings on the Waveform Control.


waveform.png

Here you can specify the binding to the variable that you configured in the Network Variable Data Source.


binding.png
 

You can now select End Template Editing for the FormView Control.

endediting.png


To AutoRefresh the Controls in the Form View, add a Measurement Studio AutoRefresh control to the Designer and select Edit Default Refresh Items.


refresh.png

 


Select Add and TYPE the name of the Waveform Graph control that was added to the FormView control.


refreshcontrols.png

 


Select Debug»Start without Debugging. Your Waveform Graph should now bind the network variable and automatically refresh on the web page.


Should you want to refresh pragmatically you can reference the Measurement Studio User Manual Chapter 5 Walkthrough:Walkthrough: Creating a Measurement Studio Application with Web Forms Controls and Network Variable

-Adri Kruger

Adri Kruger
National Instruments
LabVIEW Product Marketing
Message 2 of 7
(5,395 Views)

Thanks for the idea, I've tried that before and no result.

 

My WindowsForms application for the acquisition code looks like:

 

[...]

 

#region vars
            private string _networkVariablePath;
            public NetworkVariableWriter<AnalogWaveform<double>[]> myNetworkVariableWriter;

        #endregion

        public void Initialization()
        {
            _networkVariablePath = @"\\localhost\system\myVariable";
            myNetworkVariableWriter = new NetworkVariableWriter<AnalogWaveform<double>[]>(_networkVariablePath);
            myNetworkVariableWriter.Connect();
        }

[...]

 private void daqTaskComponent1_DataReady(object sender, DaqTaskComponentDataReadyEventArgs e)
        {
            
            NationalInstruments.AnalogWaveform<double>[] acquiredData = e.GetData();
            
            myNetworkVariableWriter.WriteValue(acquiredData);


            waveformGraph1.PlotWaveforms(acquiredData);
        }

[...]

 

I have a continuous data acquisition there and that part is working properly.

 

winappl.jpg

 

My problem appears at ploting data on the waveformgraph

not_working.jpg

Help please 😞

 

Thanks a lot

0 Kudos
Message 3 of 7
(5,388 Views)
Are you using the NetworkVariableDataSource to bind the the network variable?

I have attached example code to write to a network variable using a console application and an ASP.NET application that binds to this network variable and displays it on a Measurement Studio WaveformGraph.

Instructions for running this example code:

1. Run the WritingDataFromConsole Application and keep it running.
2. Then run the ReadingNetworkVariable ASP.NET application.

note that you will need Measurement Studio 8.6 Professional or Enterprise and Visual Studio 2008.

-Adri Kruger
Adri Kruger
National Instruments
LabVIEW Product Marketing
0 Kudos
Message 4 of 7
(5,374 Views)
Well, I know that project. I have Visual Studio 2008, Measurement Studio 8.6 Enterprise, DAQmx driver for NI USB 6009, and NI USB 6009 acquisition card. I know the code from Measurement Studio User Manual. The problem comes when I'm trying to plot data acquired real time from the NI USB 6009. When I use software generated signals everything works fine.
0 Kudos
Message 5 of 7
(5,371 Views)

KarinaA,

 

I just tested the code Adri posted, and all I had to do was publish the live data to a network variable, then bind the Waveform Graph to that variable.  All I had to do was to open the code by going to File»Open»Web Site, then select the ReadingNetworkVariable folder.  This opened the ReadingNetworkVariable project.  I then selected the "NetworkVariableDataSource" item at the top of the Default.aspx designer page, clicked on the arrow to the right of it and selected "Edit Bindings".  From there I could modify the Location property of Bindin1 to be my variable.  After that, I just ran the webpage and it worked.  What problems are you seeing?

 

EDIT: I should note that I was using live data.  I had a simple VI reading in data from a DAQ card and publishing it to a network variable.

Message Edited by Eric B. on 07-13-2009 05:14 PM
Eric B.
National Instruments
0 Kudos
Message 6 of 7
(5,328 Views)
Solution
Accepted by topic author KarinaA

I found a solution

 

p1.jpg

 

 private void Acquisition()
{
if (_runningTask == null)
{
try
{


_myTask = new Task();


_myTask.AIChannels.CreateVoltageChannel(textBox1.Text,"", AITerminalConfiguration.Differential, Convert.ToDouble("-10"),
Convert.ToDouble("10"), AIVoltageUnits.Volts);


_myTask.Timing.ConfigureSampleClock("",numericEdit2.Value, SampleClockActiveEdge.Rising,
SampleQuantityMode.ContinuousSamples, Convert.ToInt32(numericEdit1.Value));


_myTask.Control(TaskAction.Verify);


_runningTask = _myTask;


_myTask.Stream.ReadOverwriteMode =
ReadOverwriteMode.OverwriteUnreadSamples;


myAnalogSingleChannelReader = new
AnalogSingleChannelReader(_myTask.Stream);


analogCallback = new
AsyncCallback(MyAnalogSingleChannelReaderCallback);


myAnalogSingleChannelReader.BeginReadMultiSample(Convert.ToInt32(numericEdit2
.Value), analogCallback, _myTask);
}
catch (DaqException exception)
{
MessageBox.Show(exception.Message);
_myTask.Dispose();
this.switch1.Value = false;
}
}
}

 

 

 

 

private void MyAnalogSingleChannelReaderCallback(IAsyncResult
asyncresult)
{
try
{
if (_runningTask == asyncresult.AsyncState)
{
_myData =
myAnalogSingleChannelReader.EndReadMultiSample(asyncresult);


long newSamples =
_myTask.Stream.TotalSamplesAcquiredPerChannel -
_myTask.Stream.CurrentReadPosition;


if (newSamples <
_myTask.Stream.AvailableSamplesPerChannel)
{


_myTask.Stream.ReadRelativeTo =
ReadRelativeTo.CurrentReadPosition;


_myTask.Stream.ReadOffset = 0;
}
else
{
_myTask.Stream.ReadRelativeTo =
ReadRelativeTo.MostRecentSample;


_myTask.Stream.ReadOffset = -
(int)_myTask.Stream.AvailableSamplesPerChannel;


}
this.textBox6.Text = "Writing to DoubleArray...";
myBufferedWriter.WriteValue(_myData);
waveformGraph1.PlotY(_myData);
myAnalogSingleChannelReader.BeginReadMultiSample(Convert.ToInt32(numericEdit2
.Value), analogCallback, _myTask);
}
}
catch (DaqException exception)
{
MessageBox.Show(exception.Message);
_runningTask = null;
_myTask.Dispose();
}
}

 

Message Edited by KarinaA on 07-22-2009 07:34 AM
0 Kudos
Message 7 of 7
(5,267 Views)