04-02-2015 11:06 AM - edited 04-02-2015 11:10 AM
I have a windows application written in Visual C# 2012. I am capturing Analog Input from a USB 6009 DAQ card.
I am using MStudio's ScatterGraph component to read the analog input signal from the DAQ device. However, majority of the times, the graph crashes and I get a white box with a red X on it! See screenshot of the crash.
Note that the analog input data is still being loaded into the application, since I am able to compute the average peak signal and have it displayed on a text box, but it just that the real time update of the data cannot be seen. I have to close out of the application and re-run it and hope everytime that it doesn't crash again! The application uses a async call to allow for analog I/O without freezing up the application when any process is in progress!
Desperately need help to fix this before I can build a commercial version of this application. Does mstudio allow logging the crash info somewhere within the application or Visual Studio to debug the problem related to this scattergraph object? Any other alternatives? Thank you very much for your assistance.
04-03-2015 04:37 PM
Hi,
Do you know of any pattern that seems to cause this error to occur or does it seem to occur somewhat randomly? Visual Studio can log crashes as described in brief here: https://msdn.microsoft.com/en-us/library/ms241272.aspx, however if an error isn’t being thrown the IDE may not view it as a crash. You should be able to use any Visual Studio debugging tools with Measurement Studio.
-Kevin
04-04-2015 01:57 PM - edited 04-04-2015 01:59 PM
Thanks Kevin.
It doesn't throw an error in VStudio v11 2012 and that is part of the problem. I have monitored the 'output' in VStudio after each step in the application, but there is no error to be seen. I am guessing it is because the graph is a mstudio component as opposed to one that is coded up from ground up?
As regards a pattern, I have observed that it only occurs in the first few seconds after capturing the analog signal on the graph. Once the graph has run successfully for say over 10 seconds, then rarely does it ever crash after that!! I have seen it run without problem for more than an hour after that initial shaky phase! The graph crash rate (in the first 10 seconds) is estimated at over 80%!! So, I have to keep re-running the solution file until the graph doesn't crash in the first 10 seconds and then I am good to go. Does that tell you something? Thanks again. - Sid
04-06-2015 02:30 PM
It should still be registering any errors that it sees with Measurement Studio components. Its interesting that this error will be avoided around 10-20% of the time. Typically behavior like that suggests something like a race condition causing the graph to somehow be in an inconsistent state. You may want to double check that your application is doing operations in an order that you expect.
-Kevin
04-07-2015 01:22 AM
Hi,
I had the same problem just lately.
It's was caused by trying to update the Graph from a thread that isn't the UI thread.
In Vb.net the solution for me was: -
Delegate Sub updateGraphUI()
Private Sub ()
' InvokeRequired required compares the thread ID of the
' calling thread to the thread ID of the creating thread.
' If these threads are different, it returns true.
If Me.Graph.InvokeRequired Then
Dim updateGraph As New updateGraphUI(AddressOf Me.updateGraph)
Else
updateGraph()
End If
End Sub
Private Sub updateGraph()
Me.Graph.PlotY(_ydata(_activeChannel), StartX, deltaX)
End Sub
StevieB
04-08-2015 12:30 PM
Thanks Kevin and StevieB. I wil check on both your solutions and report back. - Sid
04-11-2015 05:31 PM - edited 04-11-2015 05:32 PM
Kevin and StevieB (or anybody else please),
I am back after some troubleshooting, but still haven't figured out a solution to the graphing crash. Here are things for your kind review (notepad++ renders it well):
1. I have attached the activitylog.xml file and there are no errors in there. Does this still tell you something?
2. I am also sending you code for the graphing function with comments. Would you please take a look at it and see where the problem is? StevieB, your code is great, but not entirely clear to me 😞 May be the attached snippet can help you pinpoint the problem?
3. Specific to the graphs dll, I see that under file description of 'NationalInstruments.Controls.Graphs.dll', it states NI WPF Graph Control, while my application is a Windows Form Application. Does that matter?
Thank you very much for your help and suggestions.
Sid
04-16-2015 01:40 PM
Anybody who can help, please? Thank you. Sid
04-17-2015 04:09 PM
Sid,
The code snippett you provided should work. If possible you may want to contact NI support (ni.com/contact-us/) to have an engineer look specifically at this problem.
Kevin