简体   繁体   English

使用Qt,QWT和C ++进行实时数据绘图

[英]Real Time Data Plotting With Qt, QWT and C++

I'm compelety new to Qt,QWT and have a basic knowledge in C++. 我是Qt,QWT的新手,并且具备C ++的基础知识。

According to the project that i got, i have to acquire some data given by the sensors on a caravan, like solar panel voltage and current, the temperature,humidity and so on. 根据我得到的项目,我必须获取大篷车上传感器给出的一些数据,如太阳能电池板的电压和电流,温度,湿度等。 All these datas are acquired by some sensors and collected by a NI 6229 DAQ Device. 所有这些数据都由一些传感器采集并由NI 6229 DAQ设备采集。

Until now, i just gave the sidelights. 直到现在,我只是给了侧灯。 Now i'm coming to the real problem. 现在我要解决真正的问题。

I want to acquire the datas that came from the DAQ device and show,plot,record and log in a program. 我想获取来自DAQ设备的数据并显示,绘制,记录和登录程序。

I've decided to use C++, Qt and QWT. 我决定使用C ++,Qt和QWT。 And the NIDAQMX API for acquiring the data from the DAQ device of course. 当然,NIDAQMX API用于从DAQ设备获取数据。

I've already designed a GUI partly, but the point where i stuck is the real working part of my code. 我已经部分设计了一个GUI,但我卡住的地方是我的代码的真正工作部分。

I don't know how to implement all these stuff with taking the performance criterias into account and i really need a guide. 我不知道如何考虑性能标准来实现所有这些东西,我真的需要一个指南。

How should i handle data acquisition ? 我该如何处理数据采集?

How should i plot the datas that i acquire ? 我应该如何绘制我获得的数据?

Are these need to be seperated by different threads or some another structure ? 这些是否需要由不同的线程或其他结构分开?

Does collecting almost 10 or 12 channels data and plotting it in real time cause reasonable performance problems ? 收集几乎10或12个通道数据并实时绘制数据会导致合理的性能问题吗? If so, how can i handle it ? 如果是这样,我该如何处理?

Thanks in advance. 提前致谢。

If you write a simple program to work with NI 6229, you need to set the priority of operations: plotting or recording data. 如果编写一个简单的程序来使用NI 6229,则需要设置操作的优先级:绘制或记录数据。
In most cases, data storage is the most important operation. 在大多数情况下,数据存储是最重要的操作。
In my practice, I used the following algorithm: 在我的实践中,我使用了以下算法:

  • 1 GUI thread (common UI + plotting), 1 thread for data acquisition for every device, 1 thread for recording data. 1个GUI线程(通用UI +绘图),1个用于每个设备数据采集的线程,1个用于记录数据的线程。
  • Thread for data acquisition runs every dT time (we ask device: - how much data ready? - 10000 samples - ok, gimme it). 用于数据采集的线程每dT时间运行一次(我们询问设备: - 准备好多少数据? - 10000个样本 - 确定,给它一点)。 Because the NI 6659 has a sampling frequency less 1 MSamples/s, I think the value of dT will be roughly 50-200 ms (depends on interface). 由于NI 6659的采样频率低于1 MSamples / s,我认为dT的值大约为50-200 ms(取决于接口)。
  • After reading data from device I send data to thread for recording by using queue for that. 从设备读取数据后,我使用队列将数据发送到线程进行记录。
  • The same about plotting. 关于绘图也一样。 I use qwt with data decimation (but you should save peaks). 我使用qwt进行数据抽取(但你应该保存峰值)。 Qwt has not bad example for it. Qwt也没有不好的例子。 Also you can find solutions to increase plotting performance. 您还可以找到提高绘图性能的解决方案。 My advice is to split charts to groups, for example, one group may contain 4 charts. 我的建议是将图表拆分为组,例如,一组可能包含4个图表。

It's solution for simple program only and not for realtime OS. 它只是简单程序的解决方案,而不是实时操作系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM