ni.com is currently undergoing scheduled maintenance.
Some services may be unavailable at this time. Please contact us for help or try again later.
To download NI software, including the products shown below, visit ni.com/downloads.
Overview
Monitor and visualize how many events have been requested using queues.
Description
Event-Driven applications can be easily made in LabVIEW. However, even while the Event Structure will monitor and queue events as they occur, it does not provide information about the events waiting for their turn to run. Specifically, if you trigger an event that takes several minutes to execute, you can still trigger more events while that first event case finishes executing. The newly triggered events will wait for the first event’s code to complete before they run. Unfortunately, the Event Structure does not give you any way to see what events are waiting, how many events are waiting nor will you be able to manipulate the events waiting. This example program will show you how you can implement your own, user defined queue to use with an Event Structure.
This example VI contains a queue that stores events generated by an Event Structure in a Producer Loop. Rather than having the code for each event run in the Event Structure, the Event Structure quickly passes what event occurred out and enqueues that information. That information is than dequeued in a Consumer Loop where the code for each event actually runs. When the code for the first event finishes in the Consumer Loop, the next event in the queue’s code will run next… While the Producer Loop is adding events to the queue and the Consumer Loop is removing the element from the queue to perform the required action, the queue can be read and manipulated anywhere on the block diagram. In this example VI, there is a Monitor Loop that monitors amount of elements in queue. There is also a mechanism for clearing the queue.
Requirements
LabVIEW 2012 (or compatible)
Steps to Implement or Execute Code
1. Run the VI
2. Quickly push buttons to generate events and add them to the queue
3. Visualize how they are being updated
4. Use the Stop button to finish execution
Additional Information or References
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.