Real-Time Plotting

Jan 19, 2012 at 7:43 PM

Hello,

I had used D3 (non-direct-x) previously in one of my projects but now have found a project in which I need to plot thousands of points and real-time plotting similar to what one would see in a scope. I have successfully compiled and run the code from Source Code and am able to plot lots of points, but is there a way to update this real-time? Also, with D3 I used to be able to add a plot with an empty data source (observableDataSource) which then I could append to (again, for real-time purposes using ApendAsync(Dispatcher, Point); however if I insert an empty plotter I get an exception listed below. Also, if I start appending points, I don't see the graph updating "real-time" .

Would you be able to provide an example on how to achieve real-time plotting and also comment on the ability of having a plot with an empty data source?

Thanks!

 

Exception:

System.IndexOutOfRangeException was unhandled  Message=Index was outside the bounds of the array.  Source=SlimDX  StackTrace:       at SlimDX.Direct3D9.Line.Draw(Vector2[] vertexList, Color4 color)       at Microsoft.Research.DynamicDataDisplay.DirectX2D.DirectXLineGraph.OnDirectXRender() in C:\Users\abrahamvivas\Downloads\D3Dx\DynamicDataDisplay.DirectX2D\DirectXLineGraph.cs:line 180       at Microsoft.Research.DynamicDataDisplay.DirectX2D.DirectXChart.OnMainLoop(Object sender, EventArgs e) in C:\Users\abrahamvivas\Downloads\D3Dx\DynamicDataDisplay.DirectX2D\DirectXChart.cs:line 224       at System.EventHandler.Invoke(Object sender, EventArgs e)       at Microsoft.Research.DynamicDataDisplay.DirectX2D.SlimDXControl.OnMainLoop(EventArgs e) in C:\Users\abrahamvivas\Downloads\D3Dx\DynamicDataDisplay.DirectX2D\SlimDX\SlimDXControl.xaml.cs:line 239       at Microsoft.Research.DynamicDataDisplay.DirectX2D.SlimDXControl.OnRendering(Object sender, EventArgs e) in C:\Users\abrahamvivas\Downloads\D3Dx\DynamicDataDisplay.DirectX2D\SlimDX\SlimDXControl.xaml.cs:line 711       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)       at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)       at System.Windows.Threading.DispatcherOperation.InvokeImpl()       at System.Threading.ExecutionContext.runTryCode(Object userData)       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)       at System.Windows.Threading.DispatcherOperation.Invoke()       at System.Windows.Threading.Dispatcher.ProcessQueue()       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)       at System.Windows.Application.RunInternal(Window window)       at System.Windows.Application.Run()       at TestD3DirectX.App.Main() in C:\Users\abrahamvivas\Downloads\D3Dx\Examples\TestD3DirectX\obj\Debug\App.g.cs:line 0       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)       at System.Threading.ThreadHelper.ThreadStart()  InnerException: 

Jan 27, 2012 at 9:31 AM
Edited Jan 27, 2012 at 9:34 AM

Hi

 

insert the if statment in Microsoft.Research.DynamicDataDisplay.DirectX2D.DirectXLineGraph

 

 

protected override void OnDirectXRender()
        {
            ...

            //_line.Draw(pointList, new Color4(color.ToArgb()));
            if (pointList.Count() > 0)
                _line.Draw(pointList, color);
        }
 

 

best regards

Tobias