|
real time chart from UDP data |
Posted by AM.s on Sep-22-2016 16:44 |
|
Hi , I wrote a Win32 program in VS2010 that receive UDP packet . I want to plot data in real time mode .(My data type is array of int that came from sender).I saw your MFC examples code, but I can not use it in my Win32 program. Can you help me, how to use your MFC examples like realtime project ?
Thanks |
Re: real time chart from UDP data |
Posted by Peter Kwan on Sep-23-2016 02:27 |
|
Hi AM.s,
There are many kinds of Win32 program. I assume you are writing a Windows GUI program, and not a console program.
Your probably already know that C++ itself does not have GUI. Using the OS directly by processing the GUI message loop is difficult and uncommon nowadays. Most people will use some sort of GUI framework, such as MFC or Qt. Are you using any GUI framwork, or just interface with the OS and handles the message loop yourself?
If you are not using any GUI framework, but can modify your code to use any framework you like, you may consider to use MFC. In this case, to begin width, you can try to move your UDP code to the realtime chart example to replace the random number generator, so it can plot your data instead of random numbers.
If you must create a GUI program without any GUI framework, I assume you know how to display an image on the screen and set up a timer using the standard Win32 method. In this case, you can use ChartDirector to periodically create the chart image with your latest data (which should be constant updated by your code that processed the UDP packet), then display it on the screen. The charting part of the sample code already demonstrates how to create the chart. Instead of outputting to the MFC ChartViewer, you can output the chart as BMP in memory, create a HBITMAP, and displays it. In case you need the code to create a HBITMAP from BMP, an example can be found at:
http://www.chartdir.com/forum/download_thread.php?bn=chartdir_general&pattern=HBITMAP&thread=1169546968#N1169577379
Regards
Peter Kwan |
Re: real time chart from UDP data |
Posted by AM.s on Sep-24-2016 14:08 |
|
Hi
Dear Peter
I didn't use GUI program ,I wrote console program which is receive UDP packet.
I knew for using GUI in C++ I have to use GUI framework such as QT or MFC. Although i can not work MFC framework very well Because i am beginner at this framework.
Peter Kwan wrote:
If you are not using any GUI framework, but can modify your code to use any framework you like, you may consider to use MFC. In this case, to begin width, you can try to move your UDP code to the realtime chart example to replace the random number generator, so it can plot your data instead of random numbers.
Regards
Peter Kwan
I want to do that but I have problem with MFC real time project: I replaced initialization of udp socket in example code and received a packet of data(array of int) but when I replaced data to random number generator section in example code, it can not draw and plot. I run the code as debugging mode but i can not understood why ?
Thanks |
Re: real time chart from UDP data |
Posted by Peter Kwan on Sep-25-2016 18:42 |
|
Hi AM.s,
It is hard to trouble-shoot your code without seeing the code. Is it possible to email the modified realtime chart example to me so I can try the trouble-shoot the issue? My email is pkwan@advsofteng.net
Regards
Peter Kwan |
Re: real time chart from UDP data |
Posted by Alex on Sep-25-2016 20:39 |
|
Hi Dear Peter
Woww , I am surprised , your support is very excellent.
My problem resolved .
I wrote initialization of socket in new function out of random number generator section and data drew successfully
Thank you
Best Regard
AM.s |
|