LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

state machine with polling loop

Solved!
Go to solution

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?  

 

 

 

 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 27
(3,563 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 27
(3,558 Views)

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

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 3 of 27
(3,543 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 4 of 27
(3,540 Views)

 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?   

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 5 of 27
(3,524 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 6 of 27
(3,507 Views)

To me it sounds like a ordinary Event Structure - User selects a row through some control and you use the value change event.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 27
(3,504 Views)

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!

 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 8 of 27
(3,496 Views)

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.   

 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 9 of 27
(3,493 Views)
Solution
Accepted by topic author jyang72211

Take a look at this example.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 10 of 27
(3,477 Views)