NI LabVIEW,CVI,数据采集等产品讨论区

取消
显示结果 
搜索替代 
您的意思是: 

生产者消费者结构能随时启动停止吗

生产者消费者结构+状态图。可以通过前面板控制,或者后面板数据独立控制消费者循环以及生产者循环的运行。

存在的问题是,不能实现“中止”的操作,及如果某一个循环中存在长延时,那么,一定要等待延时结束,才能响应状态改变。

0 项奖励
11 条消息(共 15 条)
2,398 次查看

延时肯定是必须要等待完毕的。你可以试试在一个并行的循环里面调用停止的VI。

ScreenHunter_01 Jan. 04 11.33.gif

District Sales Manager | Shanghai Pudong, China
0 项奖励
12 条消息(共 15 条)
2,360 次查看

If the delay used is for causing a preset delay before an action, you might wanna try using Elapsed Time instead. With Elapsed Time, the similar, if not same, flow control can be achieve through its Time has Elapsed output i.e. True to execute next action, while having able to stop the loop almost immediately...

 

Hope above make sense to you 😉 

 

 

PS: Below is of Context Help of STOP vi. Try avoid using STOP unless necessary.

Stop Details

If you need to abort execution of all VIs in a hierarchy from the block diagram, you can use this function, but you must use it with caution. Before you call this function with a TRUE input, be sure to complete all final tasks for the VI first, such as closing files, setting save values for devices being controlled, and so on. If you put this function in a subVI, you should make its behavior clear to other users of the VI because this function causes their VI hierarchies to abort execution.

 

In general, avoid using this function when you have a built-in termination protocol in a VI. For example, I/O operations should be performed in While Loops so that the VI can terminate the loop on an I/O error. Also, consider using a front panel stop button Boolean control to terminate the loop at the request of the user rather than using this function.

 

Message Edited by ian fung on 01-07-2010 10:50 AM
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
0 项奖励
13 条消息(共 15 条)
2,332 次查看

Within the same vi, there is no perfect solution to terminate a running "thread" with a delay component in it as soon as you press some button, unless the developer can get the handle of these "threads".But, as you know, not all of these for/while loops are actually threads.Once "handles" are provided, maybe, the architecture of LV would be ruined.So, the only thing we can do is putting codes in a subvi, than terminating that vi.

 

by the way, there are huge differences between Time Delay and Elapsed Time. i don't think they can replace with each other any time.Elapsed Time just is a time counter, and costs a high CPU usage, while Time Delay doesn't do that.When Time Delay is running, your codes just become still and costs 0 CPU usage.

 

here is example(LV09) showing the difference between Time Delay and Elapsed Time.

 

Message Edited by hunt978 on 01-06-2010 08:44 PM
0 项奖励
14 条消息(共 15 条)
2,327 次查看

If you use the combination of Time Delay and Elapsed Time, it is achievable, not exact, but close.

Unless CPU usage is Super critical to your program, else, using Elapsed Time for triggering of "next" action, and with a small loop delay (using Time Delay) shouldn't cause too high the CPU usage... some level of compromise has to be done in order to have both the timed-delay-action and "immediate" response of a while-loop.

 

Here is an example of such...  

Message Edited by ian fung on 01-07-2010 01:20 PM
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
0 项奖励
15 条消息(共 15 条)
2,321 次查看