简体   繁体   English

labview - 缓冲数据然后保存到excel文件

[英]labview - buffer data then save to excel file

My question is with respect to a labVIEW VI (2013), I am trying to modify.我的问题是关于 labVIEW VI (2013),我正在尝试修改。 (I am only just learning to use this language. I have searched the NI site and stackoverflow for help without success, I suspect I am using the incorrect key words). (我只是刚开始学习使用这门语言。我已经在 NI 站点和 stackoverflow 上搜索了帮助,但没有成功,我怀疑我使用了不正确的关键字)。

My VI consists of a flat sequence one pane of which contains a while loop where integer data is collected from a device and displayed on a graph.我的 VI 由一个平面序列组成,其中一个窗格包含一个 while 循环,其中从设备收集整数数据并显示在图形上。

I would like to be able to be able to buffer this data and then send it to disk when a preset number of samples have been collected.我希望能够缓冲这些数据,然后在收集到预设数量的样本后将其发送到磁盘。 My attempts so far result in only the last record being saved.到目前为止,我的尝试只保存了最后一条记录。

Specifically I need to know how to save the data in a buffer (array) then when the correct number of samples are captured save it all to disk (saving as it is captured slows the process down to much).具体来说,我需要知道如何将数据保存在缓冲区(数组)中,然后在捕获到正确数量的样本时将其全部保存到磁盘(在捕获时保存会使过程减慢很多)。

Hope the question is clear and thanks very much in advance for any suggestions.希望问题很清楚,并非常感谢您提出任何建议。 Tom汤姆

Below is a simple circular-buffer that holds the most recent 100 readings.下面是一个简单的循环缓冲区,其中包含最近的 100 个读数。 Each time the buffer is refilled, its contents are written to a text file.每次重新填充缓冲区时,其内容都会写入文本文件。 Drag the image onto a VI's block diagram to try it out.将图像拖到 VI 的程序框图上进行试用。

在此处输入图像描述

As you learn more about LabVIEW and as your performance and multi-threaded needs increase, consider reading about some of the LabVIEW design patterns mentioned in the other answers:随着您对 LabVIEW 的了解越来越多,以及性能和多线程需求的增加,请考虑阅读其他答案中提到的一些LabVIEW 设计模式

I'd suggest to split the data acquisition and the data saving in two different loops using a producer/consumer design pattern.我建议使用生产者/消费者设计模式将数据采集和数据保存分成两个不同的循环。 . .

来自 NI 网站的生产者/消费者示例

Moreover if you need a very high throughput consider using TDMS file format.此外,如果您需要非常高的吞吐量,请考虑使用 TDMS 文件格式。 Have a look here for an overview: http://www.ni.com/white-paper/3727/en/在这里查看概述: http ://www.ni.com/white-paper/3727/en/

Screenshot will definitely help.屏幕截图肯定会有所帮助。 However, some things are clear:但是,有些事情是明确的:

Unless you are dealing with very high volume of data, very slow hard drives or have other unusual requirements, open the file before your while loop, write to it every time you acquire a sample (leaving buffering to the OS), and close it afterwards.除非你正在处理非常大量的数据,非常慢的硬盘驱动器或有其他不寻常的要求,否则在你的 while 循环之前打开文件,每次获取样本时写入它(将缓冲留给操作系统),然后关闭它.

If you decide you need to manage buffering on your own, you can use queues.如果您决定需要自己管理缓冲,则可以使用队列。 See this example: https://decibel.ni.com/content/docs/DOC-14804 for reference (they stream data from disk, buffering it in the queue, but it is the same idea)请参阅此示例: https ://decibel.ni.com/content/docs/DOC-14804 以供参考(他们从磁盘流式传输数据,将其缓冲在队列中,但这是相同的想法)

My VI consists of a flat sequence one pane of which我的 VI 由一个平面序列组成,其中一个窗格

Substitute flat sequence for finite state machine (eg http://forums.ni.com/t5/LabVIEW/Ending-a-Flat-Sequence-Inside-a-case-structure/td-p/3170025 )用有限状态机替换平面序列(例如http://forums.ni.com/t5/LabVIEW/Ending-a-Flat-Sequence-Inside-a-case-structure/td-p/3170025

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

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