LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

queue vs property node: update problem in event structure QSMPC

Hi,

 

I am using queued statemachine as consumer and event structure as producer . events are giving some data to a graph which are read in consumer. but i require the consumer to run in a certain state since i will bedoing some operation on the data. please look at the attachment.

 

I am using a property node to get the data that event structure emitted and also circulating the queue with the same data in same state, but for some reason the queue operation is getting the previous event data and cycling between the new data.

 

observe both the graphs. how can i make the queue graph not cycle and display only the current data as the property node graph in my attachment.

 

attached LV8.2 ver

 

Thanks

0 Kudos
Message 1 of 9
(4,190 Views)

Because you initially queue up event 1 in the timeout event case.  Later on you queue up event 2 data.  But in your consumer loop, you are always re-enqueueing your element.  So event 1 data gets put back in, then event 2 comes up and will get put back in.  Your are constantly cycling between 2 elements in your queue.  If you keep hitting the event 1 or event 2 button, you are putting even more data in your queue cycling among 3 elements, 4 elements, 5 elements and so on.

 

Why are you re-enqueueing the element in the consumer loop?

0 Kudos
Message 2 of 9
(4,174 Views)

I want to process the graph data constantly using cursors etc so i need the consumer loop always running but update with new graph when ever event occurs. if i dont re enque, the loop runs only as many times as events occured. is there a better way using queues differently to solve my problem, i dont want to use the locals/ property node for graph update I am new to queues

 

Thanks

0 Kudos
Message 3 of 9
(4,171 Views)

Right now you aren't doing anything with cursors, and not doing anything but displaying data in your consumer loop.  So there is no need to re-enqueue.

 

If you want to do something with cursors, then add other event cases to your producer loop that look for cursor events.

0 Kudos
Message 4 of 9
(4,169 Views)

i have a larger program that does some operation with cursors and other logic that needs the loop be running all the time. I have made this test program for forum posting purpose only.

I just want the consumer loop to run continuously. re-enqueuing was just a bad implementation i guess.

 

what i was trying to do was have only 1 element in the queue at any time so that it is cycled like in a shift register.

 

deque 1 element it becomes empty then re enque with the same element so it cycles the same element but when event occurs deque new element and get that element cycled again

 

is it possible

0 Kudos
Message 5 of 9
(4,166 Views)

I scratched my head all over and still could not make out why it is happening.....Somehow the data is being getting added..But from where?

 

Guru

Regards
Guru (CLA)
0 Kudos
Message 6 of 9
(4,151 Views)

freemason wrote:

i have a larger program that does some operation with cursors and other logic that needs the loop be running all the time. I have made this test program for forum posting purpose only.

I just want the consumer loop to run continuously. re-enqueuing was just a bad implementation i guess.

 

what i was trying to do was have only 1 element in the queue at any time so that it is cycled like in a shift register.

 

deque 1 element it becomes empty then re enque with the same element so it cycles the same element but when event occurs deque new element and get that element cycled again

 

is it possible


 

Use the timeout terminal of the dequeue element, if the dequeue times out, then have a case structure that executes the "run" command.

 

Have you created a flowchart that defines all of your states and their order of execution?  What do you want to have happen when the Event1 data has been running and you hit the Event2 data, do you want your state machine to forget about the event 1 data?   Are there other events or conditions that you haven't programmed yet?  How do they fit into the overall flow of the program?

 

 


Guruthilak wrote:

I scratched my head all over and still could not make out why it is happening.....Somehow the data is being getting added..But from where?

 

Guru


 

Look at the end of the Run case in the consumer loop.  The data that was de-enqueued is getting all bundled up again and re-enqueued.
0 Kudos
Message 7 of 9
(4,128 Views)

exactly,

 

I wanted only one element at a time. i dont want the SM to forget the previous but dequeue everything it has, make sure it is empty and then only enqueue new..

 

i think i figured it out. now it acts the way i wanted similar to the property node but without using it and proper usage of Qs

 

see attached.

 

also when i hit the stop button there were 2 events queued up since stop state also had other enqueue element. now i just use state and data only once depending on the stop button pressing.

 

Thanks for the feedback .

I shall post more if i run into problems..

0 Kudos
Message 8 of 9
(4,121 Views)

I'm glad to hear it is starting to work the way you want now.

 

Don't forget to wire up the error wires on your queue functions.

0 Kudos
Message 9 of 9
(4,119 Views)