C#中线条和点的图形 [英] Graphics if lines and ponts in C#

查看:90
本文介绍了C#中线条和点的图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何基于从USB微控制器实时获取的一些数据生成线和点的图形
在C#中,

How to generate a graph of lines and points based on some data acquired from a USB microcontolador real-time
in C# °

推荐答案

这是一项非常具有挑战性的任务,需要您学会一次做几件事.您需要与USB微控制器进行接口并从中接收数据流,然后将数据放置在某处.然后,您需要绘制一个折线图,只要有新数据从USB端口传入,它就会使用新到达的数据进行更新.这可以通过将任务划分为单独的线程,一个用于协调所有内容的主线程和两个用于维护数据流并保持图形更新的辅助线程来实现.

CodeProject上有一些出色的文章,可以教您如何访问USB端口,以及其他有关图形绘制的知识.问题的复杂性太大,无法在此处找到答案,但要花一些时间来搜索和阅读可用的文章.在您对需要做的事情有了更多的了解之后,回到这里来解决您无法解决的问题.
That''s a very challenging assignment, requiring that you learn to do several things at once. You''ll need to interface with your USB microcontroller and receive a data stream from it, then put the data somewhere. Then you need to draw a line graph that updates itself with newly arrived data whenever new data comes in from the USB port. This would probably be accomplished by dividing the tasks into separate threads, one master thread to coordinate everything, and two worker threads to maintain the data flow, and keep the graph updated.

There are some excellent articles here on CodeProject that can teach you about accessing USB ports, and others about graphing. The complexity of the problem is too great to expect an answer here, but spend some time searching for and reading the articles available. After you''ve become more informed about what you need to do, come back here with specific questions on matters you can''t solve yourself.


做起来可能并不难这可以通过C#WinForm和诸如Zedgraph的图表库(一个出色的免费图表库)来完成.第一步是与设备建立连接.如果您使用RS232串行通信,则可以通过System.IO.Ports中的SeialPort类来完成.一旦建立了连接,就需要通过某些命令从设备查询数据,或者如果设备定期发送数据,则需要通过串行端口接收此数据.现在,您需要了解数据格式.假设您正在接收CSV字符串数据,该数据可能是点的X和Y坐标,现在根据所使用的图表库将此数据解析为Point结构,一旦收集了这些点,就将它们绘制在图形上.现在,如果这与您要查找的内容有关,那么您需要了解有关使用SerialPort类和ZedGraph库的知识.您当然可以在CodeProject上找到许多出色的文章.在我看来,您应该开发一个没有任何线程的工作程序,并且一旦您的应用程序启动并运行,便可以使用线程来提高性能.如果您的数据没有以很高的速率被泵送,那么您可能根本不需要多线程,也不需要额外的复杂性.
It may not be so hard to do this with C# WinForm & a charting library like Zedgraph(an excellent free charting library).The first step is to establish a connection with your device.If you are using RS232 serial communication this may be accomplished with SeialPort class in System.IO.Ports namespace.Once you have connection in place you need to query data from the device via some command or if device is regularly sending data you need to receive this data via your serial port. Now you need to know how the data format is. Suppose you are receiving a CSV string data, that may be X and Y coordinates of the points , now parse this data to Point structure depending on the charting library you are using and once you have collection of these points , plot them on the graph . Now if this is relevant to what you was looking for then you need to know about using SerialPort class and ZedGraph library.Of course you can find number of excellent articles on CodeProject. In my opinion you should develop a working program without any threading and once your application is up and running then you can go for threading to improve the performance. If your data is not pumped at very high rate you may not require a multi- threading at all & also the additional complexity.


这篇关于C#中线条和点的图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆