05-03-2011 09:14 AM
I asked a similar question before, but I realized that I was not being clear, so I am asking my question again in a more concise and clear format.
Two Loops:
- 1st Loop: run a state machine to produce data (a 2d array)
- 2nd Loop: 1) poll the user concerning which row in the 2d array (passed form 1st Loop) to display and 2) display the row on GUI
I don't want to use polling on my 2nd loop. I try to use queue, but I don't think it fits my application too well, since I have to pass data and to poll user input. At the end, I thought it would be for the best if I just create a functioal variable (FV) to pass data from loop 1 to loop 2 and to display the data in loop 2 based on the user input received through polling in loop 2 (Yes, polling!!). Is there a better way? What do you think?
Solved! Go to Solution.
05-03-2011 09:20 AM
Can you please post an example of what you have done. I is difficult to give you suggestions without seeing what you have done.
Also, I would recommend that you use an event structure for moniroing the user's actions rather than polling. This way your UI code will only run when there is a user action.
05-03-2011 10:17 AM
Hi Mark,
I thought about using an event structure for monitoring user's action rather than polling as well, but besides user's action (changing enum value), I want UI to update on the condition below as well.
1. When user select the enum but decided to leave the value the same (no value change event)
2. When new data is available, the UI should update with the current enum value (no event at all). Maybe I can use a dynamic event?
See attachment on the first post of the link below.
http://forums.ni.com/t5/LabVIEW/Comment-on-design-selection/m-p/1544648#M571666
05-03-2011 10:21 AM
Yes, you can use a dynamic event to trigger the update. The first item is not an issue since you don't need to write a value to the ENUM. It has whatever value the user set whether that is a new value or the old one. You can test inside the event to see if the value was changed and do nothing if it is the same value.
05-03-2011 12:11 PM
After I dequeued in my consumer, and I have multiple event occuring, I will not be able to handle the events after the first event, since the consumer loop is stuck at dequeuing (see attached). Should I use preview queue, lossy enqueue, and a event structure instead? If I have to do this, should I still use queue? Maybe I should use something else? Is there a way to use regular enqueue and dequeue in my design?
05-03-2011 01:08 PM
How large will your data set be? How often will it be changing? Will you be continuously collecting data? Based on these answers I can propose a ideas. BTW, you misunderstand how the producer/consumer architecture works. As you discovered you cannot have the loop with the event structure (typically the producer loop) waiting on both the queue and the event. Generally the loop with th eevent structure enqueues the data/message/action.
05-03-2011 01:17 PM - edited 05-03-2011 01:18 PM
To me it sounds like a ordinary Event Structure - User selects a row through some control and you use the value change event.
/Y
05-03-2011 01:40 PM
1. The data point is just be an 8 elements cluster array.
2. There is a new data point once every 3 minutes.
3. I will be continuously collecting data. I am going to log all data into a file, and display only the current data point on UI.
When the consumer has the current data point (array) and the producer has not produced the new data point, the consumer should allow the user to select which element from the current data point to display on UI.
I understand that I am not using queue properly. That's why I want to know what is the right way and all the alternative ways.
Thanks!
05-03-2011 01:42 PM
Hi Yamaeda,
The problem is when the consumer has the current data point (array) and the producer has not produced the new data point, the consumer should allow the user to select which element from the current data point to display on UI.
However, after the first event, the consumer loop is stuck waiting for the next new data. I want the consumer loop to select different index of the current arrray.
05-03-2011 03:46 PM
Take a look at this example.