11-08-2013 04:45 AM
Hello,
I'm trying to follow the example from the Getting Started with Measurement Studio (VS2010), creating a Measurement Studio NI-DAQmx Application.
I added my Task to a fresh c# WPF application and the next step should be using the DAQmx User Control-Assistant to add the graph to my GUI, except theres no such assistant :manindifferent:
Those are all the options I get offered by MeasurementStudio
Im using VS2010, Developer Suit with MS 2012
11-08-2013 03:34 PM
As of Measurement Studio 2013, the DAQmx GUI generator is only available for Windows Forms. You can use the NI DAQ Windows Application project template to see the kind of code that is generated.
In general, the GUI generator adds a graph and a button to an empty form, add makes the appropriate call to the DAQ component in the button click handler. To adapt this for WPF, simply assign the resulting data to the DataSource of a WPF graph, rather than calling one of the Plot___ methods exposed by the Windows Forms graphs.
11-12-2013 07:36 AM
Hello,
I did exactly what you suggested, but I still have a little problem.
I have my DaqTask.mxb and MainWindow
I bound the graph.DataSource to AnalogWaveform data - (declared it public to access it from my MainWindow file)
Then I StartReading() from my instance of DaqTaskComponent.
That code runs (not so) fine, its way to demanding to the CPU.
Normally I would use a thread or timer to funnel the data , but how is this accomplished with WPF and DataBinding?
Some example would be appreciated
Thanks
11-12-2013 01:31 PM
From your description it sounds like you have a task configured to acquire continuously, and are saving the new waveform from the data event to a public property named data, with a graph using DataSource="{Binding data}" or a similar binding.
If that is the case, then the only requirement should be that the data property raises a change notification when it is updated (either by using a dependency property, or implementing INotifyPropertyChanged, or some other other binding source supported by WPF).
11-13-2013 05:41 AM
Followed your advice but the CPU consumption is still thru the roof, task manager says 50-60%
Running the MXB file in my solution takes maybe 2%
Can you take a look on whats the cause of this?
11-14-2013 06:46 AM
When I only display 4 of my 16 channels the graph runs fairly smooth (15% cpu usage)
8ch still possible, but 30%
12ch 40-45%, "lagging" graph
16ch 60% but whole window gets unresponsive
there a approx. 10 data refreshes per second with the standard setting of 100 samples per channel
There must be some way to optimize this ![]()
11-14-2013 10:37 AM
From your code, it looks like you are already using many of the settings from the Optimizing the WPF Graphs topic. When I run the application you attached last time, I do not experience any slow down (it remains responsive using about 30% of my CPU with all 16 channels on a simulated device). I would recommend using a profiler to narrow down where the slowdown occurs.